|
> I'll warn you that it's very 80's hackeresque, but in a good way. Incredibly pragmatic. I consider the BEAM VM as one of the marvels of software engineering. You know it is good, when you explain to other programmers that you can have something like an isolated memory process just like an OS process, with preemption and only a few Ks of memory, with a low latency GC, with distribution across machines built in -- and they don't believe me. Even experienced senior developers are skeptical saying stuff like "well yeah but those are green threads then and they have to yield explicitly -- nope, they don't", "so you have callbacks then somehow, no, not callbacks", "what do you mean separate memory spaces, it is a single OS process right?" and so on. It sounds like magic -- this stuff shouldn't exist, right, but the awesome thing is, it does. Moreover, it is not a hacked up version from a lab some place or a PhD disertation proof of concept -- this is what powers banking, databases, messaging, and probably more than 50% of smartphone access to the internet today. |
https://github.com/mbrock/HBEAM
It's a Haskell executor of .beam programs, in very early prototype stage, and I abandoned working on it 5 years ago (apparently).
Of course it's not meant to be competitive in any way, it's basically just for fun, and because I wanted to learn more about how Erlang works.
The function `interpret1` in the middle of this file has the main opcode switch.
https://github.com/mbrock/HBEAM/blob/master/src/Language/Erl...
I think it's about the smallest subset needed to run a factorial program, but also to implement the very basics of mailboxes with send/receive/timeout.
It uses GHC's shared transactional memory for the mailboxes:
https://github.com/mbrock/HBEAM/blob/master/src/Language/Erl...
Someone, fork it and finish it! :-)