Alabhya Jindal

Crafting Interpreters: Part 1

I finally read the first half of Crafting Interpreters! I started the book multiple times, never getting past the first chapter until now. I have about 4-5 folders called jlox, plox etc. on my computer from me starting the book multiple times.

A two-pass reading approach worked this time. I read a chapter understanding the material and then came back to it afterwards, converting the Java code to Python. Initially I started with no intention of programming anything. After reading Parsing Expressions I felt confident enough to give it a try. I leaned on LLMs to help with the translations. I got this idea from Hacker News about a year ago when I mentioned how this book using Java was a hurdle for me.

I used dataclasses and pattern matching. This helped eliminate the need for a script to generate classes and the visitor pattern. I have skipped the chapters on Classes, maybe I’ll come back to it. I also didn’t understand the chapter, Resolving and Binding.

I’m quite eager to start the second half using C. I’ll need to brush up on the language a little before I start.