Lessons in this course (11)

10. Compilers, interpreters, JIT and AOT

IntermediateMediumLesson 10 of 11
ModelHowExamplesTrade-off
Ahead-of-time compiledSource → machine code before runningC, C++, Rust, Go, .NET Native AOTFast start, platform-specific binary
InterpretedInterpreter executes source/bytecode line by linePython (bytecode VM), classic JavaScript, PowerShellPortable, slower
Bytecode + JITCompile to intermediate code; at runtime compile hot methods to machine code.NET (IL → RyuJIT), Java (bytecode → HotSpot), JavaScript V8Portable + fast after warm-up, startup cost

Compiler stages: lexing (characters → tokens) → parsing (tokens → syntax tree) → semantic analysis (types, symbols) → optimisation → code generation. The C# compiler Roslyn does these to produce IL; the JIT then turns IL into machine code for the actual CPU (x64 or ARM64), with tiered compilation (quick code first, optimised code for hot methods).