the joy of building a bytecode VM from scratch

submited by
Style Pass
2025-08-07 06:30:05

A few months ago, I was working on numero - a math expression parser. I thought I was building a calculator. Turns out, I was actually standing at the edge of the compiler rabbit hole.

While exploring, I came across the excellent books by Thorsten Ball - Writing An Interpreter In Go and Writing A Compiler In Go. They walk you through building a full interpreted programming language in Go, step by step.

Inspired by that, I knew I wanted to build a toy language of my own. Although, copying the implementation file-by-file didn’t sound fun. So to make things interesting: I rewrote the whole thing in C.

In this post, I’ll walk you through what it took to go from monkey’s source code to an actual executable that feels like magic to me. You'll see why.

It’s not a compiler in the traditional sense (like C → machine code) but it is conceptually kinda similar to how Deno, Bun or Node.js produce self-contained executables for JavaScript.

Leave a Comment
Related Posts