3 ms·
Curious here: would Rust be a better language for writing the VM of an M:N-scheduled platform? Like, would rewriting Erlang's BEAM in Rust be a win?
by derefr 12y ago
Curious here: would Rust be a better language for writing the VM of an M:N-scheduled platform? Like, would rewriting Erlang's BEAM in Rust be a win?
- steveklabnik 12y agoSo, in general, Rust should be good for writing VMs. If you want a JIT, though, Rust may not have any super huge advantage with it, specifically, as it would basically be all unsafe anyway. There was a really great blog post about writing a Scheme implementation, including a GC: http://fitzgeraldnick.com/weblog/60/ http://fitzgeraldnick.com/weblog/60/
- jroesch 12y agoI'm pretty sure even when building a JIT Rust would provide advantages. The only unsafe part of JITing is allocating the underlying instruction buffer and marking the memory as executable to the OS. You could still leverage Rust in building compilers from IR -> Instructions.
- steveklabnik 12y agoYeah, it's only for part of it, maybe the SpiderMonkey people I was talking too are more focused on the unsafe part than the other parts.
- eslaught 12y agoThe point is that whenever you do "IR -> Instructions" you are opening the possibility for logic errors to become memory errors. E.g. emitting opcode 9 instead of opcode 8 might (on some system) allow an attacker to execute arbitrary code. And these sorts of bugs cannot be prevented by pure memory safety alone, once you have (intentionally) opened the door to writing executable memory. You would actually need a full theorem prover to check the correctness of your code for you (which obviously Rust does not provide).