Compiler vs Interpreter
That these are properties of a language rather than of an implementation, which produces sentences like "Python is interpreted". Every mainstream Python implementation compiles source to bytecode before executing any of it, and there are ahead-of-time compilers for languages usually described as interpreted.
Compiler
When the program is run far more often than it is changed, and startup cost can be paid once at build time.
Interpreter
When the edit-run loop matters more than throughput, or when the program is generated and executed in the same breath.
| Aspect | Compiler | Interpreter |
|---|---|---|
| What it produces | An artifact in another representation — machine code, bytecode, another language. | Behavior. Nothing is left over when it finishes. |
| When errors surface | Everything the analysis models is reported before anything runs. | Errors on a path surface when that path executes, and not before. |
| What it can know | Only what is in the source and the build configuration. | The actual values, which is why an interpreter never has to guess about types. |
| Cost model | Paid once at build, amortized over every run. | Paid on every run, proportional to what is actually executed. |
| Where the boundary blurs | A compiler emitting bytecode has not produced machine code. | An interpreter with a JIT is compiling, at run time, with better information. |
| Failure to watch for | Long builds hiding a fast inner loop of iteration. | A type error in a rarely taken branch reaching production. |