Programmer to Interpreter Development

READING PATHSSTATUS: STABLELEVEL: INTROREVIEWED: 2026-10-21

This path is for programmers who write code but have never built a language implementation. It follows source text through parsing, tree walking and bytecode to a running interpreter, and then looks at the decisions an interpreter for R has to make.

  1. Interpreter vs Runtime vs VM vs Compiler. Four words people use interchangeably for four different things.

  2. Source Text, Tokens, and Parsing. How a lexer and a parser turn text into a tree, and what is unusual about R’s parser.

  3. ASTs and Tree-Walking Evaluation. The simplest way to run that tree, and why it is slow.

  4. Bytecode and Virtual Machines. Flattening the tree into instructions for a dispatch loop, as R’s bytecode compiler does.

  5. How R Executes Code. The same ideas in GNU R: the evaluation loop, argument matching, and the bytecode compiler.

  6. Stack versus Heap. An interpreter keeps call frames on a stack and long-lived objects on a heap, and where a value lives decides how long it lasts.

  7. R Objects. Every R value carries a type and a bag of attributes, and almost everything else follows from that.

  8. Environments. Name lookup is where an interpreter spends a surprising amount of its life.

  9. Closures. Functions capture their defining scope. This is how lexical scoping works in a runtime.

  10. Ownership in Rust. When implementing an interpreter from scratch, memory safety becomes a design choice. Rust enforces ownership at compile time.

  11. Multi-Interpreter Architecture. What has to be true before two interpreters can share one process without corrupting each other.

JIT Compilation and Deoptimization goes one step past bytecode. After this path, r-in-rust shows an R interpreter being built from scratch, and threaded-r an existing interpreter adapted to run on several threads.

Where this appears

Where to go next

Back to top