Programmer to Interpreter Development
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.
Interpreter vs Runtime vs VM vs Compiler. Four words people use interchangeably for four different things.
Source Text, Tokens, and Parsing. How a lexer and a parser turn text into a tree, and what is unusual about R’s parser.
ASTs and Tree-Walking Evaluation. The simplest way to run that tree, and why it is slow.
Bytecode and Virtual Machines. Flattening the tree into instructions for a dispatch loop, as R’s bytecode compiler does.
How R Executes Code. The same ideas in GNU R: the evaluation loop, argument matching, and the bytecode compiler.
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.
R Objects. Every R value carries a type and a bag of attributes, and almost everything else follows from that.
Environments. Name lookup is where an interpreter spends a surprising amount of its life.
Closures. Functions capture their defining scope. This is how lexical scoping works in a runtime.
Ownership in Rust. When implementing an interpreter from scratch, memory safety becomes a design choice. Rust enforces ownership at compile time.
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.