Runtime · intermediate
Compiler, interpreter, and JIT
A compiler translates a program representation into another representation before later execution; an interpreter directly performs the operations described by a representation; and a just-in-time (JIT) compiler translates code during execution, often using observed runtime behavior. Real implementations commonly combine all three techniques.
Why it matters
The execution pipeline determines startup time, optimization opportunities, portability, debugging behavior, and deployment artifacts. It also replaces the inaccurate idea that each programming language is inherently either compiled or interpreted.
Mental model
How to reason about compiler, interpreter, and jit
Separate source language from implementation stages. Source may be parsed and compiled to bytecode, bytecode interpreted in a virtual machine, and frequently executed regions compiled again into native code by a JIT.
Analogy
A production can translate a script into stage directions ahead of time, have a director perform directions as written, and later rewrite frequently used scenes for faster performance; those are pipeline choices, not properties of the story's language.
Examples
See the boundary, not just the happy path
Worked example · Ahead-of-time object code
clang -c hello.c -o hello.oClang translates the C translation unit into an object file before the finished program executes. Linking and loading remain later stages.
Worked example · Compile then interpret bytecode
python -m dis module.pyCPython normally compiles source into Python bytecode executed by its evaluation loop. Calling Python merely line-by-line interpreted ignores this compilation stage.
Useful contrast · Language is not execution strategy
JavaScript engines can interpret bytecode and JIT-compile hot codeDifferent engines and modes can implement the same language with different combinations of compilation and interpretation while preserving the language specification.
Common mistakes
Misconceptions to remove early
Defining a compiler as source-to-machine-code only
Compilers can target object code, assembly, bytecode, another high-level language, or intermediate representation. Translation stage and target matter more than one fixed output.
Defining an interpreter as executing source one line at a time
Interpreters often execute an AST or bytecode, and statement boundaries need not be source lines. Source can be compiled before any interpreted execution begins.
Quick check
Can you predict the result?
1. Can one runtime both interpret and compile the same program during one execution?
- • Yes; it can interpret an intermediate form and JIT-compile selected regions.
- • No; compilation and interpretation are mutually exclusive language categories.
- • Only if the source contains no functions.
2. Why is interpreted language an unreliable classification?
Keep building