The V Programming Language

wget vlang.io/v.c && gcc -o v v.c

fn main() { areas := ['game' ,'web' ,'tools' ,'science' ,'systems' ,'embedded' ,'drivers' ,'GUI' ,'mobile' ]for areain areas { println('Hello, $areadevelopers!' ) } }

V is an actively developed language at an early stage. It will stabilize by the time of the 0.2 release planned for early December 2019.
Simple language for building maintainable programs
You can learn the entire language by going through the documentation in half an hour, 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. Anything you can do in other languages, you can do in V.
Safety
Performance
Fast compilation
V compiles between ≈100k and 1.2 million lines of code per second per CPU core. (Intel i5-7500 @ 3.40GHz, SM0256L SSD, no optimization)V compiles itself in 0.15 - 0.6 seconds.
Small and easy to build compiler
The entire language and its standard library are less than 1 MB. V is written in V, and can be built in 0.09 - 0.6 seconds.
For comparison:
Space required | Build time | |
Go | 525 MB | 1m 33s |
Rust | 30 GB | 45m |
GCC | 8 GB | 50m |
Clang | 90 GB [0] | 25m |
Swift | 70 GB [1] | 90m |
V | < 1 MB | 0.15s - 0.6s |
V has only one dependency: a C compiler. If you are doing development, most likely you already have a C compiler installed.
It's a small dependency, and it's not going to be needed once x64 generation is mature enough.
Building V in 0.4 seconds and then using the resulting binary to build itself again:
C translation
V can translate your entire C wip project and offer you the safety, simplicity, and 10-25x compilation speed-up.std::vector<std::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 about translating DOOM will be published soon.
C++ to V translation is at an early stage.
Translating DOOM from C to V and building it in 0.7 seconds (x25 speed-up): wip

You can follow the progress and read translated code here: github.com/vlang/doom
Hot code reloading
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.
Powerful graphics libraries
Cross-platform drawing library built on top of GDI+/Cocoa Drawing, and an OpenGL based graphics library for more complex 2D/3D applications, that will also have the following features:- Loading complex 3D objects with textures wip
- Camera (moving, looking around) wip
- Skeletal animation wip
DirectX, Vulkan, and Metal support is planned.
A simple example of the graphics library in action is tetris.v.

Native cross-platform GUI library
Build native apps with native controls. You no longer need to embed a browser to develop cross-platform apps quickly.
V has a ui
module that uses native GUI toolkits: WinAPI/GDI+ on Windows, Cocoa on macOS.
On Linux custom drawing is used.
Coming soon:
- a Delphi-like visual editor for building native GUI apps
- iOS/Android support with native controls
- a declarative API similar to SwiftUI and React Native.
Easy cross compilation
To cross compile your software simply runv -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:
Painless deployments and dependency management
To build you project, no matter how big, all you need to do is runv .
No more build environments, makefiles, headers, virtual environments, etc.
You get a single statically linked binary that is guaranteed to work on all operating systems (provided you cross compile) without any dependencies. *
Installing new libraries is as simple as v install sqlite
.
Run everywhere
V can emit (human readable) C, so you get the great platform support and optimization of GCC and Clang.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.
REPL
v >>> import http >>> data := http.get('https://vlang.io/utc_now') or { panic(err) } >>> data.text 1565977541
V Script
for file in ls('build/') { rm(file) } mv('v.exe', 'build/') v run deploy.vshRead more about V script
Powerful built-in web framework
github.com/vlang/v/tree/master/vlib/vweb['/post/:id'] fn (b Blog) show_post(id int) vweb.Result { post := b.posts_repo.retrieve(id)or {return vweb.not_found() }return vweb.view(post) }
Built-in ORM
struct Customer { id int name string nr_orders int country string } db := pg.connect(db_name, db_user) nr_customers := db.select count from Customer println('number of all customers: $nr_customers')// V syntax can be used to build queries uk_customers = 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 = db.select from Customer where id == 1 limit 1 println(customer.name)// insert a new customer new_customer := Customer{name: 'Bob', nr_orders: 10} db.insert(new_customer)
FAQ
V. The compiler can compile itself. The original version was written in Go.
No. V uses C as its backend and will compile directly to machine code by the time of the 1.0 release.
For now V emits C and uses GCC/Clang for optimized production builds. This way you get access to sophisticated optimization.
Such builds are compiled ≈150 times slower than V development builds (but are still an order of magnitude faster than C++ production builds).
This can be a problem for industries where optimization is required during development (for example AAA games). In this case, hot code reloading can be used.
In the future V will have its own optimizer.
No. V manages memory at compilation, like Rust:
vlang.io/docs#memory
Yes! V is a very modular language and encourages creation of modules that are easy to reuse.
Submitting your V module takes a couple of seconds.
Installing modules is as easy as
v install sqlite
It's going to be the same as in Go. To run foo()
concurrently, just call it with
go foo()
. Right now it launches the function in a new system thread. Soon coroutines and
the scheduler will be implemented.
Yes! Simply run with -bare
to exclude libc and vlib. See an example here.
Yes. This hasn't been implemented yet.
Right now V is under heavy development, lots of things change.
A stable 0.2 version will be released in early December 2019.
1.0 is going to have forward compatibility, meaning that V 1.0 programs will continue to compile and run without change.
It's very important to give developers certainty and stability, and not to be in beta for years. This means that we need to be careful with the 1.0 release. It's going to happen in early 2020.
Windows, macOS, Linux, FreeBSD, OpenBSD, NetBSD, DragonflyBSD, Solaris, Android (Termux).
Android and iOS later this year.
Clang parser is used for translating C/C++ to V.
There are basic plugins for VS Code and Vim. Also check out the Vid editor, which is written in V. It has V support built in.
Plugins for Emacs, and other popular editors will be available soon.
V is a small and simple language, it doesn't need a powerful IDE.
Initially the language had the same name as the product it was created for: Volt. The extension was ".v", I didn't want to mess up git history, so I decided to name it V :)
It's a simple name that reflects the simplicity of the language, and it's easy to pronounce for everyone in the world.
Please note that the name of the language is "V", not "Vlang" or "V-Lang" etc.
The name is not very searchable (like Go), so use #vlang on Twitter, vlang on Google etc.
No, sorry. Macros can be really useful, but they complicate the code significantly. Every company, team, developer can extend the language, and it's no longer possible to jump into a new codebase and immediately understand what's going on.
V will have sophisticated code generation.
MIT.