Compilers & Programming Languages

How does source code become executable behavior, and how do language and compiler design choices affect correctness, performance, safety, tooling and developer experience?

Your path through Compilers & Programming Languages

0 of 88 Foundation lessons done
0 of 284 lessons done overall
Start: From Source to Behavior →

Then follow the stages in order

Each stage builds on the ones before it. Labs and simulators sit right after the lessons they exercise. Open a stage to see its lessons. Full roadmap with goals →

  1. What Happens to My Code0 of 17 lessons done
    1. From Source to BehaviorFoundation≈ 15 min
    2. The Phases, and Why Each One ExistsFoundation≈ 20 min
    3. Frontend, Middle-End, BackendFoundation≈ 15 min
    4. Compiler versus Interpreter Is Not a BinaryFoundation≈ 20 min
    5. What Seven Real Languages Actually DoFoundation≈ 15 min
    6. Ahead-of-Time CompilationFoundation≈ 15 min
    7. What Dies at Each StageFoundation≈ 20 min
    8. One Line, All the Way DownFoundation≈ 20 min
    9. Who Is the Language For?Foundation≈ 15 min
    10. The Questions a Language Definition Must AnswerFoundation≈ 15 min
    11. Syntax versus SemanticsFoundation≈ 15 min
    12. Ergonomics Is a Compiler FeatureFoundation≈ 15 min
    13. Choosing an Execution ModelFoundation≈ 15 min
    14. Choosing How Memory Is ManagedFoundation≈ 15 min
    15. Choosing a Concurrency ModelFoundation≈ 15 min
    16. Interoperability Is a Language Design DecisionFoundation≈ 15 min
    17. The Trade Nobody EscapesFoundation≈ 15 min
  2. Syntax: Grammar, Lexing, Parsing, Diagnostics0 of 31 lessons done
    1. Formal GrammarsFoundation≈ 15 min
    2. Productions & DerivationsFoundation≈ 15 min
    3. BNF & EBNFFoundation≈ 15 min
    4. Context-Free GrammarsFoundation≈ 15 min
    5. Ambiguous GrammarsFoundation≈ 20 min
    6. Operator PrecedenceFoundation≈ 15 min
    7. AssociativityFoundation≈ 20 min
    8. Left RecursionFoundation≈ 20 min
    9. Lexical AnalysisFoundation≈ 15 min
    10. Token KindsFoundation≈ 15 min
    11. Token MetadataFoundation≈ 20 min
    12. Implementing a LexerFoundation≈ 20 min
    13. Regular LanguagesFoundation≈ 15 min
    14. Finite AutomataFoundation≈ 15 min
    15. NFA vs DFAFoundation≈ 20 min
    16. Lexer HazardsFoundation≈ 25 min
    17. What a Parser Actually DoesFoundation≈ 20 min
    18. Parse Tree vs Abstract Syntax TreeFoundation≈ 20 min
    19. Recursive DescentFoundation≈ 20 min
    20. Pratt ParsingFoundation≈ 25 min
    21. LL Parsing, FIRST and FOLLOWFoundation≈ 25 min
    22. LR ParsingFoundation≈ 25 min
    23. Shift and Reduce, Step by StepFoundation≈ 20 min
    24. LL vs LR: Why Production Compilers Chose the Weaker OneFoundation≈ 25 min
    25. Parser GeneratorsFoundation≈ 20 min
    26. Source LocationsFoundation≈ 20 min
    27. Spans and RangesFoundation≈ 20 min
    28. Error RecoveryFoundation≈ 20 min
    29. Parser SynchronizationFoundation≈ 20 min
    30. Diagnostic QualityFoundation≈ 20 min
    31. Suggested FixesFoundation≈ 20 min
  3. Meaning: Trees, Names and Scopes0 of 14 lessons done
    1. The Abstract Syntax TreeFoundation≈ 15 min
    2. Designing AST NodesFoundation≈ 20 min
    3. Walking the TreeFoundation≈ 20 min
    4. The Visitor as the Shape of a PassFoundation≈ 20 min
    5. Changing the TreeFoundation≈ 20 min
    6. One Tree, Six ConsumersFoundation≈ 20 min
    7. Semantic AnalysisFoundation≈ 15 min
    8. The Symbol TableFoundation≈ 20 min
    9. Lexical ScopeFoundation≈ 20 min
    10. ShadowingFoundation≈ 15 min
    11. Name ResolutionFoundation≈ 20 min
    12. Static and Dynamic ScopingFoundation≈ 20 min
    13. Declaration OrderFoundation≈ 20 min
    14. The Annotated ASTFoundation≈ 20 min
  4. Types: What the Language Can Prove0 of 26 lessons done
    1. What a Type System Actually ProvesFoundation≈ 20 min
    2. Static and Dynamic Typing, Compared HonestlyFoundation≈ 20 min
    3. Type Checking: Is This Operation Defined for These Operands?Foundation≈ 20 min
    4. Typing Rules: Reading the Notation With the Line Through ItFoundation≈ 15 min
    5. The Type Environment: What Γ Is, and Where the Compiler Keeps ItFoundation≈ 20 min
    6. Type Inference: Leaving the Type OffFoundation≈ 20 min
    7. Hindley–Milner: Inference Without a Single AnnotationFoundation≈ 25 min
    8. Unification, and Why `T = List<T>` Must FailFoundation≈ 25 min
    9. Parametric Polymorphism and the Theorems You Get FreeFoundation≈ 20 min
    10. Ad-Hoc Polymorphism: One Name, Different CodeFoundation≈ 20 min
    11. Subtyping: What `Dog <: Animal` LicensesFoundation≈ 20 min
    12. Variance: Why `List<Dog>` Is Not a `List<Animal>`Foundation≈ 20 min
    13. Union TypesFoundation≈ 20 min
    14. Intersection TypesFoundation≈ 15 min
    15. Algebraic Data TypesFoundation≈ 20 min
    16. Pattern MatchingFoundation≈ 20 min
    17. Exhaustiveness CheckingFoundation≈ 20 min
    18. Nullability and Optional TypesFoundation≈ 20 min
    19. Gradual TypingFoundation≈ 20 min
    20. Structural vs Nominal TypingFoundation≈ 20 min
    21. Type SoundnessFoundation≈ 20 min
    22. Type Erasure and ReificationFoundation≈ 20 min
    23. MonomorphizationFoundation≈ 20 min
    24. Ownership TypesFoundation≈ 20 min
    25. Lifetime AnalysisFoundation≈ 20 min
    26. Effect SystemsFoundation≈ 20 min
  5. The Middle End: IR, CFG, SSA, Data Flow0 of 28 lessons done
    1. What an Intermediate Representation IsIntermediate≈ 15 min
    2. Why an IR Exists: M x N Becomes M + NIntermediate≈ 15 min
    3. Levels of IR: High, Mid and LowIntermediate≈ 15 min
    4. Three-Address CodeIntermediate≈ 15 min
    5. LoweringIntermediate≈ 20 min
    6. Designing an IR: The Four DecisionsIntermediate≈ 20 min
    7. IR VerificationIntermediate≈ 15 min
    8. Many Frontends, One BackendIntermediate≈ 15 min
    9. The Control-Flow GraphIntermediate≈ 15 min
    10. Basic BlocksIntermediate≈ 15 min
    11. Building the CFGIntermediate≈ 20 min
    12. Natural LoopsIntermediate≈ 20 min
    13. DominatorsIntermediate≈ 20 min
    14. The Dominator TreeIntermediate≈ 15 min
    15. The Dominance FrontierIntermediate≈ 20 min
    16. Static Single AssignmentIntermediate≈ 20 min
    17. Phi FunctionsIntermediate≈ 20 min
    18. Constructing SSAIntermediate≈ 20 min
    19. Why SSA HelpsIntermediate≈ 20 min
    20. Leaving SSAIntermediate≈ 25 min
    21. SSA VariantsIntermediate≈ 20 min
    22. The Data-Flow FrameworkIntermediate≈ 20 min
    23. Iterating to a Fixed PointIntermediate≈ 20 min
    24. Forward and Backward AnalysisIntermediate≈ 15 min
    25. Reaching DefinitionsIntermediate≈ 20 min
    26. Liveness AnalysisIntermediate≈ 20 min
    27. Available ExpressionsIntermediate≈ 20 min
    28. Constant PropagationIntermediate≈ 20 min
  6. Optimization, Loops and Legality0 of 24 lessons done
    1. Constant FoldingIntermediate≈ 15 min
    2. Dead Code EliminationIntermediate≈ 15 min
    3. Common Subexpression EliminationIntermediate≈ 15 min
    4. Copy PropagationIntermediate≈ 15 min
    5. Strength Reduction and Algebraic IdentitiesIntermediate≈ 20 min
    6. InliningIntermediate≈ 20 min
    7. DevirtualizationIntermediate≈ 20 min
    8. Partial Evaluation and SpecializationIntermediate≈ 20 min
    9. Loop-Invariant Code MotionIntermediate≈ 15 min
    10. Loop UnrollingIntermediate≈ 15 min
    11. Fusion, Fission, Interchange and TilingIntermediate≈ 20 min
    12. Automatic VectorizationIntermediate≈ 15 min
    13. Alias AnalysisIntermediate≈ 20 min
    14. Escape AnalysisIntermediate≈ 20 min
    15. Bounds Check EliminationIntermediate≈ 20 min
    16. Optimization LegalityIntermediate≈ 20 min
    17. Observable BehaviorIntermediate≈ 20 min
    18. The As-If RuleIntermediate≈ 20 min
    19. Undefined BehaviorIntermediate≈ 20 min
    20. How Undefined Behavior Becomes Faster CodeIntermediate≈ 20 min
    21. Semantics Decide, Not ClevernessIntermediate≈ 20 min
    22. Optimization LevelsIntermediate≈ 20 min
    23. Pass PipelinesIntermediate≈ 20 min
    24. Phase OrderingIntermediate≈ 20 min
  7. The Back End: Code Generation, Registers, ABI0 of 22 lessons done
    1. Code GenerationIntermediate≈ 15 min
    2. Instruction SelectionIntermediate≈ 20 min
    3. Tree Pattern MatchingIntermediate≈ 15 min
    4. Instruction SchedulingIntermediate≈ 20 min
    5. Peephole OptimizationIntermediate≈ 20 min
    6. Reading Assembly OutputIntermediate≈ 20 min
    7. Machine Code EncodingIntermediate≈ 20 min
    8. What a Backend Must Know About Its TargetIntermediate≈ 15 min
    9. Register AllocationIntermediate≈ 15 min
    10. Live RangesIntermediate≈ 20 min
    11. The Interference GraphIntermediate≈ 15 min
    12. Graph Colouring AllocationIntermediate≈ 15 min
    13. Linear Scan AllocationIntermediate≈ 15 min
    14. SpillingIntermediate≈ 20 min
    15. Coalescing and RematerializationIntermediate≈ 20 min
    16. Calling ConventionsIntermediate≈ 25 min
    17. Stack Frame LayoutIntermediate≈ 20 min
    18. What an ABI Actually IsIntermediate≈ 20 min
    19. Name ManglingIntermediate≈ 15 min
    20. ABI StabilityIntermediate≈ 20 min
    21. Cross-CompilationIntermediate≈ 15 min
    22. Target TriplesIntermediate≈ 15 min
  8. Linking, Runtimes and Compiling at Run Time0 of 43 lessons done
    1. What a Linker DoesAdvanced≈ 20 min
    2. Object FilesAdvanced≈ 20 min
    3. Symbols and ReferencesAdvanced≈ 20 min
    4. RelocationsAdvanced≈ 20 min
    5. Static LinkingAdvanced≈ 20 min
    6. Dynamic LinkingAdvanced≈ 20 min
    7. Shared LibrariesAdvanced≈ 20 min
    8. Symbol Resolution OrderAdvanced≈ 20 min
    9. The LoaderAdvanced≈ 20 min
    10. Bootstrapping a CompilerAdvanced≈ 15 min
    11. Self-Hosting and the Three-Stage BuildAdvanced≈ 15 min
    12. Reflections on Trusting TrustAdvanced≈ 15 min
    13. The Toolchain Is Your Trusted Computing BaseAdvanced≈ 15 min
    14. Reproducible CompilationAdvanced≈ 15 min
    15. BytecodeAdvanced≈ 20 min
    16. Stack-Based Virtual MachinesAdvanced≈ 15 min
    17. Register-Based Virtual MachinesAdvanced≈ 15 min
    18. Stack VM vs Register VMAdvanced≈ 15 min
    19. Tree-Walking InterpretersAdvanced≈ 15 min
    20. Compiling to BytecodeAdvanced≈ 20 min
    21. The Dispatch LoopAdvanced≈ 15 min
    22. Where an Interpreter's Time Actually GoesAdvanced≈ 25 min
    23. What a Virtual Machine Has to HoldAdvanced≈ 25 min
    24. Just-in-Time CompilationAdvanced≈ 20 min
    25. Why Runtime Information HelpsAdvanced≈ 20 min
    26. Tiered CompilationAdvanced≈ 20 min
    27. Profiling and HotnessAdvanced≈ 20 min
    28. On-Stack ReplacementAdvanced≈ 20 min
    29. Speculative OptimizationAdvanced≈ 20 min
    30. GuardsAdvanced≈ 20 min
    31. DeoptimizationAdvanced≈ 25 min
    32. Inline CachesAdvanced≈ 20 min
    33. What a JIT CostsAdvanced≈ 25 min
    34. Syntactic SugarAdvanced≈ 20 min
    35. DesugaringAdvanced≈ 20 min
    36. ClosuresAdvanced≈ 15 min
    37. Closure ConversionAdvanced≈ 20 min
    38. Lambda LiftingAdvanced≈ 15 min
    39. Lowering CoroutinesAdvanced≈ 20 min
    40. Lowering Async and AwaitAdvanced≈ 20 min
    41. Exception HandlingAdvanced≈ 20 min
    42. Stack UnwindingAdvanced≈ 20 min
    43. Compiling Pattern MatchingAdvanced≈ 20 min
  9. Real Pipelines, Infrastructure and DSLs0 of 26 lessons done
    1. The CPython PipelineAdvanced≈ 20 min
    2. The JavaScript PipelineAdvanced≈ 20 min
    3. The TypeScript PipelineAdvanced≈ 20 min
    4. The C++ PipelineAdvanced≈ 20 min
    5. The PreprocessorAdvanced≈ 20 min
    6. TemplatesAdvanced≈ 20 min
    7. Template InstantiationAdvanced≈ 20 min
    8. Compile-Time EvaluationAdvanced≈ 20 min
    9. The Rust PipelineAdvanced≈ 25 min
    10. The Go PipelineAdvanced≈ 25 min
    11. Four Languages, One ProgramAdvanced≈ 30 min
    12. What LLVM Actually IsAdvanced≈ 15 min
    13. The Three-Phase ArchitectureAdvanced≈ 15 min
    14. Reading LLVM IRAdvanced≈ 20 min
    15. ClangAdvanced≈ 15 min
    16. GCCAdvanced≈ 15 min
    17. What a Toolchain Actually ContainsAdvanced≈ 15 min
    18. WebAssembly as a Compilation TargetAdvanced≈ 15 min
    19. The WebAssembly Execution ModelAdvanced≈ 20 min
    20. WebAssembly Versus NativeAdvanced≈ 15 min
    21. Domain-Specific LanguagesAdvanced≈ 15 min
    22. Internal versus External DSLsAdvanced≈ 15 min
    23. Should I Build a DSL?Advanced≈ 20 min
    24. Implementing a DSLAdvanced≈ 20 min
    25. Configuration LanguagesAdvanced≈ 20 min
    26. The Tooling Cost of a DSLAdvanced≈ 20 min
  10. Correctness, Tooling, Builds and AtlasLang0 of 53 lessons done
    1. MiscompilationAdvanced≈ 20 min
    2. Testing a CompilerAdvanced≈ 20 min
    3. Golden TestsAdvanced≈ 15 min
    4. Differential TestingAdvanced≈ 20 min
    5. Compiler FuzzingAdvanced≈ 20 min
    6. Translation ValidationAdvanced≈ 20 min
    7. Verified CompilersAdvanced≈ 15 min
    8. Compilers and SecurityAdvanced≈ 15 min
    9. Static AnalysisAdvanced≈ 20 min
    10. Abstract InterpretationAdvanced≈ 25 min
    11. Control-Flow AnalysisAdvanced≈ 20 min
    12. Interprocedural AnalysisAdvanced≈ 20 min
    13. LintersAdvanced≈ 20 min
    14. FormattersAdvanced≈ 25 min
    15. The Concrete Syntax TreeAdvanced≈ 20 min
    16. The Language ServerAdvanced≈ 25 min
    17. The Language Server ProtocolAdvanced≈ 20 min
    18. Semantic RefactoringAdvanced≈ 25 min
    19. Debug InformationAdvanced≈ 25 min
    20. Source MapsAdvanced≈ 25 min
    21. Debug and Release BuildsAdvanced≈ 20 min
    22. Debugging Optimized CodeAdvanced≈ 25 min
    23. SymbolicationAdvanced≈ 20 min
    24. Reading What the Compiler ProducedAdvanced≈ 20 min
    25. Compilation UnitsAdvanced≈ 15 min
    26. Separate CompilationAdvanced≈ 15 min
    27. Modules as Units of Separate CompilationAdvanced≈ 10 min
    28. Interface FilesAdvanced≈ 10 min
    29. Incremental CompilationAdvanced≈ 10 min
    30. The Build Dependency GraphAdvanced≈ 15 min
    31. Where the Compiler Ends and the Build System BeginsAdvanced≈ 10 min
    32. Hermetic CompilationAdvanced≈ 20 min
    33. Compile Time versus RuntimeAdvanced≈ 20 min
    34. Whole-Program OptimizationAdvanced≈ 20 min
    35. Link-Time OptimizationAdvanced≈ 20 min
    36. Profile-Guided OptimizationAdvanced≈ 20 min
    37. What a Profile Costs YouAdvanced≈ 20 min
    38. Feedback-Directed OptimizationAdvanced≈ 20 min
    39. The Compiler Is Also a Program With Performance RequirementsAdvanced≈ 20 min
    40. A Plan Is a ProgramAdvanced≈ 20 min
    41. Agent DSLs and the Plan ASTAdvanced≈ 15 min
    42. Typed Tool CallsAdvanced≈ 20 min
    43. Parse, Validate, Authorize, ExecuteAdvanced≈ 15 min
    44. Recovering Structure From Model OutputAdvanced≈ 15 min
    45. AtlasLang: The Whole ThingAdvanced≈ 20 min
    46. AtlasLang: The LexerAdvanced≈ 20 min
    47. AtlasLang: The ParserAdvanced≈ 20 min
    48. AtlasLang: Evaluating the Tree DirectlyAdvanced≈ 20 min
    49. AtlasLang: Scopes, Shadowing and a Real BugAdvanced≈ 20 min
    50. AtlasLang: Three Types and One Honest LimitationAdvanced≈ 25 min
    51. AtlasLang: Bytecode and the Stack MachineAdvanced≈ 20 min
    52. AtlasLang: Eight Passes and Two GuardsAdvanced≈ 20 min
    53. AtlasLang: What a Language Owes Its UsersAdvanced≈ 20 min
