FREE LESSON · Languages & compilers · 3 OF 4

Compiler vs Interpreter vs JIT

Many roads to execution — Compilers, interpreters, VMs, and JITs

Translation time is a design choice, not a binary category.

A native compiler can optimize ahead of time into target instructions. An interpreter can execute a syntax tree or bytecode step by step. A virtual machine defines a portable instruction set. A just-in-time compiler observes running code and compiles hot paths using runtime facts, with warm-up and deoptimization costs.

Move work earlier for predictable startup; move it later to exploit runtime evidence.

Optimization must preserve observable meaning

Constant folding can replace 3×7 with 21; dead-code elimination can remove work whose result is unobservable; inlining exposes cross-function opportunities. But exceptions, I/O, timing contracts, concurrency, and language rules constrain what counts as unobservable. Faster wrong code is not an optimization.

Every optimization is a semantics-preservation argument under stated assumptions.
Open this lesson in the interactive course →