The V Programming Language

Simple, fast, safe, compiled language for developing maintainable software github.com/vlang/v 11k
Install V from source in 0.5 seconds
wget vlang.io/v.c && gcc -o v v.c
Install V from source
this will take a couple of seconds
git clone https://github.com/vlang/v
cd v
make
V 0.1.19 Changelog
fn main() {
	areas := ['game', 'web', 'tools', 'science', 'systems',
	          'embedded', 'drivers', 'GUI', 'mobile'] 
	for area in areas {
		println('Hello, $area developers!')
	}
}	


V is an actively developed language at an early stage. Features that are still being worked on are marked with wip
Everything else on this page and the docs has been implemented and open-sourced.

By the time of the V 1.0 release planned for December 2019, there will be no wip's left.

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

  • No null
  • No global variables
  • No undefined values
  • No undefined behavior
  • No variable shadowing
  • Bounds checking
  • Option/Result types
  • Generics
  • Immutable variables by default
  • Pure functions by default
  • Immutable structs by default
  • Performance

  • As fast as C
  • C interop without any costs
  • Minimal amount of allocations
  • Built-in serialization without runtime reflection
  • Compiles to native binaries without any dependencies: a simple web server is only 65 KB
  • 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.15 - 0.6 seconds.

    For comparison:

    Space required   Build time
    Go525 MB1m 33s
    Rust30 GB45m
    GCC8 GB50m
    Clang90 GB [0] 25m
    Swift70 GB [1] 90m
    V< 1 MB0.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/C++ translation

    V can translate your entire C or C++ wip project and offer you the safety, simplicity, and up to 400x 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.

    Almost the entire C standard is supported right now, but C++ translation is at an early stage. The example above works, but more complicated code won't. C++ is a very complex language, hopefully the project will be finished by the end of this year.

     

    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.

    github.com/.../examples/hot_reload

     

    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 also has 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.

    Volt, a 300 KB Slack client built with V and V ui :

    Easy cross compilation

    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:

    Painless deployments and dependency management

    To build you project, no matter how big, all you need to do is run v .

    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 wip

    #v 
    for file in ls('build/') {
    	rm(file) 
    }  
    mv('*.exe', 'build/') 
    
    v run deploy.v 
    	
    Read 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)
    }
    
    

    V forum and V blog are built with vweb/vtalk.

    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)
    

    Sponsors



    Become a sponsor

    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 (≈100k 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. Read more: https://vlang.io/docs#memory.

    Is there a package manager?

    Yes! V is a very modular language and encourages creation of modules that are easy to reuse.

    vpm.vlang.io.

    Submitting your V module takes a couple of seconds.

    Installing modules is 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 coroutines and the scheduler will be implemented.

    Will I be able to build V programs without libc?

    Yes!

    Will I be able to use a custom allocator?

    Yes. This hasn't been implemented yet, but it will be soon after the release in June.

    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 coroutines).

    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, vfmt will take care of it automatically.

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

    When is v1.0 happening?

    The plan is to launch v1.0 by the end of 2019.

    This may sound ambitious, but V is a very small and simple language. Most of it has been figured out already.

    It's very important to give developers certainty and stability, and not to be in beta for years.

    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.

    Clang parser is used for translating C/C++ to V.

    What about editor support?

    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.

    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.

    Any plans to implement macros?

    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.

    Under which license is V published?

    MIT.

    Have an unanswered question? Contact me.

    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 1 MB editor with the performance of Sublime Text.

    C/C++ to V translator

    This tool already supports C and will soon support the latest standard of notoriously complex C++. It does 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.

    vgram

    A bot library for Telegram Bot API.

    Awesome V

    A curated list of awesome V frameworks, libraries and software


    Are you using V to build your product or library? Have it added to this list.