Version 0.2 is now out of beta, and officially released!
As we all know, Vale is a programming language that aims to be fast, safe, and easy to use. It's a challenging goal, and version 0.2 lays a solid foundation for the next steps in the endeavor.
This version has been prioritizing ease of use, enabling much larger Vale projects. We can now comfortably create large programs such as this roguelike game. With this version, Vale has graduated from a prototype to early alpha status.
You can find the version 0.2 binaries here.
Below are the new features in 0.2, enjoy!
This release enables Higher RAII, a form of linear typing that helps the compiler enforce that we "never forget to call that function".
For a real-world use case, check out the recent article Higher RAII, the pattern that saved me a vital 5 hours in the 7DRL Challenge.
To use Higher RAII, just add a #!DeriveStructDrop above your struct or #!DeriveInterfaceDrop above your interface, to prevent it from automatically defining a drop function (the ! means "don't").
Instead of having an implicitly-called drop function, this example has a destroyShip function that takes a boolean parameter and returns an integer.
Since there is no drop function for the struct, Vale will never automatically destroy the object. The user must explicitly call the destroyShip function.
This pattern can be used to enforce that we don't forget to call a certain function (like destroyShip) at some point in the future.
We're particularly excited to prototype the region borrow checker, which could help Vale approach C++'s speed by getting rid of the vast majority of our memory safety overhead, and enable concurrency features like described in Seamless, Fearless, Structured Concurrency.
We've been looking forward to this version for a long time!
Type-state programming is a way to use the compiler to ensure that specific functions are only callable when the object is in a certain state. This is all tracked via the type system, with zero run-time overhead.
Vale now supports concept functions, a way to specify that certain functions must exist for given generic parameters, without making them implement any traits.
For example, List's clone function can require that there exists a clone function for its elements:
This is often much easier than what we normally see in mainstream languages, which is to require an explicit implementation for the type.
Read more at Concept Functions!
We're happy to announce that Vale now has "const generics", where generic parameters can contain not only types (like the T in List<T>) but also integers, booleans, and other types.
Now, instead of repeating classes...
...we can have one:
We also now have the compile-time spread operator .. for structs, which enabled us to implement tuples in the standard library, instead of in the compiler.
We have some interesting things planned for const generics, see Const Generics and the Compile-Time Spread Operator for more!
The 0.2 release removes the let and let mut keywords, making our syntax cleaner and more readable.
Read more at On Removing Let and Let Mut!
This version of the compiler is 3x as fast as the previous version, after we did some optimizations:
We also updated to LLVM 13 under the hood.
Vale has a new take on modules, which is as easy to use as Java's packages while providing the flexibility of Rust's crates.
Check out the Modules Guide to see them!
We make heavy use of our module system in our new standard library, too.
We can now downcast interfaces to a specified struct, using the as function.
In this example, we're downcasting a Ship interface reference to a FireflyShip struct reference.
Downcasting will always return a Result<T, E> where T is the struct type, and E is the interface type. In this example, it returns a Result<FireflyShip, Ship>.
It will either be an Ok containing a FireflyShip, or if the ship wasn't actually a FireflyShip it will contain an Err with the original Ship.
Here, we're calling .expect() because we know it is indeed a FireflyShip.
Vale now supports foreach loops, and the break statement as well.
See the Collections Guide for more!
When we use the exported keyword on a function, Vale will generate headers so that C can call that function. We can also call C functions by declaring an extern function.
See Externs and Exports in the guide for more!
Here, main is calling out into an external C function that reads an int from the keyboard.
The extern func readInt() int; is telling Vale that the C code will declare a function named readInt.
Vale's approach to FFI is unusual. Vale regards its own objects as in a separate "region" of memory than C's objects, and doesn't directly expose Vale objects to C. 2
This separation enables some pretty interesting upcoming features. "Fearless FFI" will allow us to be certain we're not accidentally corrupting our Vale objects from C. "Perfect Replayability" will then rely on that memory-safety and determinism to allow us to easily reproduce any bug from a previous run. 3
Now that we have a usable and solid language to build on, version 0.3 will be focused on prototyping our flagship feature, the region borrow checker.
Also keep an eye out for our next series of articles, which paint a more holistic picture of how Vale will combine generational references, "life cells", and the region borrow checker to provide maximum speed, memory safety, while still remaining easy to use.
Here's to a great year, and a great version!
Thanks for reading, we hope you enjoyed this article! And if you're impressed with our track record and believe in the direction we're heading, please consider sponsoring us on github:
With your support, we can work on this full-time, and bring speed and safety to more programmers than ever before!
This may be relaxed in the future, using unsafe blocks.
Stay tuned for the next two articles, on Fearless FFI and Perfect Replayability. If you want early access, feel free to swing by the discord server and ask!
Vale aims to bring a new way of programming into the world that offers speed, safety, and ease of use.
The world needs something like this! Currently, most programming language work is in:
These are useful, but there is a vast field of possibilities in between, waiting to be explored!
Our aim is to explore that space, discover what it has to offer, and make speed and safety easier than ever before.
In this quest, we've discovered and implemented a lot of new techniques:
These techniques have also opened up some new emergent possibilities, which we hope to implement:
We also gain a lot of inspiration from other languages, and are finding new ways to combine their techniques:
...plus a lot more interesting ideas to explore!
The Vale programming language is a novel combination of ideas from the research world and original innovations. Our goal is to publish our techniques, even the ones that couldn't fit in Vale, so that the world as a whole can benefit from our work here, not just those who use Vale.
Our medium-term goals:
We aim to publish articles biweekly on all of these topics, and create and inspire the next generation of fast, safe, and easy programming languages.
If you want to support our work, please consider sponsoring us on GitHub!
With enough sponsorship, we can: