Skip to content

Comment on Ask HN: What does a developer need to know to build their own Lisp from scratch?

Comments

At the simplest:

1. Parse and produce S-Expresseions ("read" and "print").

2. Use the object system of the implementation language as much as possible. If necessary, implement some lisp-specific types like the cons pair, empty list, symbol. First get it to work correctly, you can optimise later.

3. Implement all the "special forms" which can't be implemented using macros in the implementation language.

4. Implement any library functions that can't be implemented in lisp itself using the implementation language.

5. Implement "eval" (evaluates S-Expresseions). Now you've got a working interpreter.

6. Use your interpreter to evaluate macros. Use that to implement any additional "special forms".

7. Write any additional library functions in your own lisp.

That's it, at this point you have a working lisp implementation. There are many opportunities for optimisation, from lambda lifting and continuation passing style to hygienic macros and even just in time compilation.

Happy Hacking!

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.