Vale has an ambitious goal: to be fast, memory safe, and most importantly, easy. There are a lot of stellar languages that have two, and we suspect it's possible to really maximize all three.
To do this, we're harnessing a new concept called regions.
In Part 1 we saw how we can use pure functions to easily immutably borrow data to make it faster to access.
Part 2 showed us how we could more precisely create regions via isolates, and immutably borrow them too.
The isolates we've seen so far have had complete isolation: no outside data can point to any inside data, and vice versa. This is useful for a lot of things, but there are times when we want inside data to point out.
Luckily, with one-way isolation, we can make data inside the region point to data outside the region.
Here's something similar to the example we saw in Part 2.
This snippet doesn't yet use isolation, we'll show that further below.
There are a couple differences from what we saw in part 2:
In Part 2, we were able to optimize this by making cannon isolated, because it didn't point to anything outside itself, and nothing outside pointed in.
However, Cannon now points to an EnergySource outside itself, so we can't use the isolation we saw in Part 2.
The answer is to use one-way isolation. Here's how!
Even though something inside the Cannon points outside itself, there's still nothing outside that points in.
In this case, we can still make cannon isolated, as long as we tell the compiler which parts of Cannon might point to outside itself.
We still make the changes from Part 2:
But there are a couple extra changes now, in Cannon and fire:
As you can see, we're still able to isolate Cannon and open it immutably, even though it points to something outside its own isolated region.
A lot of real-world code can fit easily with one-way isolation. Most languages have a notion of "private" data, that's not exposed via an object's API. Those objects can be in the object's isolate, yet they can still point outside.
With one-way isolation, we can immutably borrow much more of our programs data a lot more often.
The best thing about one-way isolation is that it's opt-in:
This is consistent with Vale's philosophy of avoiding forced complexity.
This has two extra benefits to the programmer:
In a way, regions and isolation allow us to get the optimization power of borrow checking, with less restrictions and constraints.
As we saw, one-way isolation can allow us to use isolation even for data that points to things outside itself.
Part 4 shows how one object can contain another region's data inline, and Part 5 shows how that combined with one-way isolation can make certain patterns (iterating collections, calculating determinants, etc.) and entire architectures (like entity-component-system) zero-cost. 2
That's all for now! We hope you enjoyed this article. Stay tuned for the next article, which shows how one-way isolation works.
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 bring regions to programmers worldwide.
See you next time!
- Evan Ovadia
If anything isn't clear, feel free to reach out via discord, twitter, or the subreddit! We love answering questions, and it helps us know how to improve our explanations.
We're aiming to complete regions by early 2024, check out the roadmap for more details.
Together, isolates, pure functions, and one-way isolation combine to form something that looks suspiciously like an entire new programming paradigm... whether that's true remains to be seen!
This is still a draft! TODOs:
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: