Building LISP

“The best way to understand how something works is to try to build it for yourself. Reading somebody else’s explanation might satisfy your curiosity, but without the experience of falling into all the little traps it is difficult to get a feel for why something is designed a certain way.

It’s been said that every would-be programmer should write a compiler. While I think this is good advice (although I haven’t followed it myself), there is so much effort involved just in parsing a language such as C that any potential insights risk getting lost in a mire of details. Perhaps creating an interpreter for some simple language would be a good first step.

I first started playing around with LISP a good few years ago, yet much later than I should have. This led me to the classic lecture series Structure and Interpretation of Computer Programs. If you have the next 24 hours free and haven’t seen the videos already, go watch them now.

The course covers many topics, but the second half shows in detail how to evaluate LISP, first by implementing a simple version of eval in LISP itself. I figured that this would translate well into C, and so decided to try creating my own implementation of LISP…”