Bytecode compilers and interpreters
Two fun things happened recently and the proximity of the two made something go click in my head and now I think I understand how bytecode interpreters work.
I am a human and programmer . I like to read books, take photos, and ride bikes in the hills near my house. I post things (and toot things ) about bread, legumes, and compilers. Right now, I am a software engineer working on compilers at Shopify and a Hacker in Residence at the Dartmouth College computer science…
Visit bernsteinbear.com → RSS feedOn Hacker News Jan 2019 – Dec 2025
Software Engineering 22Programming Languages 15Tools & Productivity 3Math & Algorithms 2Life, Learning & Writing 2Databases & Data 2
Two fun things happened recently and the proximity of the two made something go click in my head and now I think I understand how bytecode interpreters work.
Scrapscript is a small, pure, functional, content-addressable, network-first programming language. It’s designed to allow creating small, simply shareable programs. The language was created by Taylor Troesh and the main implementation was created by me and Chris.
Intro to HM
With some partial evaluation and specialization hints, it is possible to get pretty decent speedups on interpreters by turning them into compilers.
first – previous
What is Damas-Hindley-Milner?
CPS, or continuation-passing style, is an intermediate representation for programs, particularly functional programs. It’s used in compilers for languages such as SML and Scheme. Much of its utility comes from its support for tail calls and nonlocal control flow such as call/cc, but it can also be used as an…
Compiling Lisp let expressions to x86-64
Tiger got to hunt, Bird got to fly; Lisper got to sit and wonder, (Y (Y Y))? Tiger got to sleep, Bird got to land; Lisper got to tell himself he understand. -- Kurt Vonnegut, modified by Darius Bacon
Compiling Lisp primitive unary functions to x86-64
Optimizing compilers like to keep track of each IR instruction’s effects. An instruction’s effects vary wildly from having no effects at all, to writing a specific variable, to completely unknown (writing all state).
Adding a reader to our Lisp compiler
Overture to our small Lisp to x86-64 compiler
Static Single Assignment is a program representation where each “variable” (though this term can be misleading) is assigned exactly once. Mostly the variables aren’t variables at all, but instead names for values—for expressions. SSA is used a lot in compilers. See this lesson from Cornell for converting Bril to SSA…
With a little effort, you can make your mypy-typed Python go zoom.