The question this domain answers

What actually happens to my code between the editor and the CPU — and which of it was a choice?

A compiler is not a translation step. It is a sequence of representations, each one built because the previous form could not answer the next question — and every transformation between them is legal only under a precondition someone had to establish. This domain is about those representations, those preconditions, and the design decisions that put them there.

The pipeline every lesson sits on
Source→Lexing→Tokens→Parsing→AST→Semantics→Typed→IR→Optimize→Codegen→Machine code→Link→Execute

Read it as a list of questions rather than a list of steps. Tokens exist because characters cannot say which of them belong together. An AST exists because a token list cannot say what applies to what. IR exists because a tree cannot say in what order things happen. Every arrow is a question the previous box could not answer — and something the new box has thrown away.

Three sentences the whole domain hangs on

If a lesson here ever seems to contradict one of these, the lesson is wrong.

1

A compiler is a sequence of representations, not a translation step. Every phase exists because the previous representation could not answer the next question.

2

An optimization is legal only if it preserves the language's defined observable behavior — so what a compiler may do is decided by language semantics, not by cleverness.

3

"Compiled" and "interpreted" are not properties of languages. They are implementation strategies, and real systems combine them.

This domain is not Runtime Internals, and not Computer Architecture

Both neighbours are close enough to be worth stating the line.

