Caleb Stanford (talk | contribs) →Features: e Tags: Reverted 2017 wikitext editor |
Caleb Stanford (talk | contribs) rm exercism links Tags: Reverted 2017 wikitext editor |
||
Line 64: | Line 64: | ||
=== Performance === |
=== Performance === |
||
At the time of 0.1.24, V was found to be as fast as C.<ref name="auto3">{{cite web |last1=Shóstak |first1=Vic |title=The V programming language |url=https://dev.to/koddr/good-to-know-the-v-programming-language-k5b/ |website=DEV |date=15 January 2020 |access-date=8 November 2021}}</ref><ref>{{cite web |title=C is how old now? - Learning the V programming language |url=https://l-m.dev/cs/learning_v/ |website=l-m |date=10 April 2022 |access-date=10 April 2022}}</ref><ref>{{cite web |title=V language: simple like Go, small binary like Rust|url=https://techracho.bpsinc.jp/hachi8833/2021_03_09/89457/ |website=TechRacho |access-date=3 March 2021 |
At the time of 0.1.24, V was found to be as fast as C.<ref name="auto3">{{cite web |last1=Shóstak |first1=Vic |title=The V programming language |url=https://dev.to/koddr/good-to-know-the-v-programming-language-k5b/ |website=DEV |date=15 January 2020 |access-date=8 November 2021}}</ref><ref>{{cite web |title=C is how old now? - Learning the V programming language |url=https://l-m.dev/cs/learning_v/ |website=l-m |date=10 April 2022 |access-date=10 April 2022}}</ref><ref>{{cite web |title=V language: simple like Go, small binary like Rust|url=https://techracho.bpsinc.jp/hachi8833/2021_03_09/89457/ |website=TechRacho |access-date=3 March 2021}}</ref> |
||
The language also supports a [[foreign function interface]] for interoperability with C.<ref name="analyticsindiamag">{{cite web |first=Ambika |last=Choudhury |title=Meet V, The New Statically Typed Programming Language Inspired By Go & Rust|url=https://analyticsindiamag.com/meet-v-the-new-statistically-typed-programming-language-inspired-by-go-rust|website=Analytics India Magazine (AIM)|access-date=3 July 2019}}</ref><ref>{{cite web |title=How to install the V programming Language on Ubuntu 20.04 / Debian 10? |url=https://www.osradar.com/install-the-v-programming-language-ubuntu-20-04-debian-10 |website=osradar |date=24 June 2020 |access-date=24 June 2020}}</ref><ref name="Grabowski">{{cite web |first=Hank |last=Grabowski |title=Fighting Bloat With the V Language|url=https://www.nequalsonelifestyle.com/2021/06/25/fighting-bloat-with-vlang/|website=nequalsonelifestyle|access-date=25 June 2021 |
The language also supports a [[foreign function interface]] for interoperability with C.<ref name="analyticsindiamag">{{cite web |first=Ambika |last=Choudhury |title=Meet V, The New Statically Typed Programming Language Inspired By Go & Rust|url=https://analyticsindiamag.com/meet-v-the-new-statistically-typed-programming-language-inspired-by-go-rust|website=Analytics India Magazine (AIM)|access-date=3 July 2019}}</ref><ref>{{cite web |title=How to install the V programming Language on Ubuntu 20.04 / Debian 10? |url=https://www.osradar.com/install-the-v-programming-language-ubuntu-20-04-debian-10 |website=osradar |date=24 June 2020 |access-date=24 June 2020}}</ref><ref name="Grabowski">{{cite web |first=Hank |last=Grabowski |title=Fighting Bloat With the V Language|url=https://www.nequalsonelifestyle.com/2021/06/25/fighting-bloat-with-vlang/|website=nequalsonelifestyle|access-date=25 June 2021}}</ref> |
||
Allocations are minimized by the language,<ref>{{cite web |title=The V programming language is now open source |url=https://hub.packtpub.com/the-v-programming-language-is-now-open-sourced-is-it-too-good-to-be-true// |website=Packt Hub |date=24 June 2019 |access-date=24 June 2019}}</ref>{{better source needed|date=November 2023}} |
Allocations are minimized by the language,<ref>{{cite web |title=The V programming language is now open source |url=https://hub.packtpub.com/the-v-programming-language-is-now-open-sourced-is-it-too-good-to-be-true// |website=Packt Hub |date=24 June 2019 |access-date=24 June 2019}}</ref>{{better source needed|date=November 2023}} |
Revision as of 15:19, 4 November 2023
Paradigms | Multi-paradigm: functional, imperative, structured, concurrent |
---|---|
Designed by | Alexander Medvednikov[1] |
First appeared | 20 June 2019[2] |
Stable release | 0.4.2[3]
/ September 30, 2023 |
Typing discipline | static, strong, infered |
Memory management | optional (automatic or manual) |
Implementation language | V |
Platform | x86-64 |
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 as vlang, is a statically typed compiled programming language currently in beta[4] created by Alexander Medvednikov in early 2019.[5] Its creators were inspired by the Go programming language, as well as other influences including C, Rust, and Oberon-2.[6][7][8] It is free and open-source software released under the MIT license.
The goals of V include readability and fast compile time.[9][better source needed][10][11] Some programming ambiguities are eliminated in V; for example, variable shadowing is not allowed; that is, declaring a variable with a name that is already used in a parent scope will cause a compilation error.[12][13][better source needed]
History
According to one of the developers, the new language was created as a result of frustration with existing languages being used for personal projects.[14] Originally the language was intended for personal use, but after it was mentioned publicly and gained interest, it was decided to make it public. V was initially created in order to develop a desktop messaging client known as Volt.[7] The V language was created in order to develop it, along with other software applications such as Ved (also called Vid). As the extension in use was already ".v", to not mess up the git history, it was decided to name it "V".[11] Upon public release, the compiler was written in V, and could compile itself.[15] Along with Alexander Medvednikov, the creator, its community has a large number of contributors from around the world[16][15] who have helped with continually developing and adding to the compiler, language, and modules. Key design goals behind the creation of V: easier to learn and use, higher readability, fast compilation, increased safety, efficient development, cross-platform usability, improved C interop, better error handling, modern features, and more maintainable software.[11][17][18][19]
Features
Performance
At the time of 0.1.24, V was found to be as fast as C.[20][21][22] The language also supports a foreign function interface for interoperability with C.[23][24][25]
Allocations are minimized by the language,[26][better source needed] which also supports serialization without runtime reflection[20]. Native binaries compiled with no dependencies[8][27]
Compilation time
The V compiler is written in itself. As of January 2022, the compiler was about 1 MB and could compile an unspecified 1 million lines of code in less than a second, according to a blog post.[28][15][better source needed]
Source code translators
V supports a Source-to-source compiler (transpiler) from C.[12][29][19]
Working translators are also under development for Go, JavaScript, and WASM.[30][31]
Syntax
Hello world
fn main() {
println('hello world')
}
Structs
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 == 10
Heap structs
Structs are allocated on the stack. To allocate a struct on the heap and get a reference to it, use the & prefix:
struct Point {
x int
y int
}
p := &Point{10, 10}
// References have the same syntax for accessing fields
println(p.x)
Methods
V doesn't have classes, but you can define methods to types. A method is a function with a special 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.
In this example, 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.
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.
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)
References
- ^ "Creator of V". GitHub.
- ^ "First public release". GitHub. 20 June 2019.
- ^ "Latest releases". GitHub.
- ^ "The V Programming Language". vlang.io. Retrieved 4 November 2023.
- ^ "Getting Started with V Programming". subscription.packtpub.com. Retrieved 1 November 2023.
- ^ Lewkowicz, Jakub (25 June 2019). "SD Times news digest: V language now open sourced". SD Times. Retrieved 25 June 2019.
- ^ a b James, Ben (23 July 2019). "The V Programming Language: Vain Or Virtuous?". Hackaday. Retrieved 23 July 2019.
- ^ a b Umoren, Samuel. "Building a Web Server using Vlang". Section. Retrieved 5 April 2021.
- ^ Knott, Simon (27 June 2019). "An introduction to V". Retrieved 27 June 2019.
- ^ Cheng, Jeremy. "VLang for Automation Scripting". Level Up Coding. Retrieved 27 December 2020.
- ^ a b c Jonah, Victor (25 February 2021). "What is Vlang? An introduction". LogRocket. Retrieved 25 February 2021.
- ^ a b "Introducing the V Tutorial!". Replit. Retrieved 4 January 2021.
- ^ Galuh, Rosa (8 August 2022). "A Brief Introduction to the V Language". MUO. Retrieved 8 August 2022.
- ^ "How To Maintain And Iterate With V - SYNCS 2023 (Sydney Computing Society at the University of Sydney)". YouTube. Retrieved 18 October 2023.
- ^ a b c Rao 2021.
- ^ "Contributors" – via OSS.
- ^ Independent Laboratory 2020.
- ^ Lyons 2022.
- ^ a b Nasufi, Erdet. "An introduction to V - the vlang". DebConf. Retrieved 24 July 2022.
- ^ a b Shóstak, Vic (15 January 2020). "The V programming language". DEV. Retrieved 8 November 2021.
- ^ "C is how old now? - Learning the V programming language". l-m. 10 April 2022. Retrieved 10 April 2022.
- ^ "V language: simple like Go, small binary like Rust". TechRacho. Retrieved 3 March 2021.
- ^ Choudhury, Ambika. "Meet V, The New Statically Typed Programming Language Inspired By Go & Rust". Analytics India Magazine (AIM). Retrieved 3 July 2019.
- ^ "How to install the V programming Language on Ubuntu 20.04 / Debian 10?". osradar. 24 June 2020. Retrieved 24 June 2020.
- ^ Grabowski, Hank. "Fighting Bloat With the V Language". nequalsonelifestyle. Retrieved 25 June 2021.
- ^ "The V programming language is now open source". Packt Hub. 24 June 2019. Retrieved 24 June 2019.
- ^ Dr. Rangarajan Krishnamoorthy. "Building V Language DLL". rangakrish. Retrieved 2 April 2023.
- ^ Oliveira, Marcos (18 January 2022). "V , the programming language that is making a lot of success". Terminal Root. Retrieved 18 January 2022.
- ^ 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.
- ^ "Convert Go to V with go2v". Zenn. 26 January 2023. Retrieved 26 January 2023.
- ^ "The V WebAssembly Compiler Backend". l-m. 26 February 2023. Retrieved 26 February 2023.
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.
{{cite book}}
: CS1 maint: date and year (link) - Lyons, Dakota "Kai" (13 April 2022). Beginning with V Programming. Independently Published. ISBN 979-8801499963.
{{cite book}}
: CS1 maint: date and year (link) - Tsoukalos, Mihalis (May 2022). "Discover the V language". Linux Format Magazine (288). ISSN 1470-4234.