4 ms·
I'm always impressed how the magic of interpreters and compilers can be explained so succinctly. Inspired by Jonesforth, I wrote a complete Lisp interpreter in
by marcpaq 10y ago
I'm always impressed how the magic of interpreters and compilers can be explained so succinctly.
Inspired by Jonesforth, I wrote a complete Lisp interpreter in a single ARM assembly file: https://github.com/marcpaq/arpilisp https://github.com/marcpaq/arpilisp
- cagmz 10y agoHow long did it take you? The documentation is A+ (it reminds me of this compiler: https://github.com/thejameskyle/the-super-tiny-compiler https://github.com/thejameskyle/the-super-tiny-compiler ).
- marcpaq 10y agoI estimate it took 60-70 hours, of which 2/3 of that was for the documentation. Thanks for the compliment and the link to TSTC. I'll add it to my personal list.
- pjmlp 10y agoVery good quality congratulations! While quickly reading through it, my first idea was getting the PI to boot directly to it. :)
- jackhack 10y agoThis is brilliant! I've failed more than once to wrap my stupid brain around lisp but after reading your code, something clicked. I dare say I think I get it! https://github.com/marcpaq/arpilisp/blob/master/arpilisp.s https://github.com/marcpaq/arpilisp/blob/master/arpilisp.s It's all extraordinarily clean and clear (and must set a new world record for most thorough comment --1120 lines!)
- dancek 10y agoYou are my new hero. I've become interested in Lisp every couple of years. This fall I even learned Clojure and implemented a Lisp interpreter in Python. I searched a lot for any open-source Lisp implementation in assembly, but found none. Here it is! I thought a lot about bootstrapping, too, since apparently almost every compiler is written in C these days. Somewhere I got the idea that in the 1970s someone wrote a compiler in assembly and that was used to bootstrap the first C compiler. Guess I'm a romantic, but for me it's important that we know how to get where we are now. Having a high-level language implemented in assembly is quite essential to that, IMO.
- rm445 10y agoI think there's a separate Lisp lineage anyway, wherein someone in the 1960s wrote a minimal machine-code interpreter, and ever since lispers have been writing interpreters on top of other Lisps and revising them to emit compiled code along the way. We would still have Lisp compilers if C never existed.