2.4k

The V Programming Language

Simple, fast, safe language created for developing Volt, soon available for everyone.

Open source release in June 2019. Early access since April 15.
Install V from source in 0.5 seconds
wget vlang.io/v.c && gcc -o v v.c
Subscribe to development updates
fn main() {
	types := ['game', 'web', 'tools', 'GUI']
	for typ in types {
		println('Hello, $typ developers!')
	}
}	

Fast compilation

V compiles ≈1.5 million lines of code per second per CPU core. (Intel i5-7500 @ 3.40GHz, SM0256L SSD)

Such speed is achieved by direct machine code generation.

wc -l doom3.v     # 458 713
time v doom3.v    # 0.5s *
Compilation speed benchmark

Safety

  • No global state
  • No null
  • No undefined values
  • Option types
  • Generics
  • Immutability by default
  • Partially pure functions
  • C/C++ translation

    V can translate your entire C/C++ project and offer you the safety, simplicity, and up to 200x compilation speed up.
    std::vector<std::string> s;
    s.push_back("V is ");
    s.push_back("awesome");
    std::cout << s.size(); 
    	mut s := []string 
    	s << 'V is '
    	s << 'awesome'
    	println(s.len)

    How does it work?

    Read about translating Doom & Doom 3, LevelDB, SQLite (coming in April).

    400 KB compiler with zero dependencies *

    The entire language and its standard library are less than 400 KB. You can build V in 0.3 seconds.

    For comparison:

    Space requiredBuild time
    Go525 MB1m 33s
    Rust30 GB45m
    gcc8 GB50m
    Clang15-20 GB25m
    Swift70 GB *90m
    V0.4 MB0.3s

    Performance

  • As fast as C
  • Minimal amount of allocations
  • Built-in serialization without reflection
  • Compiles to native binaries without any dependencies: a simple web server is only 65 KB
  • Simple language for building maintainable programs

    You can learn the entire language by going through the documentation in half an hour.

    Despite being simple, it gives a lot of power to the developer. Anything you can do in other languages, you can do in V.

    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 GTK+/Cocoa Drawing, and an OpenGL based graphics library for more complex 2D/3D applications.

    DirectX, Vulkan, and Metal support soon.

    REPL

     v
     >> data := http.get('https://vlang.io/utc_now')? 
     >> data 
     '1551205308' 
    

    Native cross platform UI library

    Build native apps that look native. You no longer need to embed a browser to develop cross platform apps quickly.

    Run everywhere

    V can compile to (human readable) C, so you get the great platform support and optimization of gcc and Clang.

    FAQ

    Why create V when there are already so many languages? Why not use Go, Rust, C++, Python etc?

    Detailed comparison of V and other languages.

    What language is V written in?

    V. The compiler can compile itself. The original version was written in Go.

    Does V use LLVM?

    No. V compiles directly to machine code. It's one of the main reasons it's so light and fast. Right now only x64 architecture/Mach-O format are supported. Once V is open-sourced, other architectures and formats should be implemented relatively quickly.

    V can also emit human readable C, which can then be compiled to run on any platform. This way the compilation speed is about 10 times slower (≈150k lines/second).

    What about optimization?

    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.

    Is there garbage collection?

    No. V manages memory at compilation time (like Rust). Right now only basic cases are handled. For others, manual memory management is required for now. The right approach to solve this will be figured out in the near future.

    Is there going to be a package manager?

    Yes! V is a very modular language and encourages creation of modules that are easy to reuse. There will be a central package manager, and installing modules will be as easy as

    v install sqlite
    What about concurrency?

    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 goroutines and the scheduler will be implemented.

    Can I build V programs without libc?

    Yes!

    Is V going to change a lot before v1.0?

    No. The things you can learn from documentation today are going to stay the same. There will be several new features of course (like goroutines).

    When designing V, I spent a lot of time on research to make sure I won't have to change things in the future.

    Even if something does change, there will be an automatic migration tool.

    The same will be true after v1.0 is released.

    What operating systems are supported?

    Windows, macOS, Linux, *BSD.

    Android and iOS later this year.

    Who's behind V?

    Just me.

    How can it translate C++? It's impossible for one person to write a C++ parser.

    Indeed it is. Luckily I didn't have to write it. I use Clang parser for translating C/C++ to V.

    Why "V"?

    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.

    Under which license is V going to be published?

    MIT.

    Have an unanswered question? Contact me.

    Software built in V

    V

    V itself is written in V.

    Volt

    Native desktop client for Slack, Skype, Matrix, Telegram, Twitch and many more services.

    Filey

    Cross platform file manager with Miller Columns and built-in selective sync with major cloud platforms.

    Vid

    Open source 200 KB editor with the performance of Sublime Text.

    C/C++ to V translator

    This tool supports the latest standard of notoriously complex C++ and allows full automatic conversion to human readable code.

    V ui

    Cross platform widget toolkit using native APIs.

    gitly

    Open-source light and fast alternative to GitHub/GitLab.

    V blog

    Right now it's powered by very basic blogging software, but in the future it will be a full featured light alternative to Discourse.