Simple, fast, safe, compiled. For developing maintainable software.
fn main() {
areas := ['game', 'web', 'tools', 'science', 'systems',
'embedded', 'drivers', 'GUI', 'mobile']
for area in areas {
println('Hello, ${area} developers!')
}
}
The best way to get the latest and greatest V, is to install it from source. It is easy, and it takes only a few seconds:
git clone --depth=1 https://github.com/vlang/v cd v make
You can learn the entire language by going through the documentation over a weekend, and in most cases there's only one way to do something.
This results in simple, readable, and maintainable code.
Despite being simple, V gives a lot of power to the developer and can be used in pretty much every field, including systems programming, webdev, gamedev, GUI, mobile, science, embedded, tooling, etc.
V is very similar to Go. If you know Go, you already know ≈80% of V. Things V improves on Go: vlang.io/compare#go.
V compiles ≈80k (Clang backend) and ≈400k (x64 and tcc backends) lines of code per second.
(Apple M2, no optimization)
V is written in V and compiles itself in under a second (0.33s on MacBook Air M3).
Most of the compiler is still single threaded, so it's going to be 2-3x faster in the future!
V can be bootstrapped in under a second by compiling its code translated to C with a simple
cc v.cNo libraries or dependencies needed.
| Space | Build time | |
| Go | 525 MB | 1m 33s |
| Rust | 30 GB | 45m |
| GCC | 8 GB | 50m |
| Clang | 90 GB [0] | 60m |
| Swift | 70 GB [1] | 90m |
| V | < 20 MB [2] | <1s |
V avoids doing unnecessary allocations in the first place by using value types, string buffers, promoting a simple abstraction-free code style.
There are 4 ways to manage memory in V.
The default is a minimal and a well performing tracing GC.
The second way is autofree, it can be enabled with -autofree. It takes care of most objects (~90-100%):
the compiler inserts necessary free calls automatically during compilation.
Remaining small percentage of objects is freed via GC.
The developer doesn't need to change anything in their code. "It just works",
like in Python, Go, or Java, except there's no heavy GC tracing everything
or expensive RC for each object. Autofree is still experimental and not production ready yet. That's planned for V 1.0.
For developers willing to have more low level control, memory can be managed manually
with -gc none.
Arena allocation is available via v -prealloc.
V can translate your entire C project and offer you the safety, simplicity, and compilation speed-up (via modules).
v translate file.c
std::vector<:string> s;
s.push_back("V is ");
s.push_back("awesome");
std::cout << s.size();
mut s := [] s << 'V is ' s << 'awesome' println(s.len)
A blog post/tutorial about translating DOOM is available.
C++ to V translation is at an early stage.
Translating DOOM from C to V and building it in under a second:
You can read translated code here: github.com/vlang/doom
Get your changes instantly without recompiling.
Since you also don't have to get to the state you are working on after every compilation, this can save a lot of precious minutes of your development time.
Cross-platform drawing library gg, using OpenGL/Metal/DirectX 11 for rendering 2D applications.
There's also a 3D engine in development with the following features already available:
A simple example of the graphics library in action is tetris.v.
For 3D examples, check out this.
Build native UI apps with V UI. You no longer need to embed a browser to develop cross-platform apps quickly.
V has a UI module that uses custom drawing, similar to Qt and Flutter, but with as much similarity to the native GUI toolkit as possible.
It has a declarative API similar to SwiftUI and React Native and runs on Windows, Linux, macOS, and Android.
Coming soon:
To cross compile your software simply run v -os windows or v -os linux. No extra steps required, even for GUI and graphical apps!
(Compiling macOS software only works on macOS for now.)
Building V for Windows using V for macOS, and then testing resulting v.exe on a Windows VM:
To build your project, no matter how big, all you need to do is run
v .
v -cc musl-gcc .v install ui
V can emit (human readable) C, so you get the great platform support and optimization of GCC and Clang. (Use v -prod . to make optimized builds.)
Emitting C will always be an option, even after direct machine code generation matures.
V can call C code, and calling V code is possible in any language that has C interop.
v
>>> import net.http
>>> data := http.get('https://vlang.io/utc_now')!
>>> data.body
1565977541
V can be used as an alternative to Bash to write deployment scripts, build scripts, etc. The advantage of using V for this is the simplicity and predictability of the language, and cross-platform support. "V scripts" run on Unix-like systems as well as on Windows.
for file in ls('build/') {
rm(file)
}
mv('v.exe', 'build/')
v run deploy.vsh
No more arguments about coding styles. There's one official coding style enforced by the vfmt formatter.
All V code bases are guaranteed to use the same style, making it easier to read and change code written by other developers.
v fmt -w hello.v
Build and run your program with
v -profile profile.txt x.v && ./xand you'll get a detailed list for all function calls: number of calls, average time per call, total time per call.
V programs can be translated to JavaScript (WIP):
v -o hello.js hello.v
The JS backend is at an early stage.
They can also be compiled to WASM (for now with Emscripten, but native WASM support is planned). V compiler compiled to WASM and running V programs by translating them to JavaScript:
A game written using V's graphical backend and compiled to WASM:
v2048Use vdoc to get instant documentation generated directly from the module's source code. No need to keep and update separate documentation.
v doc os
Writing tests is very easy: just start your test function with test_
fn get_string() string { return 'hello' }
fn test_get_string() {
assert get_string() == 'hello'
}
Helpful error messages make learning the language and fixing errors simpler:
user.v:8:14: error: `update_user` parameter `user` is mutable, you need to provide `mut`: `update_user(mut user)`
7 | mut user := User{}
8 | update_user(user)
| ~~~~
9 | }
Veb is very fast (built on top of pico.v which has been at the top of TechEmpower benchmark), it compiles into a single binary (html templates are also compiled), supports hot code reloading (the website is automatically updated in the browser once you change any .v/.html file).
github.com/vlang/v/tree/master/vlib/veb
['/post/:id'] fn (b &Blog) show_post(id int) veb.Result { post := b.posts_repo.retrieve(id) or { return veb.not_found() } return veb.view(post) }
Gitly, a light and fast alternative to GitHub/GitLab is built in V and Veb.
import db.sqlite struct Customer { id int name string nr_orders int country string } fn main() { db := sqlite.connect('example.sqlite') or { panic('could not create/find example.sqlite') } nr_customers := sql db { select count from Customer }! println('number of customers: ${nr_customers}') // V syntax can be used to build queries uk_customers := sql db { select from Customer where country == 'uk' && nr_orders > 0 }! for customer in uk_customers { println('${customer.id} - ${customer.name}') } // by adding `limit 1` we tell V that there will be // only one object customer := sql db { select from Customer where id == 1 limit 1 }! println(customer.name) // insert a new customer new_customer := Customer{name: 'Bob', nr_orders: 10} sql db { insert new_customer into Customer }! }
V itself is written in V.
Native desktop client for Slack, Skype, Matrix, Telegram, Twitch and many more services.
A minimalistic open-source OS that can already run Bash, GCC, V, g++, GTK3.
Open-source 1 MB editor with the performance of Sublime Text.
An early stage HTML+CSS renderer which can already render sites like Hacker News 20x faster than Chrome while using 4x less RAM.
An upcoming open source alternative to Discord and Telegram that combines the best features of the two while being ultra fast and light.
A single-file SQL database written in pure V with no dependencies.
Programs equivalent to GNU coreutils, written 100% in V.
This tool can already translate entire original DOOM. C++ support is planned as well. It does full automatic conversion to human readable code.
Cross-platform widget toolkit.
Right now it's very basic forum/blogging software, but in the future it will be a full featured light alternative to Discourse.
The V forum runs on Vorum.
A bot library for Telegram Bot API.
A curated list of awesome V frameworks, libraries and software
An n-dimensional Tensor data structure, sophisticated reduction, elementwise, and accumulation operations, data Structures that can easily be passed to C libraries, powerful linear algebra routines backed by VSL.
A Scientific Library with a great variety of different modules.
Are you using V to build your product or library? Have it added to this list.