Runtime Internals owns

Object representation, garbage collection, virtual-machine execution, runtime dispatch. What happens while the program runs.

We own

Everything up to the handover, plus the compiler-side half of every runtime mechanism — the metadata emitted, the guard inserted, the state map that makes deoptimization possible.

Computer Architecture owns

The ISA and the microarchitecture. We own the compiler's model of that machine, and the places where the model is deliberately wrong.

Almost nothing here is true of every compiler. Every lesson labels its claims — spec when the standard requires it, implementation when it is one compiler at one version, typical when it is a habit rather than a guarantee, target when it is really about the machine, and simplified when our own model has left something out. A reader who memorises an unlabelled fact will carry it to a language where it is false.

Flagship experiences

The parts of this domain that are not reading.

Learning modules

36 modules, grouped by where they sit on the pipeline.

284 lessons →

Frontend

Source to a checked, structured program.

Grammar & Syntax8

Writing down what a valid program looks like: productions, derivations, EBNF, and the ambiguity that precedence and associativity exist to resolve.

Lexical Analysis8

Characters to tokens, why regular languages are enough for this job, and the hazards — maximal munch, keywords that are also identifiers, numbers that run into letters.

Parsing9

Tokens to structure. Recursive descent and Pratt parsing by hand, LL and LR as families, and what a parser generator buys and costs.

