Crafting Interpreters Review
15 April 2021

I finished read Crafting Interpreters. Well I only really read the second part. I am reasonably familiar with interpreters so didn't feel the need to read about a Java implementation of an AST interpreter.

The second part of the book takes you through creating a byte code compiler and interpreter, all in C.

This interested me enough to read it and type in the code as I went through the book. The author has taken the nice approach of telling you everything you need to type to get each section working. This works really well. The gradual flipping from explanation to targeted additions to the code works really well. I can't be sure how well it would work for a total beginner, presumably they would work through the first section as well.

Having something working early on helped to motivate continuing to work through the book.

I admit I stopped typing the code during the final few chapters. I felt I understood the interpreter enough to understand his approach to the final chapters. Turns out to be a good call as it saved time and comprehension remained high.

Did it introduce any new concepts, alas not too many. While the interpreter had certain limitation it had support for closures (variable capturing) and a simple garbage collector. So you develop a fully featured interpreter. I didn't know much about implementing closures so that was new to me.

The C code presented was as simple as could be. It took some approaches that might get picked up in a code review in a professional environment but these shorts cuts where justified from the simplifications they brought to the code. Understanding of the ideas is more important than optimal code quality. Ignore these small short comings then the code you type in results in some nice looking C code, something worth looking at if you have a low opinion on programming in C.

Would I recommend this book. Absolutely, given it is online other than a bit of time you have little to lose. You need to know a little C to get the most out of it. The explanation of the algorithms used is good and his easy going writing style flow smoothly.