V (programming language)

V, also known as vlang, is a statically typed, compiled programming language created by Alexander Medvednikov in early 2019.[4] It was inspired by Go, and other programming languages including Oberon, Swift, and Rust.[5][6][7] It is free and open-source software released under the MIT License, and currently in beta.[8]

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.4.11[3] Edit this on Wikidata / June 19, 2025; 2 months ago (June 19, 2025)
Typing disciplinestatic, strong, inferred
Memory managementoptional (automatic or manual)
Implementation languageV
Platformx86-64
OSLinux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, DragonflyBSD, Solaris
LicenseMIT
Filename extensions.v, .vsh
Websitevlang.io
Influenced by
Go, Kotlin, Oberon, Python, Rust, Swift

The goals of V include ease of use, readability, and maintainability.[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, but after being mentioned publicly and increasing interest, it was decided to make it public. V was initially created to develop a desktop messaging client named Volt.[6] On public release, the compiler was written in V, and could compile 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, improved C interoperability, better error handling, modern features, and more maintainable software.[13][14][10][15]

V is released and developed through GitHub,[16][6] and maintained by developers and contributors internationally.[4] It is among the languages that have been listed on the TIOBE index.[17]

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

Features

edit

Safety

edit

V has policies to facilitate memory-safety, speed, and secure code,[13][19][6] including various default features for greater program safety.[7][13][12] It employs bounds checking, to guard against out of bounds use of variables. Option/result types are used, where the option data type (?) can be represented by none (among possible choices) and the result type (!) can handle any returned errors. To ensure greater safety, error checking is mandatory. By default, the following are immutable: variables, structs, and function arguments. This includes string values are immutable, so elements cannot be mutated. Other protections, which are the default for the language, are: no use of undefined values, variable shadowing, null pointers (unless marked as unsafe), or global variables (unless enabled via flag).

Performance

edit

V uses value types and string buffers to reduce memory allocations.[20][21][13] 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.[13][14][12]

Memory management

edit

V supports 4 memory management options:[22][6][12]

  1. Use of an optional garbage collection (GC), that can be disabled, for handling allocations, and is the default.
  2. Manual memory management via disabling the GC (-gc none).
  3. Autofree, which handles most objects via free call insertion, and then the remaining percentage is freed by GC (-autofree).
  4. Arena allocation (-prealloc).

Source code translators

edit

V supports a source-to-source compiler (transpiler) and can translate C code into V.[14][23][10]

Working translators are also being developed for Go, JavaScript, and WebAssembly.[24][25][4]

Syntax

edit

Hello world

edit

The "Hello, World!" program in V:[13][26]

fn main() {
	println("Hello, World!")
}

Variables

edit

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

x := 1
mut y := 2
y = 3

Redeclaring a variable, whether in an inner scope or in the same scope, is not allowed:[27][26]

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

Structs

edit

Struct example:[9][7][26]

struct Foo {
    number int
	name string
    score f32
}

// Struct fields can be initialized by name
var1 := Foo {
    number: 21
    name: "baz"
    score: 2.5
}

// or by position
var2 := Foo{50, "taz", 3.14}

Heap structs

edit

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

struct Foo {
    number int
}

@[heap]
struct Baz {
    number f32
}

// Structs that are referenced are heap allocated
var1 := &Foo{2}

// Baz is always heap allocated because of its [heap] attribute
var2 := Baz{4.5}

Methods

edit

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

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

struct Client {
    enrolled bool
}

fn (x Client) enrolled_status() bool {
    return x.enrolled
}

println(Client{enrolled: true}.enrolled_status())  // true
println(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 represent none. Option types prepend ? to the type name: ?Type.[9][7][22][26]

fn something(t string) !string {
	if t == "foo" { return "foo" }
	return error("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 error

println(x)
println(y)

See also

edit

References

edit
  1. ^ "Creator of V". GitHub.
  2. ^ "First public release". GitHub. 20 June 2019.
  3. ^ "Release 0.4.11". 19 June 2025. Retrieved 20 June 2025.
  4. ^ a b c d e f Rao 2021.
  5. ^ Lewkowicz, Jakub (25 June 2019). "SD Times news digest: V language now open sourced". SD Times. SD Times. Retrieved 25 June 2019.
  6. ^ a b c d e James, Ben (23 July 2019). "The V Programming Language: Vain Or Virtuous?". Hackaday. Hackaday. Retrieved 23 July 2019.
  7. ^ a b c d e Umoren, Samuel. "Building a Web Server using Vlang". Section. Archived from the original on 13 March 2023. Retrieved 5 April 2021.
  8. ^ "The V Programming Language". vlang.io. Retrieved 4 November 2023.
  9. ^ a b c d Knott, Simon (27 June 2019). "An introduction to V". Retrieved 27 June 2019.
  10. ^ a b c d Nasufi, Erdet. "An introduction to V - the vlang". Debian Conference (DebConf). Retrieved 24 July 2022.
  11. ^ Sharma, Gaurav (19 March 2024). "Exploring the newest programming languages for developers in 2024". TechGig. TechGig.com.
  12. ^ a b c d e Chakraborty & Haldar 2023.
  13. ^ a b c d e f Galuh, Rosa (8 August 2022). "A Brief Introduction to the V Language". MakeUseOf (MUO). Valnet. Retrieved 8 August 2022.
  14. ^ a b c Choudhury, Ambika (9 February 2022). "Meet V, The New Statically Typed Programming Language Inspired By Go & Rust". Analytics India Magazine (AIM). Retrieved 7 July 2024.
  15. ^ "V language: simple like Go, small binary like Rust". TechRacho. Retrieved 3 March 2021.
  16. ^ "GitHub Programming Languages (repository details)" – via OSS Insight using TiDB.[permanent dead link]
  17. ^ "TIOBE Index". tiobe. TIOBE. Archived from the original on 11 April 2025. Retrieved 11 April 2025.
  18. ^ "V's official mascot". GitHub. Retrieved 8 November 2023.
  19. ^ Abbas, Hazem (5 August 2024). "Introduction to V Language and Desktop App Development". medevel. Retrieved 3 January 2025.
  20. ^ Rao 2021, p. 7.
  21. ^ "The V programming language is now open source". Packt Hub. Packt Publishing. 24 June 2019. Retrieved 24 June 2019.
  22. ^ a b Tsoukalos 2022.
  23. ^ Schlothauer, Sarah. "The trendy five: Blazing hot GitHub repos in June 2019". JAXenter. Archived from the original on 17 February 2020. Retrieved 1 July 2019.
  24. ^ "Convert Go to V with go2v". Zenn. 26 January 2023. Retrieved 26 January 2023.
  25. ^ "The V WebAssembly Compiler Backend". l-m. 26 February 2023. Archived from the original on 8 July 2024.
  26. ^ a b c d e f g "V Documentation". docs.vlang.io. Retrieved 25 August 2025.   This article incorporates text from this free content work. Licensed under The MIT License (license statement/permission).
  27. ^ a b Rao 2021, pp. 28–40.

Further reading

edit
edit