2023-08-29 18:42:07
A simple language for building programs that are easy to maintain. You can learn the whole language by browsing the documentation over a weekend, and in most cases there’s only one way to do something. The result is a code that is simple, readable and easy to maintain.
Despite its simplicity, V gives a lot of power to the developer and can be used in virtually any field including systems programming, web development, game development, GUI, mobile, science, board, tools, etc. V is very similar to Go. If you know Go, you already know ≈80% of V. What V improves over Go.
Security
Boundary checkingNo undefined valuesNo variable shadingImmutable variables by defaultImmutable structures by defaultOption/result and mandatory error checksSum typesGenericImmutable function argument by default, mutable argues must be marked when callingNo null (allowed in the insecure code) No undefined behavior (eg wip, overflow can still result in UB) No global variables (can be enabled for low level applications like kernels via a flag)
Performance
Cost-free C interoperabilityMinimum allocationsBuilt-in serialization with no runtime reflectionCompiles to native binaries without any dependencies: a simple web server weighs only around 250KBAs fast as C (the main V backend compiles to readable C by man), with an equivalent code.
V introduces some overloads for security (like array bounds checking, free GC), but these features can be disabled or bypassed when performance is more important.
Quick compilation
V compiles ≈110,000 (Clang backend) and ≈500,000 (x64 and tcc backends) lines of code per second.
(Intel i5-7500, SM0256L SSD, no optimization)
V is written in V and compiles in less than a second. Most of the compiler is still single-threaded, so it will be 2-3 times faster in the future!
Small and easy to build compiler
V can be started in less than a second by compiling its translated C code with a simple cc vc command No libraries or dependencies needed.
For comparison, the space and time needed to build each compiler:
Build V in 0.3 seconds and use the resulting binary to rebuild itself:
Flexible memory management
V avoids unnecessary allocations by using value types, string buffers, and favoring a simple, non-abstracting code style.
There are 4 ways to manage memory in V.
The default method is a minimal, high-performance GC.
The second method is autofree, it can be enabled with -autofree. It takes care of most objects (~90-100%): the compiler inserts the necessary release calls automatically during compilation. The remaining small percentage of items are released by the GC. The developer does not need to change anything in his code. It just works, just like in Python, Go, or Java, except there’s no heavyweight GC that traces everything or expensive RC for every object.
For developers wanting lower control, memory can be managed manually with -gc none.
Arena allocation is available via v -prealloc.
V’s autofree demo. All objects are freed during compilation. Running the Ved editor on an 8MB file with 0 leaks:
Run everywhere
V can produce C (human readable), so you get GCC and Clang support and optimization. (Use v -prod . to do optimized builds). Emitting C will always be an option, even following direct machine code generation has matured.
V can call C code, and calling V code is possible in any language that has interoperability with C.
Source : Vlang
And you ?
What is your opinion on this new programming language?
See as well :
Crumb: A new programming language where there are no keywords and everything is a function
The V programming language (Vlang) is now available in version 0.2 and emphasizes stability and memory management at compile time
The V programming language has just been released as open source and does not seem to live up to all its promises
1693336052
#simple #fast #secure #compiled #developing #maintainable #software #creator