News for hackers. Stuff that matters.
Re:Lisp in fewer than 200 lines of C by akashakya on Sunday November 26, 2017 @03:24PM (#15782786)
If you like this, you might like Lisp interpreter written in assembly in a single file. It is one of the best commented code ever written imo.

https://github.com/marcpaq/arpilisp

Re:Lisp in fewer than 200 lines of C by sparkie on Sunday November 26, 2017 @05:28PM (#15783440)
Another small lisp implementation: http://piumarta.com/software/lysp/

Also, another, more interesting Lisp by the same author: (http://piumarta.com/software/maru/). Maru is basically a lisp where some of the core functions like eval and apply are extensible from user code. There's basically a global map of types to evaluators and applicators, with some functions for you to register your own types and get the evaluation behavior you want.

Re:Lisp in fewer than 200 lines of C by fasquoika on Sunday November 26, 2017 @07:31PM (#15783958)
It seems like arpilisp is inspired by jonesforth[0]. Although not directly stated, the style is similar and the acknowledgements mentions Richard Jones. Anyone interested in implementing simple programming languages might also want to take a look at jonesforth.

[0]: https://github.com/nornagon/jonesforth

Re:Lisp in fewer than 200 lines of C by marcpaq on Monday December 04, 2017 @12:16PM (#15845492)
Arpilisp author here.

Yes, jonesforth definitely inspired and influenced me; that's why Jones is first in the Acknowledgements section.

If you're curious, I keep a list of single-file implementations of programming languages (including jonesforth):

https://github.com/marcpaq/b1fipl

Re:Lisp in fewer than 200 lines of C by nielsbot on Monday November 27, 2017 @05:19AM (#15786253)
Someone once suggested to me the easiest way to "bootstrap the world" is to write a Forth implementation in assembly, and then write your Lisp in Forth.
Re:Lisp in fewer than 200 lines of C by z29LiTp5qUC30n on Monday November 27, 2017 @09:53AM (#15787745)
as there is a project aiming to "bootstrap the world" https://savannah.nongnu.org/projects/stage0/ and they hand wrote a FORTH http://git.savannah.nongnu.org/cgit/stage0.git/tree/stage2/f... and a compacting garbage collecting lisp http://git.savannah.nongnu.org/cgit/stage0.git/tree/stage2/l...

and their opinion was that it was easier to do the lisp than it was to do the FORTH. Although right now they are trying to improve their C Compiler prototype https://github.com/oriansj/M2-Planet before they convert it to assembly

Re:Lisp in fewer than 200 lines of C by _sdegutis on Sunday November 26, 2017 @08:39PM (#15784208)
Since this is written in assembly is it much faster than a C version since this one can manage its own stack frames and stack variables and such? I always imagined that’s the case and that a lisp implemented fully in assembly would be the trick to a super fast lisp that can complete with Go.
Re:Lisp in fewer than 200 lines of C by tom_mellior on Monday November 27, 2017 @03:54AM (#15785816)
An interpreter written in assembly is still an interpreter. Yes, it may have control over stack frames. But so does a compiler, and the code generated by a compiler doesn't incur interpretation overhead. If you want performance, compliation is the way to go. And that's what fast Lisps do.
Re:Lisp in fewer than 200 lines of C by marcpaq on Monday December 04, 2017 @12:45PM (#15845778)
Arpilisp author here.

If you were to implement the same Lisp in C then compare, then maybe the assembly variant would be faster for the reasons you mention. Or maybe not.

Also, I modeled arpilisp after the original Lisp. That's barely a first step, and possibly the wrong first step, for anything non-trivial, including applications requiring a "super fast lisp that can compete with Go."

But I didn't write arpilisp for performance. I wrote it to learn and share. Enjoy!

Re:Lisp in fewer than 200 lines of C by ci5er on Sunday November 26, 2017 @10:45PM (#15784652)
LISP was created a long time ago. Assembly was the weapon of choice. Thinking Machines, Symbolics and Macsyma might already say: We did that. But, uh, no.
Re:Lisp in fewer than 200 lines of C by klmr on Monday November 27, 2017 @08:04AM (#15786954)
The first LISP implementation was famously done in machine code, not assembly.