| V | |
|---|---|
The official V logo | |
| Paradigms | Multi-paradigm:functional,imperative,structured,concurrent |
| Designed by | Alexander Medvednikov[1] |
| First appeared | 20 June 2019; 6 years ago (2019-06-20)[2] |
| Stable release | |
| Typing discipline | static,strong,inferred |
| Memory management | optional (automatic ormanual) |
| Implementation language | V |
| OS | Linux,macOS,Windows,FreeBSD,OpenBSD,NetBSD,DragonflyBSD,Solaris |
| License | MIT |
| Filename extensions | .v,.vsh |
| Website | vlang |
| 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]
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]

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).
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]
V supports four memory management options:[23][6][12][4]
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]
The"Hello, World!" program in V:[14][27]
fnmain(){println("Hello, World!")}
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
structFoo{numberintnamestringscoref32}// Struct fields can be initialized by namevar1:=Foo{number:21name:"baz"score:2.5}// or by positionvar2:=Foo{50,"taz",3.14}
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 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
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)
{{cite web}}: CS1 maint: ref duplicates default (link)