How Code Runs: Compilation, Interpretation, and Execution Models
You have typed ruby script.rb thousands of times. What actually happens between pressing enter and seeing output? Most engineers have a vague answer — "Ruby runs it" — and that va…
Compilers and Interpreters covers: How Code Runs, The Front End, Making Meaning, The Back End, Ruby Under the Hood. Year 3, Quarter 11. Includes 14 exercises and 2 projects.
This course unlocks once you've finished its prerequisite. Open prerequisite →
You have typed ruby script.rb thousands of times. What actually happens between pressing enter and seeing output? Most engineers have a vague answer — "Ruby runs it" — and that va…
The scariest-sounding part of building a language — turning a flat string of characters like if (x > 0) return x 2; into a structured tree a computer can execute — turns out to b…
Parsing gave you a tree that's grammatically correct — but grammatical correctness isn't meaning. x + 1 parses fine even if x was never declared; "hello" - 3 parses fine even thou…
The front end understood your program; the middle end optimized it; now the back end has to make it actually run on real hardware — and this is where the abstract meets the physic…
Everything in this course has been building to a single, quietly transformative capability: you can now open CRuby's actual source code — parse.y, compile.c, vm.c — and follow wha…
- [ ] CI Ch4: Scanning — Build a lexer/scanner that tokenizes Lox source code (numbers, strings, identifiers, operators) - [ ] CI Ch5: Representing Code — Define AST node classes …
- [ ] CI Ch7: Evaluating Expressions — Tree-walk interpreter evaluating arithmetic, comparisons, string concatenation - [ ] CI Ch8: Statements and State — Add print statements, va…
- [ ] CI Ch12-13: Classes and Inheritance — Add classes, this, constructors, methods, single inheritance - [ ] CI Ch14-18: Bytecode VM — Build a bytecode chunk format, VM with sta…
- [ ] Build a complete Lox interpreter in Ruby (tree-walk) — All features from Crafting Interpreters Part II: expressions, statements, control flow, functions, closures, classes, …
Following Crafting Interpreters chapters 4-6, build the lexer (scanner) and parser for the Lox language in Ruby (not Java). Output: token stream and AST for Lox programs. Test wit…
Write a Ruby tool that takes Ruby source code, compiles it with RubyVM::InstructionSequence, and displays the YARV bytecode with annotations explaining each instruction. Compare b…
- [ ] What are the stages of a compiler? (lexing, parsing, semantic analysis, optimization, code generation) - [ ] What is a recursive descent parser? What class of grammars can i…
12 lessons. Read in order; spiral back when you need to. By the end you'll have used the core ideas twice — once on the abstract, once on something you'll meet at work next week.