Austin's Blog

Crafting Interpreters: The Journey So Far

I've been reading Crafting Interpreters by Robert Nystrom over the past week or so. More specifically I'm revisiting the book from where I left off, part 2 where we start building a bytecode compiler called clox. It's a fascinating journey through the implementation of a compiler, and Nystrom makes the read approachable yet technically information-dense -- frankly, it's a joy to read, which I never thought I would ever say about a compiler book.

The book is currently going through the implementation of hash tables, strings, and other basic data types and structures in the lox scripting language the book is based around. Nystrom does this part of the book in C. While I've read my fair share of C code snippets, and I've used gdb to debug running C programs, I've never used C to build anything practical of note.

This book changed that for me. I'm learning how to use C in 2025, and it's a lot different than when I first tried the language. When I first tried learning C, I was but a fledgling programmer, not knowing a pointer from a hole in the ground. At the time, I conflated C and C++, being a brand new dev, and attempted to learn both at the same time from a couple of those "Teach Yourself in 24 Hours"-series books. They were pretty terrible books to learn from, and I wouldn't recommend them to anyone. It turned me off of programming for a while until I learned Perl in college and realized hey, programming can be fun! (C programming can be fun too, but it takes a deeper understanding of several concepts that were not immediately accessible to my baby-dev brain.)

Anyway, C has been a lot of fun to dig into. Having used C indirectly through languages that use it and its binary interface, wrapping C libraries in languages like Python, etc. it's not totally unfamiliar, yet it still takes a lot of getting used to. For example, things you take for granted in Javascript, Ruby, Python, etc. such as dictionaries/hash tables, objects, even dynamic arrays have to be coded from scratch. Or, you can use libraries that implement these for you -- I haven't gotten to that yet, but there are lots of utility libraries out there from orgs like GNU, Apache, etc. that seem a lot heavier and more robust than what I've been writing (then again, those are battle-tested tools for production-level codebases, and not tutorial code examples meant to teach, so this makes sense).

Overall I'm having a load of fun learning how these things work under the hood.