Vale was created to be the first fast, safe, and easy programming language.
Generally, languages today have one or two, but not all three.
This article will dive into the details and compare these languages' designs!
Easy | Safe | Fast | |
---|---|---|---|
C++ | No | No | Yes |
Javascript | Yes | Yes | No |
Rust | No | Mostly | Yes |
Vale | Yes | Yes | Yes |
This article is meant to explain our vision for Vale, so will reference a lot of the final designs. We'll make it clear when we're talking about the current implementation versus what we have planned.
We hope to have all of these completed and benchmarked by late 2023. We're grateful for your interest and support as we create all this!
We picked these three languages because they're our favorites in some way:
This post is not meant to criticize, just an honest comparison. Also note that these are only opinions, and not objective truths!
(I hope this isn't quoted on PCJ!)
It's fun to push the borrow checker's boundaries, especially when traits and closures are involved!
Vale aims to be safe and fast while also remaining easy.
To get a sense of what easy means:
Vale is 100% safe, which removes most of C++'s difficulties.
Vale's "region borrow checker" doesn't impose the mutability-xor-aliasability restriction on every object, which is the source of Rust's difficulties.
Vale also has some innovations to make parallelism and concurrency easier:
Vale does make a few concessions here:
In the end, Vale is almost as easy as Javascript, and much easier than Rust and C++.
This principle is called "gradual complexity." Other languages that do this well are C#, Swift, and Go.
Vale is 100% memory-safe and data-race-safe, like Javascript, and safer than Rust and C++.
Vale plans to have a memory-safe unsafe block, as odd as that sounds; it will use the region borrow checker to keep the safe region's data separate from the unsafe region's data, and allowing safe communication between them.
Vale's "check override" operator !! is disabled by default, and can be enabled on a per-module basis.
Specifically, Javascript can use FFI into other languages with webassembly, but it doesn't share memory with them, it only sends immutable values back and forth.
This stands for Foreign Function Interface, and refers to how Rust can call into C code.
Vale aims to be as fast as Rust and C++ in the average case, and much faster than Javascript.
It is of course impossible to match C++'s speed in theory. However, for the majority of programs, Vale could approach it, and sometimes even surpass it.
Basically, we start with Generational References, and then remove the vast majority of the generation checks by using:
By our estimation, a surprisingly high percentage of functions drop to zero memory-safety overhead when we use these three techniques together as in this snippet, and we estimate the remaining generation checks are only about as common as the extra bounds checking that Rust does compared to other languages.
Additionally, Vale aims to make fast patterns much more accessible than C++ does, by:
If we can make it easier to use these performance techniques, then people will use them more, and their programs will be faster in practice.
In summary, while no language can be faster than C++'s speed in theory, the average Vale program might be much faster in practice.
On top of all that, if there's still a generation check in critical code and someone needs an extra sliver of speed, they can use the check override operator to elide that check in release mode.
Vale, C++, Rust, and JS have different strengths which makes them excel in different use cases.
Compared to Vale:
Vale's combination of speed, safety, and ease are universally useful, but it will particularly shine for:
We hope you enjoyed this article, and as always, feel free to tweet us, leave any comments in the r/vale subreddit, or swing by our discord server!
The borrow checker influences our programs to put more objects into centralized Vecs and HashMaps, which incur more bounds checking and hashing costs than other languages would in the same situation.