[HN Gopher] Building an Emacs Lisp VM in Rust
___________________________________________________________________
Building an Emacs Lisp VM in Rust
Author : lukastyrychtr
Score : 101 points
Date : 2021-10-29 13:30 UTC (9 hours ago)
(HTM) web link (coredumped.dev)
(TXT) w3m dump (coredumped.dev)
| sizediterable wrote:
| I would love to see some benchmarks that demonstrate the impact
| of the more optimized representation. I found that despite some
| possibly sub-optimal performance trade-offs in favor of
| productivity in my own hobby interpreter, it can still do much
| better than Python and Wren in some micro-benchmarks that I
| performed (naive sum in a loop and naive fibonacci
| implementation). Python was no surprise since PyObjects are
| relatively "fat" [0], but Wren was created by the author of
| Crafting Interpreters (mentioned in the article) so I expected a
| bit better. My representation ended up looking something like:
| enum Value { Unit, False, True,
| Integer(isize), Float(FloatSize),
| String(Rc<str>), Closure(Rc<Closure>),
| Tuple(Rc<[Value]>), }
|
| Unfortunately since I'm depending on reference-counting, it can't
| implement `Copy` which I suspect is where I'm currently losing
| significant performance. For values embedded in bytecode
| instructions I can cheat and copy anyway since only the non-
| refcounted ones are allowed in them.
|
| [0]
| https://github.com/python/cpython/blob/main/Include/object.h...
| mamcx wrote:
| Yeah, I wonder the same.
|
| I struggle a lot early on my lang with this (also: Wanna have
| 2d vectors) and eventually get a enum alike yours (but the
| Rc<str>, Rc<Closure>, Rc<[Value]> intrigue me!).
| emteycz wrote:
| How about turning Value into MemoryCell and handling references
| outside of it?
| sizediterable wrote:
| It's something I'm willing to explore once I have more
| comprehensive benchmarks. Right now the ones I have are
| significantly weighted on integer operations that I think
| will be hurt by the additional pointer indirection. Once my
| benchmark suite is less biased I can make a more holistic
| decision about the trade-offs.
| rightbyte wrote:
| "I ended up needing to make some tweaks to the ordering and
| structure of the lisp files to support a bytecode-only
| bootstrap."
|
| Why not make it two pass? We are not reading source from cards
| anymore.
| pdpi wrote:
| > About a year ago I was bitten by the PL bug. It started with
| reading Crafting Interpreters and discovering the wonders
| hidden under the hood of a compiler.
|
| Doesn't sound like the author is super-experienced with this
| whole interpreter thing, thought might not have crossed their
| mind.
| Y_Y wrote:
| I was expecting to read language evangelism from someone who
| hadn't heard of Remacs. This turned out to be a really
| interesting read and I'm looking forward to seeing what comes of
| it. I'd love to see a future where there is a choice between
| different cores for Emacs like Guile or a jitter or one of these
| rustbuckets.
| disgruntledphd2 wrote:
| Yeah, a multi threaded implementation of the Emacs VM would be
| amazing, I definitely wish the author well.
___________________________________________________________________
(page generated 2021-10-29 23:01 UTC)