About this course
A build-it-yourself course: no jargon-first compiler theory. In every session an AI
mentor walks you through writing code, running assertions, and reading ASTs — crafting
a tiny language called Luma from its very first character to real running programs.
You'll hand-write a scanner that turns source text into tokens, tame operator
precedence and associativity with a Pratt parser, and build a tree-walk evaluator
that actually computes answers. Then you'll give the language variables, scopes,
branches, loops, functions, return and closures; wire in strings, lists and a
native-function bridge; and finally compile the AST to your own bytecode and run it
on a stack VM you build yourself — two execution strategies, one language.
Only the topic skeleton is anchored on Crafting Interpreters; every script and every
line of code is original, and Luma's syntax is 100% our own. All exercises are pure
Python stdlib, fully offline, sub-second, and exactly assertable.
Finish the course and you get to say it out loud: I built a language.
What you'll learn
- Hand-write a scanner that turns source text into tokens — multi-digit numbers, two-char operators, string literals
- Tame operator precedence and associativity with Pratt parsing (binding power) and print the resulting AST
- Build a tree-walk evaluator with an environment chain: bindings, nested scopes, branches and loops
- Implement function calls, return and closures, and explain why lexical scoping is designed this way
- Wire strings, lists and a native-function bridge into the language, with type dispatch and runtime errors
- Compile the AST to your own bytecode and run it on a hand-built stack VM, matching the tree-walk results exactly
Syllabus
1Craft a Tiny Language: from Char Stream to Evaluation2 sessions
2Statements & Control Flow: Make Programs Move3 sessions
3Functions & Closures: the Soul of a Language3 sessions
4Strings, Lists & Built-ins: the Language Meets the World2 sessions
5A Bytecode VM: Another Way to Run the Same Language0 sessions
Sessions are on the way.
6Finale: Diagnostics, a REPL & Your Own DSL0 sessions
Sessions are on the way.
Same series · 计算机科学与工程探索
CS & Engineering Explorations
Build from scratch the systems you usually treat as black boxes — and understand them to the core.
◎ Modeled on Princeton’s Bitcoin and Cryptocurrency Technologies + Nakamoto’s whitepaper
Blockchain & Bitcoin: From Hashes to Nakamoto Consensus, Build a Chain YourselfHash-pointer chains, Merkle proofs, PoW nonce search, the whitepaper's own attack probability — all in stdlib hashlib, offline and deterministicView course →◎ Modeled on the University of Michigan’s Model Thinking (Scott Page)
Model Thinking: See the World Like a Many-Model ThinkerSchelling segregation, percolation phase transitions, Solow steady states, replicator dynamics — simulate and prove every model yourself in pure numpyView course →