Safety
- Bounds checking
- No undefined values +
- No undefined behavior
- No variable shadowing
- Immutable variables by default
- Immutable structs by default @@ -431,51 +383,72 @@
- Generics
- Immutable function args by default, mutable args have to be marked on call
- No null (allowed in unsafe code) -
- No undefined behavior (wip, e.g. overflowing can still result in UB) -
- No global variables (can be enabled for low level apps like kernels via a flag) +
- No global variables (can be enabled for low level applications like kernels via a command line flag)
Safety
Painless deployments and dependency management
++ To build your project, no matter how big, all you need to do is run +
+v . +
+ No 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 via vpm, a centralized package manager written in V, is as simple as +
+v install ui ++ +
Run everywhere
+
+ 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.
+
REPL
+v
+>>> import net.http
+>>> data := http.get('https://vlang.io/utc_now')?
+>>> data.text
+1565977541
+ Cross-platform shell scripts in V
++ V can be used as an alternative to Bash to write deployment scripts, build scripts, etc. -
Partners & Sponsors
-Performance
-
+
- As fast as C (V's main backend compiles to human readable 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 about 250 KB -
- As fast as C (V's main backend compiles to human readable C),
- with equivalent code.
-
V does introduce some overhead for safety (such as array bounds checking, GC free), but these features can be disabled/bypassed when performance is more important. -
+ - Compiles to native binaries without any dependencies: a simple web server is only 65 KB
Fast compilation
Small and easy to build compiler
+Small and easy to build compiler
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.
- For comparison, space and time required to build each compiler: + For comparison, space and time required to build each compiler. The lines show the amount of time that it takes to build:
| 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 | < 10 MB [2] - | <1s | 1s | +
Building V in 0.3 seconds and then using the resulting binary to build itself again:
@@ -533,36 +506,22 @@ Small and easy to build compiler
-- Try it yourself: -
-
- wget https://github.com/vlang/v/releases/latest/download/v_linux.zip
- unzip v_linux && cd v
- time ./v self
-
Flexible memory management
+Innovative and flexible memory management
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. -
+ Right now allocations are handled by a minimal and well performing GC until V's autofree engine is production ready.- 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%):
+ Autofree 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",
@@ -588,7 +547,7 @@
Flexible memory management
V's autofree demo. All objects are freed during compilation. Running the Ved editor on an 8 MB file with 0 leaks:
@@ -604,7 +563,7 @@Flexible memory management
C translation
V can translate your entire C project and offer you the safety, simplicity, and compilation speed-up (via modules).
C translation
C++ to V translation is at an early stage.Translating DOOM from C to V and building it in under a second:
@@ -639,7 +598,7 @@C translation
Hot code reloading
Get your changes instantly without recompiling. @@ -648,126 +607,69 @@
Hot code reloading
github.com/.../examples/hot_reloadA powerful graphics library
+Powerful graphics libraries
- Cross-platform drawing library, using OpenGL/Metal/DirectX 11 for rendering 2D/3D applications. -
- The following features are planned: + 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
- Camera (moving, looking around)
- Skeletal animation
DirectX, Vulkan, and Metal support is planned.
A simple example of the graphics library in action is tetris.v.
-For 3D examples, check out this.
+
Light and fast cross-platform GUI library
+Native cross-platform GUI library
- 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. -
-
+ 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 support +
- 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: + 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!
+ 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 your project, no matter how big, all you need to do is run -
-v . -
- No 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 via vpm, a centralized package manager written in V, is as simple as -
-v install ui -- -
Run everywhere
-
- 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.
-
REPL
-v
->>> import net.http
->>> data := http.get('https://vlang.io/utc_now')?
->>> data.text
-1565977541
- Cross-platform shell scripts in V
-- 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
-
- Friendly error messages
Powerful built-in web framework Vweb
-Vweb is very fast, 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/vweb
+Powerful built-in web framework
+A simple yet powerful web server with built-in routing, parameter handling, templating, and other features.
+['/post/:id'] ++['/post/:id'] fn (b Blog) show_post(id int) vweb.Result { post := b.posts_repo.retrieve(id) or { return vweb.not_found() @@ -877,7 +779,6 @@-Powerful built-in web framework Vweb
} return vweb.view(post) } -Gitly, a light and fast alternative to GitHub/GitLab is built in V and vweb.
Gitly, a light and fast alternative to GitHub/GitLab is built in V and vweb.
+
+Built-in ORM
-+
Built-in ORM
+-
import db.sqlite ++println(customer.name) + +// insert a new customer +new_customer := Customer{name: 'Bob', nr_orders: 10} +sql db { +insert new_customer into Customer +} +} +import sqlite struct Customer { - id int - name string - nr_orders int - country string +id int +name string +nr_orders int +country string } fn main() { - db := sqlite.connect('example.sqlite') or { - panic('could not create/find example.sqlite') - } +db := sqlite.connect('example.sqlite') or { +panic('could not create/find example.sqlite') +} - nr_customers := sql db { - select count from Customer - }! - println('number of all customers: ${nr_customers}') +nr_customers := sql db { +select count from Customer +} +println('number of all customers: $nr_customers') - // V syntax can be used to build queries - uk_customers := sql db { - select from Customer where country == 'uk' && nr_orders > 0 - }! +// 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}') - } +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 - }! +// 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 } --
Built in V
+Built in V
V
@@ -1021,7 +988,7 @@Filey
Filey
A curated list of awesome V frameworks, libraries and software
The V Tensor Library
-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. -
-The V Scientific Library -
-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.
@@ -1061,7 +1016,7 @@Filey
logo by Sonovice and Don.
diff --git a/preview.html b/preview.html
index 1984fe076..ccc840369 100644
--- a/preview.html
+++ b/preview.html
@@ -10,7 +10,7 @@
- The V Programming Language 0.3
-Simple, fast, safe, compiled. For developing maintainable software.
- +
Programming Language
+ “simple, fast, safe, compiled language for developing maintainable software”
+The V Programming Language 0.3
- +V version: 0.3x beta
+ -fn main() {
- areas := ['game', 'web', 'tools', 'science', 'systems',
- 'embedded', 'drivers', 'GUI', 'mobile']
- for area in areas {
- println('Hello, $area developers!')
- }
+ fn main() {
+ areas := ['game', 'web', 'tools', 'science', 'systems',
+ 'embedded', 'drivers', 'GUI', 'mobile']
+ for area in areas {
+ println('Hello, $area developers!')
+ }
}
- The V Programming Language 0.3
function update_ex() { var elems = document.querySelectorAll('.hello_devs'); - for (var index = 0 ; index < elems.length; index++) { + for (var index = 0 ; index < elems.length; index++) { - elems[index].style.display = 'none'; - } + elems[index].style.display = 'none'; + } document.getElementById('ex' + ex_id).style.display = 'table-cell'; if (ex_id <= 3) { document.getElementById('ex' + ex_id).style.fontSize = '100%'; @@ -341,85 +403,91 @@The V Programming Language 0.3
function tokenize_codeblock_99404097 (e) { - Tokenizer(e.target.value).then(function(tokens) { - document.getElementById("codeblock_hl_04227451").innerHTML = tokens - .map(function(token) { return `${token.value}` }) - .join('') - }) + Tokenizer(e.target.value).then(function(tokens) { + document.getElementById("codeblock_hl_04227451").innerHTML = tokens + .map(function(token) { return `${token.value}` }) + .join('') + }) } document.getElementById("codeblock_ta_39322469").oninput = tokenize_codeblock_99404097 tokenize_codeblock_99404097({target:{value: document.getElementById("codeblock_ta_39322469").value}}) document.getElementById("codeblock_rb_13318017").onauxclick = function(e) { - localStorage.setItem('sandbox-code', document.getElementById("codeblock_ta_39322469").value) + localStorage.setItem('sandbox-code', document.getElementById("codeblock_ta_39322469").value) } document.getElementById("codeblock_rb_13318017").onclick = function(e) { - if (location.pathname === 'https://v-wasm.vercel.app') e.preventDefault() - var codeblock_value = document.getElementById("codeblock_ta_39322469").value - localStorage.setItem('sandbox-code', codeblock_value) + if (location.pathname === 'https://v-wasm.vercel.app') e.preventDefault() + var codeblock_value = document.getElementById("codeblock_ta_39322469").value + localStorage.setItem('sandbox-code', codeblock_value) }-
Latest news
+ +
Why V?
+Safety
Painless deployments and dependency management
++ To build your project, no matter how big, all you need to do is run +
+v . +
+ No 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 via vpm, a centralized package manager written in V, is as simple as +
+v install ui ++ +
Run everywhere
+
+ 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.
+
Sponsors
-
-
-
-
-
-
- REPL
+v
+>>> import net.http
+>>> data := http.get('https://vlang.io/utc_now')?
+>>> data.text
+1565977541
+ Cross-platform shell scripts in V
++ 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
+
Fast compilation
Small and easy to build compiler
+Small and easy to build compiler
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.
- For comparison, space and time required to build each compiler: + For comparison, space and time required to build each compiler. The lines show the amount of time that it takes to build:
| 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 | < 10 MB [2] - | <1s | 1s | +
Building V in 0.3 seconds and then using the resulting binary to build itself again:
@@ -552,7 +648,7 @@ Small and easy to build compiler
Innovative and flexible memory management
V avoids doing unnecessary allocations in the first place @@ -587,7 +683,7 @@
Innovative and flexible memory management
V's autofree demo. All objects are freed during compilation. Running the Ved editor on an 8 MB file with 0 leaks:
@@ -603,7 +699,7 @@Innovative and flexible memory management
C translation
V can translate your entire C project and offer you the safety, simplicity, and compilation speed-up (via modules).
C translation
C++ to V translation is at an early stage.Translating DOOM from C to V and building it in under a second:
@@ -638,7 +734,7 @@C translation
Hot code reloading
Get your changes instantly without recompiling. @@ -647,13 +743,13 @@
Hot code reloading
github.com/.../examples/hot_reloadPowerful 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: @@ -666,13 +762,13 @@
Powerful graphics libraries
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.
@@ -686,81 +782,30 @@
Native cross-platform GUI library
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 your project, no matter how big, all you need to do is run -
-v . -
- No 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 via vpm, a centralized package manager written in V, is as simple as -
-v install ui -- -
Run everywhere
-
- 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.
-
REPL
-v
->>> import net.http
->>> data := http.get('https://vlang.io/utc_now')?
->>> data.text
-1565977541
- Cross-platform shell scripts in V
-- 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
-
- Friendly error messages
Powerful built-in web framework
-github.com/vlang/v/tree/master/vlib/vweb
+A simple yet powerful web server with built-in routing, parameter handling, templating, and other features.
+['/post/:id'] ++['/post/:id'] fn (b Blog) show_post(id int) vweb.Result { post := b.posts_repo.retrieve(id) or { return vweb.not_found() @@ -869,7 +915,6 @@-Powerful built-in web framework
} return vweb.view(post) } -Gitly, a light and fast alternative to GitHub/GitLab is built in V and vweb.
Gitly, a light and fast alternative to GitHub/GitLab is built in V and vweb.
+
+Built-in ORM
-+
Built-in ORM
+-
import sqlite +- + +import sqlite struct Customer { - id int - name string - nr_orders int - country string +id int +name string +nr_orders int +country string } fn main() { - db := sqlite.connect('example.sqlite') or { - panic('could not create/find example.sqlite') - } +db := sqlite.connect('example.sqlite') or { +panic('could not create/find example.sqlite') +} - nr_customers := sql db { - select count from Customer - } - println('number of all customers: $nr_customers') +nr_customers := sql db { +select count from Customer +} +println('number of all customers: $nr_customers') - // V syntax can be used to build queries - uk_customers := sql db { - select from Customer where country == 'uk' && nr_orders > 0 - } +// 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') - } +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) +// 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 - } +// insert a new customer +new_customer := Customer{name: 'Bob', nr_orders: 10} +sql db { +insert new_customer into Customer +} }
Built in V
+Built in V
V
@@ -1082,12 +1152,12 @@Filey
logo by Sonovice and Don.


-