4/19/2026 at 5:21:18 AM
Dang, this is really relatable. A couple months I started digging into the Jimtcl interpreter, which is a 20-year-old Tcl interpreter written in C. My goal was to make it thread safe, which I naively thought wouldn't be that hard. Turns out interpreters are really complicated, lol. There were many many times I saw a line of code that made no sense, and only would make sense a couple days after when reading in another subsystem. Variable lookup caching in particular gave me a lot of grief, as I learned how epoch-based invalidation works. It's slightly insane to keep track of a different epoch per call frame, and whenever a variable is looked up, you have to figure out what call frame that variable is referencing based on context, and then check if its epoch is correct. It is incredibly humbling that these systems work as well as they do.I eventually did end up getting Jimtcl to be multithread-safe, but it ended up being slower than the naive approach of serializing and deserializing between threads. I've been seriously nerd-sniped since, and have slowly been building my own thread safe interpreter, but I still have to cross check with Jimtcl constantly.
by smj-edison