Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

V (programming language)

From Wikipedia, the free encyclopedia
General-purpose programming language
V
A capitalized letter V colored blue
The official V logo
ParadigmsMulti-paradigm:functional,imperative,structured,concurrent
Designed byAlexander Medvednikov[1]
First appeared20 June 2019; 6 years ago (2019-06-20)[2]
Stable release
0.5[3] Edit this on Wikidata / December 31, 2025; 45 days ago (December 31, 2025)
Typing disciplinestatic,strong,inferred
Memory managementoptional (automatic ormanual)
Implementation languageV
OSLinux,macOS,Windows,FreeBSD,OpenBSD,NetBSD,DragonflyBSD,Solaris
LicenseMIT
Filename extensions.v,.vsh
Websitevlang.io
Influenced by
Go,Kotlin,Oberon,Python,Rust,Swift

V, also known asvlang, is an in-developmentstatically typed,compiledprogramming language created by Alexander Medvednikov in early 2019.[4] It was inspired byGo, and other programming languages includingOberon,Swift, andRust.[5][6][7] It isfree and open-source software released under theMIT License, and currently inbeta.[8]

The goals of V include ease of use,readability, andmaintainability.[9][10][11]

History

[edit]

The new language was created as a result of frustration with existing languages being used for personal projects.[12] It was originally intended for personal use,[12] but after being mentioned publicly and increasing interest, it was decided to make it public.[13] V was initially created to develop a desktop messaging client named Volt.[6] On public release, the compiler was written in V, and couldcompile itself.[4][12] Key design goals in creating V were being easy to learn and use, higher readability, fast compiling, increased safety, efficient development,cross-platform usability, improvedCinteroperability, bettererror handling, modern features, and more maintainable software.[14][15][10][16]

V is developed, maintained, and released through GitHub[17][6] by developers and contributors internationally.[4] In 2025, V started being ranked on theTIOBE index.[18]

Veasel is the official mascot of the V programming language[19]

Features

[edit]

Safety

[edit]

V has policies to facilitate memory-safety, speed, and secure code,[14][20][6] including various default features for greater program safety.[7][14][12] It employsbounds checking, to guard against out of bounds use ofvariables. Option/resulttypes are used, where the optiondata type (?) can be represented bynone (among possible choices) and the result type (!) can handle any returned errors. To ensure greater safety, error checking is mandatory. By default, the following areimmutable: variables, structs, andfunctionarguments. This includes string values are immutable, so elements cannot be mutated. Other protections, which are the default for the language, are: no use ofundefined values,variable shadowing,null pointers (unless marked as unsafe), orglobal variables (unless enabled via flag).

Performance

[edit]

V usesvalue types and string buffers to reduce memory allocations.[21][22][14] The language can be compiled to human-readable C,[7][4] and in terms of execution and compilation, it's considered to be as performant.[14][15][12]

Memory management

[edit]

V supports four memory management options:[23][6][12][4]

  1. Agarbage collector. This is the default.
  2. Manual memory management via disabling the garbage collector.
  3. Autofree, which is experimental, for invoking the necessary calls to automatically free upobjects during compilation.
  4. Arena allocation.

Source code translators

[edit]

V supports asource-to-source compiler (transpiler) and can translate C code into V.[15][24][10]

Working translators are also being developed for Go,JavaScript, andWebAssembly.[25][26][4]

Syntax

[edit]

Hello world

[edit]

The"Hello, World!" program in V:[14][27]

fnmain(){println("Hello, World!")}

Variables

[edit]

Variables are immutable by default and are defined using:= and a value. Use themutreserved word (keyword) to make them mutable. Mutable variables can be assigned to using=:[28][27]

x:=1muty:=2y=3

Redeclaring a variable, whether in aninner scope or in the same scope, is not allowed:[28][27]

