How would you design a new programming language? π€
All programmers eventually fantasize about this question (I do π).
Well, this week I was introduced to Verse. I glimpsed some Rust. I came back to some C#.
Here are some features you should consider in your language π
Verse: Managed effects are indeed a good idea
I listened to the full 4 hours 25 minutes of Tim Sweeney at the Lex Fridman podcast (must listen if you ask me).
There I learned about Verse.
Verse is a new language in development by Epic Games, aiming at the Metaverse π
Epic Games is designing the language from scratch. And indeed it has some features that attract my attention:
- Statically verified: catch runtime problems at compile time
- Strongly typed
- Multi-paradigm (functional programming, object-oriented programming, imperative programming)
- Failure is control flow
- Speculative execution (try out actions without committing them)
- Controlled/Typed effects
If you look close, it gives the same vibes as
effect
in TypeScript π«‘
Here is some Verse code:
decides
: can fail (failure context)transacts
: can be rolled back
IsCriticalHealth(Health : float)<decides><transacts> : void =
((Health > 0.0) && (Health <= 30.0))
Now, the language is still in development and limited to Unreal Editor for Fortnite (UEFN).
But, it's already an interesting experiment, I will definitely keep an eye open for it (and it has to do with games as well ππΌββοΈ).
If you want to know more, they also published a paper describing the design of the language: The Verse Calculus: a Core Calculus for Functional Logic Programming.
The limits/merits of each language
On the topic of languages/libraries, here is the overview of my latest experiment on functional game dev:
- Try to use
Runtime
andScheduler
(fromeffect
) to implement a game loop - Discover that
effect
is more for structured concurrency, not much for synchronous game loops - No more
effect
, but instead doing things in plain TypeScript - Discover Bevy, and try to copy the same ideas in TypeScript
- Stop (pause) it all
TypeScript (and the single-threaded JavaScript model) is not ideal for game dev.
Bevy (Rust) can do all sort of compile-time/parallelism tricks that JavaScript cannot afford. Simple example:
fn greet_people(query: Query<&Name, With<Person>>) {
for name in &query {
println!("hello {}!", name.0);
}
}
Query
is a typed function parameter that narrows the entities passed to the function. This, in TypeScript, is all manual typing work, and not much glory.
Conclusion: why don't just use Bevy at this point?
It's not always necessary to port everything in one single language π
Full control, high complexity
Both @typeonce/ecs and Bevy are based on the ECS model.
If ECS is what matter, why not just use Unity?
An indeed, Unity has its own ECS implementation. It's extensive and powerful. And with great power comes greater complexity:
- Create components (
struct
in C#) - Create entities "authoring" (
GameObject
+ Baking & Bakers π§βπ³) - Create system (
partial struct
) - Create job (for parallel systems execution)
In all of this, you will notice how different C# is from TypeScript, from Rust, and even Verse π€―
Conclusion: don't just stick to one language if you have a wide range of interests (like me). Every new (and old) language evolved around its own needs.
If you have many needs, you need many languages π«
A new article is out: Patterns for state management with actors in React with XState.
IndexedDb
in effect
is nearly here. As well as localfirstconf.
See you next π