Diagnostics & Error Recovery6

A compiler that stops at the first error is a bad tool. Spans, recovery, synchronization, and diagnostics that name what was expected instead of saying "syntax error".

The Abstract Syntax Tree6

The representation every later phase is written against: node design, traversal, the visitor as the standard shape of a pass, and why the AST outlives the parser.

Semantic Analysis8

Names, scopes and everything the grammar could not express. Symbol tables, shadowing, resolution, and the annotated tree the type checker needs.

Type Systems12

What the language can prove before it runs. Checking, typing rules, environments, inference, unification, polymorphism, subtyping and variance.

Type System Design7

Composing types and representing absence: unions, intersections, algebraic data types, exhaustive pattern matching, nullability and gradual typing.

Types at the Implementation Boundary7

What survives to runtime and what proves memory safety: erasure versus reification, monomorphization, ownership, lifetimes and effects.

Middle-end

A representation you can analyse, and the transformations that are legal on it.

Around all of it

Real pipelines, correctness, tooling, builds — and building your own.

Real Pipelines11

Python, JavaScript, TypeScript, C++, Rust and Go: four genuinely different routes from source to behavior, compared without pretending they are the same.

Compiler Infrastructure9

LLVM as reusable middle-end and code generator rather than "a compiler", GCC as the other one, and WebAssembly as a portable sandboxed target.

Compiler Correctness & Security8

The one program whose bugs are everyone else’s bugs: miscompilation, differential testing, fuzzing, translation validation and formal verification.

Static Analysis & Language Tooling10

The frontend is the IDE. Abstract interpretation, interprocedural analysis, linters, formatters, concrete syntax trees and the language server that serves them all.

Debug Information6

Mapping optimized machine code back to what you wrote — line tables, variable locations, source maps, and why a variable reads as "optimized out".

Compilation at Scale9

Compilation units, modules, interface files and the dependency analysis that keeps a rebuild proportional to the change rather than to the codebase.

Whole-Program & Feedback-Directed Optimization6

Seeing across module boundaries with LTO, and measuring before optimizing with PGO — including what an unrepresentative profile does to the result.

Compilers for Agent Systems5

A model-generated plan is a program in an untrusted language. Parse it, type it, validate it and check its permissions before any of it executes.

AtlasLang9

Build the whole thing, one stage at a time, from `print(1 + 2)` to a typed language with a bytecode VM, an SSA optimizer and a language server.

Reference

For when you already know roughly what you are looking for.