x:=1{x:=3// error: redefinition of x}x:=2// error: redefinition of x

Structs

[edit]

Struct example:[9][7][27]

structFoo{numberintnamestringscoref32}// Struct fields can be initialized by namevar1:=Foo{number:21name:"baz"score:2.5}// or by positionvar2:=Foo{50,"taz",3.14}

Heap structs

[edit]

By default, structs are allocated on thestack. When structs are referenced by using the prefix& or have the[heap] attribute, they are allocated on theheap instead:[4][27]

structFoo{numberint}@[heap]structBaz{numberf32}// Structs that are referenced are heap allocatedvar1:=&Foo{2}// Baz is always heap allocated because of its [heap] attributevar2:=Baz{4.5}

Methods

[edit]

Methods in V are functions defined with a receiverargument. The receiver appears in its own argument list between thefn keyword and the method name. Methods must be in the samemodule as the receiver type.

The enrolled_status method (below) has a receiver of typeClient namedx. The convention is not to use receiver names like self or this, but preferably a short name. For example:[9][10][27]

structClient{enrolledbool}fn(xClient)enrolled_status()bool{returnx.enrolled}println(Client{enrolled:true}.enrolled_status())// trueprintln(Client{enrolled:false}.enrolled_status())// false

Error handling

[edit]

Result types may represent an error returned from a function. Result types are declared by prepending!:!Type

Optional types may representnone. Option types prepend? to the type name:?Type.[9][7][23][27]

fnsomething(tstring)!string{ift=="foo"{return"foo"}returnerror("invalid")}x:=something("foo")or{"default"}// x will be "foo"y:=something("baz")or{"default"}// y will be "default"z:=something("baz")or{panic("{err}")}// z will exit with an errorprintln(x)println(y)

See also

[edit]

References

[edit]
  1. ^"Creator of V".GitHub.
  2. ^"First public release".GitHub. 20 June 2019.
  3. ^"Release 0.5".
  4. ^abcdefgRao 2021.
  5. ^Lewkowicz 2019.
  6. ^abcdeJames 2019.
  7. ^abcdeUmoren 2021.
  8. ^"The V Programming Language".vlang.io. Retrieved4 November 2023.
  9. ^abcdKnott 2019.
  10. ^abcdNasufi, Erdet."An introduction to V - the vlang".Debian Conference (DebConf). Retrieved24 July 2022.
  11. ^Sharma 2024.
  12. ^abcdefChakraborty & Haldar 2023.
  13. ^"A small presentation of V's features at IBM".YouTube. Retrieved6 March 2023.
  14. ^abcdefGaluh, Rosa (8 August 2022)."A Brief Introduction to the V Language".MakeUseOf (MUO).Valnet. Retrieved8 August 2022.
  15. ^abcChoudhury, Ambika (9 February 2022)."Meet V, The New Statically Typed Programming Language Inspired By Go & Rust".Analytics India Magazine (AIM). Retrieved7 July 2024.
  16. ^"V language: simple like Go, small binary like Rust".TechRacho. Retrieved3 March 2021.
  17. ^"GitHub Programming Languages (repository details)".
  18. ^"TIOBE Index".tiobe.TIOBE. Archived fromthe original on 11 April 2025. Retrieved11 April 2025.
  19. ^"V's official mascot".GitHub. Retrieved8 November 2023.
  20. ^Abbas, Hazem (5 August 2024)."Introduction to V Language and Desktop App Development".medevel. Retrieved3 January 2025.
  21. ^Rao 2021, p. 7.
  22. ^"The V programming language is now open source".Packt Hub.Packt Publishing. 24 June 2019. Retrieved24 June 2019.
  23. ^abTsoukalos 2022.
  24. ^Schlothauer n.d.
  25. ^"Convert Go to V with go2v".Zenn (in Japanese). 26 January 2023. Retrieved26 January 2023.
  26. ^"The V WebAssembly Compiler Backend".l-m. 26 February 2023. Archived fromthe original on 8 July 2024.
  27. ^abcdefg"V Documentation".docs.vlang.io. Retrieved25 August 2025. This article incorporates text from thisfree content work. Licensed under The MIT License (license statement/permission).
  28. ^abRao 2021, pp. 28–40.

Bibliography

[edit]

Further reading

[edit]
  • The V Programming Language basic (in Japanese). Independent Laboratory. 20 June 2020.ASIN B08BKJDRFR.
  • Lyons, Dakota "Kai" (13 April 2022).Beginning with V Programming. Independently Published.ISBN 979-8801499963.
  • Sanders, Rafael (18 September 2025).V Language for Beginners: How to Code with V for Fast, Simple, and Maintainable Software. Lincoln Publishers.ISBN 979-8263861681.
  • Sanders, Rafael (18 September 2025).V Language Intermediate Guide: How to Build Reliable Software with V’s Simple but Powerful Features. Lincoln Publishers.ISBN 979-8263865429.
  • Trex, Nova (24 December 2024).V Programming: Building Robust and Efficient Software Systems. Wang Press.ISBN 979-8304813778.
  • Vinicius Silva; Heitor Leite; Fernando Pereira (19 December 2025). "Multi-Language Benchmark Generation via L-Systems".arXiv:2512.17616v1 [cs.SE].

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=V_(programming_language)&oldid=1336242965"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp