V, also known as vlang, is a statically typed, compiled programming language created by Alexander Medvednikov in early 2019. Inspired by Go, Oberon, Swift, and Rust, V aims to prioritize ease of use, readability, and maintainability. It is free and open-source software released under the MIT License and is currently in beta.
History
According to various sources, the new language was created as a result of frustration with existing languages being used for personal projects.910 The language was originally intended for personal use, but after it was mentioned publicly and gained interest, it was decided to make it public. V was initially created to develop a desktop messaging client named Volt.11 On public release, the compiler was written in V, and could compile itself.1213 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.14151617
V is released and developed through GitHub,1819 and maintained by developers and contributors internationally.2021 It is among the languages that have been listed on the TIOBE index.22
Features
Safety
V has policies to facilitate memory-safety, speed, and secure code,232425 including various default features for greater program safety.262728 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
V uses value types and string buffers to reduce memory allocations.293031 The language can be compiled to human-readable C,32 and in terms of execution and compilation, it's considered to be as performant.3334
Memory management
V supports 4 memory management options:353637
- Use of an optional garbage collection (GC), that can be disabled, for handling allocations, and is the default.
- Manual memory management via disabling the GC (-gc none).
- Autofree, which handles most objects via free call insertion, and then the remaining percentage is freed by GC (-autofree).
- Arena allocation (-prealloc).
Source code translators
V supports a source-to-source compiler (transpiler) and can translate C code into V.383940
Working translators are also being developed for Go, JavaScript, and WebAssembly.414243
Syntax
Hello world
The "Hello, World!" program in V:44
fn main() { println("Hello, World!") }Variables
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 =:45
a := 1 mut b := 2 b = 3Redeclaring a variable, whether in an inner scope or in the same scope, is not allowed:46
a := 1 { a := 3 // error: redefinition of a } a := 2 // error: redefinition of aStructs
Struct example:47
struct Point { x int y int } mut p := Point { x: 10 y: 20 } println(p.x) // Struct fields are accessed using a dot // Alternative literal syntax for structs with 3 fields or fewer p = Point{10, 20} assert p.x == 10Heap structs
Structs are allocated on the stack by default. To allocate a struct on the heap and get a reference to it, the & prefix can be used:48
struct Point { x int y int } p := &Point{10, 10} // References have the same syntax for accessing fields println(p.x)Methods
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 is_registered method has a receiver of type User named u. The convention is not to use receiver names like self or this, but preferably a short name. For example:4950
struct User { age int } fn (u User) is_registered() bool { return u.age > 16 } user := User{ age: 10 } println(user.is_registered()) // "false" user2 := User{ age: 20 } println(user2.is_registered()) // "true"Error handling
Optional types are for types which may represent none. Result types may represent an error returned from a function.
Option types are declared by prepending ? to the type name: ?Type. Result types use !: !Type.515253
fn do_something(s string) !string { if s == "foo" { return "foo" } return error("invalid string") } a := do_something("foo") or { "default" } // a will be "foo" b := do_something("bar") or { "default" } // b will be "default" c := do_something("bar") or { panic("{err}") } // exits with error "invalid string" and a traceback println(a) println(b)See also
- Free and open-source software portal
- Computer programming portal
- Comparison of programming languages
- History of programming languages
- List of programming languages
- List of programming languages by type
Further reading
- The V Programming Language basic (in Japanese). Independent Laboratory. 20 June 2020. ASIN B08BKJDRFR.
- Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862.
- Lyons, Dakota "Kai" (13 April 2022). Beginning with V Programming. Independently Published. ISBN 979-8801499963.
- Tsoukalos, Mihalis (May 2022). "Discover the V language". Linux Format Magazine (288). Linux Format. ISSN 1470-4234.
- Chakraborty, Soubhik; Haldar, Subhomoy (6 December 2023). Randomness Revisited using the V Programming Language. Nova Science Publishers. doi:10.52305/CVCN5241. ISBN 979-8891133280. S2CID 265170755.
- Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. Wang Press. ISBN 979-8304813778.
External links
- Official website
- Vlang on GitHub
- Documentation
- Modules
- Video: How To Maintain And Iterate With V (Sydney Computing Society)
- Video: A small presentation of V's features at IBM
References
Rao 2021. - Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862. https://search.worldcat.org/oclc/1290492862 ↩
Lewkowicz, Jakub (25 June 2019). "SD Times news digest: V language now open sourced". SD Times. SD Times. Retrieved 25 June 2019. https://sdtimes.com/softwaredev/sd-times-news-digest-v-language-now-open-sourced-smartbear-acquires-bdd-provider-cucumber-and-kaggle-integrates-into-bigquery ↩
James, Ben (23 July 2019). "The V Programming Language: Vain Or Virtuous?". Hackaday. Hackaday. Retrieved 23 July 2019. https://hackaday.com/2019/07/23/the-v-programming-language-vain-or-virtuous/ ↩
Umoren, Samuel. "Building a Web Server using Vlang". Section. Archived from the original on 13 March 2023. Retrieved 5 April 2021. https://web.archive.org/web/20230313021526/https://www.section.io/engineering-education/building-web-server-with-vlang ↩
"The V Programming Language". vlang.io. Retrieved 4 November 2023. https://vlang.io/ ↩
Knott, Simon (27 June 2019). "An introduction to V". Retrieved 27 June 2019. https://simonknott.de/articles/vlang/ ↩
Nasufi, Erdet. "An introduction to V - the vlang". Debian Conference (DebConf). Retrieved 24 July 2022. https://debconf22.debconf.org/talks/69-an-introduction-to-v-the-vlang/ ↩
Sharma, Gaurav (19 March 2024). "Exploring the newest programming languages for developers in 2024". TechGig. TechGig.com. https://content.techgig.com/technology/exploring-the-newest-programming-languages-for-developers-in-2024/articleshow/108624842.cms ↩
Chakraborty 2023. sfn error: no target: CITEREFChakraborty2023 (help) ↩
Trex 2024. - Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. Wang Press. ISBN 979-8304813778. ↩
James, Ben (23 July 2019). "The V Programming Language: Vain Or Virtuous?". Hackaday. Hackaday. Retrieved 23 July 2019. https://hackaday.com/2019/07/23/the-v-programming-language-vain-or-virtuous/ ↩
Rao 2021. - Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862. https://search.worldcat.org/oclc/1290492862 ↩
Chakraborty 2023. sfn error: no target: CITEREFChakraborty2023 (help) ↩
Independent Laboratory 2020. sfn error: no target: CITEREFIndependent_Laboratory2020 (help) ↩
Lyons 2022. sfn error: no target: CITEREFLyons2022 (help) ↩
Nasufi, Erdet. "An introduction to V - the vlang". Debian Conference (DebConf). Retrieved 24 July 2022. https://debconf22.debconf.org/talks/69-an-introduction-to-v-the-vlang/ ↩
"V language: simple like Go, small binary like Rust". TechRacho. Retrieved 3 March 2021. https://techracho.bpsinc.jp/hachi8833/2021_03_09/89457/ ↩
"GitHub Programming Languages (repository details)" – via OSS Insight using TiDB. https://ossinsight.io/analyze/vlang/v#overview ↩
James, Ben (23 July 2019). "The V Programming Language: Vain Or Virtuous?". Hackaday. Hackaday. Retrieved 23 July 2019. https://hackaday.com/2019/07/23/the-v-programming-language-vain-or-virtuous/ ↩
Rao 2021. - Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862. https://search.worldcat.org/oclc/1290492862 ↩
Trex 2024. - Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. Wang Press. ISBN 979-8304813778. ↩
"TIOBE Index". tiobe. TIOBE. Archived from the original on 11 April 2025. Retrieved 11 April 2025. https://web.archive.org/web/20250411043213/https://www.tiobe.com/tiobe-index/ ↩
Galuh, Rosa (8 August 2022). "A Brief Introduction to the V Language". MakeUseOf (MUO). Valnet. Retrieved 8 August 2022. https://www.makeuseof.com/v-language-brief-introduction ↩
Abbas, Hazem (5 August 2024). "Introduction to V Language and Desktop App Development". medevel. Retrieved 3 January 2025. https://medevel.com/v-desktop-app-tutorial/ ↩
Trex 2024. - Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. Wang Press. ISBN 979-8304813778. ↩
Umoren, Samuel. "Building a Web Server using Vlang". Section. Archived from the original on 13 March 2023. Retrieved 5 April 2021. https://web.archive.org/web/20230313021526/https://www.section.io/engineering-education/building-web-server-with-vlang ↩
Galuh, Rosa (8 August 2022). "A Brief Introduction to the V Language". MakeUseOf (MUO). Valnet. Retrieved 8 August 2022. https://www.makeuseof.com/v-language-brief-introduction ↩
Trex 2024. - Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. Wang Press. ISBN 979-8304813778. ↩
Rao 2021, p. 7. - Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862. https://search.worldcat.org/oclc/1290492862 ↩
"The V programming language is now open source". Packt Hub. Packt Publishing. 24 June 2019. Retrieved 24 June 2019. https://hub.packtpub.com/the-v-programming-language-is-now-open-sourced-is-it-too-good-to-be-true// ↩
Galuh, Rosa (8 August 2022). "A Brief Introduction to the V Language". MakeUseOf (MUO). Valnet. Retrieved 8 August 2022. https://www.makeuseof.com/v-language-brief-introduction ↩
Rao 2021. - Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862. https://search.worldcat.org/oclc/1290492862 ↩
Galuh, Rosa (8 August 2022). "A Brief Introduction to the V Language". MakeUseOf (MUO). Valnet. Retrieved 8 August 2022. https://www.makeuseof.com/v-language-brief-introduction ↩
Trex 2024. - Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. Wang Press. ISBN 979-8304813778. ↩
Tsoukalos 2022. - Tsoukalos, Mihalis (May 2022). "Discover the V language". Linux Format Magazine (288). Linux Format. ISSN 1470-4234. https://search.worldcat.org/issn/1470-4234 ↩
James, Ben (23 July 2019). "The V Programming Language: Vain Or Virtuous?". Hackaday. Hackaday. Retrieved 23 July 2019. https://hackaday.com/2019/07/23/the-v-programming-language-vain-or-virtuous/ ↩
Chakraborty 2023. sfn error: no target: CITEREFChakraborty2023 (help) ↩
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. https://analyticsindiamag.com/meet-v-the-new-statistically-typed-programming-language-inspired-by-go-rust ↩
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. https://web.archive.org/web/20200217130047/https://jaxenter.com/github-trending-june-2019-159622.html ↩
Nasufi, Erdet. "An introduction to V - the vlang". Debian Conference (DebConf). Retrieved 24 July 2022. https://debconf22.debconf.org/talks/69-an-introduction-to-v-the-vlang/ ↩
"Convert Go to V with go2v". Zenn. 26 January 2023. Retrieved 26 January 2023. https://zenn.dev/tkm/articles/go2v-with-go-lsd ↩
"The V WebAssembly Compiler Backend". l-m. 26 February 2023. Archived from the original on 8 July 2024. https://web.archive.org/web/20240708075458/https://l-m.dev/cs/the_v_webassembly_compiler_backend/ ↩
Trex 2024. - Trex, Nova (24 December 2024). V Programming: Building Robust and Efficient Software Systems. Wang Press. ISBN 979-8304813778. ↩
Galuh, Rosa (8 August 2022). "A Brief Introduction to the V Language". MakeUseOf (MUO). Valnet. Retrieved 8 August 2022. https://www.makeuseof.com/v-language-brief-introduction ↩
Rao 2021, pp. 28–40. - Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862. https://search.worldcat.org/oclc/1290492862 ↩
Rao 2021, pp. 28–40. - Rao, Navule Pavan Kumar (10 December 2021). Getting Started with V Programming. Packt Publishing. ISBN 978-1839213434. OCLC 1290492862. https://search.worldcat.org/oclc/1290492862 ↩
Independent Laboratory 2020. sfn error: no target: CITEREFIndependent_Laboratory2020 (help) ↩
Independent Laboratory 2020. sfn error: no target: CITEREFIndependent_Laboratory2020 (help) ↩
Knott, Simon (27 June 2019). "An introduction to V". Retrieved 27 June 2019. https://simonknott.de/articles/vlang/ ↩
Independent Laboratory 2020. sfn error: no target: CITEREFIndependent_Laboratory2020 (help) ↩
Knott, Simon (27 June 2019). "An introduction to V". Retrieved 27 June 2019. https://simonknott.de/articles/vlang/ ↩
Umoren, Samuel. "Building a Web Server using Vlang". Section. Archived from the original on 13 March 2023. Retrieved 5 April 2021. https://web.archive.org/web/20230313021526/https://www.section.io/engineering-education/building-web-server-with-vlang ↩
Tsoukalos 2022. - Tsoukalos, Mihalis (May 2022). "Discover the V language". Linux Format Magazine (288). Linux Format. ISSN 1470-4234. https://search.worldcat.org/issn/1470-4234 ↩