by throwawayboise · 5y ago · 0 comments
> All processes running on Lunatic are preemptively scheduled and executed by a work stealing async executor.
Sounds like Erlang to me.
Erlang is special for other reasons.
Some things that would make it more like Erlang than Go (but that I won't bother to verify):
1. Go isn't really pre-emptive, it just has a lot of hidden yield points afaik
2. Go doesn't enforce message passing, Erlang obviously does
3. When you send a message to a goroutine that has panicked you hang and, potentially at some point, panic. In Erlang an actor dying can send out a final exit message that other actors (likely a supervisor) can subscribe to.
So yeah IDK. To me if it's got lightweight processes, pre-emption, and message passing, it's got everything that makes Erlang special. If it says it's inspired by Erlang I'm going to assume that, along with those things, it also shares goals like fault tolerance.
Actors do not an Erlang make. What makes an Erlang:
- Isolation. A crash in an actor cannot bring down other actors. Cannot bring down the runtime
In Go `panic` crashes the program. In Erlang "panic" crashes an actor, and... that's it.
- Monitoring. The above makes an important property of the system: a process can be monitored, and when it dies you can be guaranteed to receive a message that it died, and why
This lets you build things like supervision trees that are impossible/hard/ineffecient(chose two) in other languages.
- Everything in the VM is aware of processes, concurrency and parallelism
Every process gets its fair share of time: each process gets X "reductions". A reduction is a function call, or a message pass. Each function call or message pass reduces the counter. Once it reaches zero, the process is put on hold, and the next process is run.
This means that almost everything in the system, including the VM itself is re-entrant. Even Erlang's regexp implementation is re-entrant. You never even have to think about "wait, if I call this function, and the process is put on hold, what happens". The process will be re-awakened and continued.
----
The first two are what makes Erlang special. The rest is gravy, and there is quite a lot of it on top.
Erlang doesn't enforce message passing. You can use ets tables to coordinate processes (but don't).
A lot of pls claim erlang inspiration, e.g. pony, but miss some very important points and focus on "actors". Erlang isn't even really an actor system at heart, it just looks like it superficially. Actor systems at their core are message and coordination focused; when you write an erlang or elixir program you are typically minimizing the message passing because it is imperformant and hard to reason about. The raison d'etre of erlang processes is not really message passing concurrency, it's failure domain definition and failure domain bundling (if x crashes also crash y, because now the state of y can't be trusted).