A compiler takes the whole of a program's source code and turns it into a form the computer can run directly, checking the code makes sense as it goes; an interpreter instead reads and carries out a program's instructions directly, without compiling it first. A useful example: the Python interpreter executes a script one line at a time, while a compiler processes the entire program before anything runs.
The core difference
A compiler translates the whole program before running it; an interpreter carries out the program's instructions directly, without a separate translation step.
- compiler — a program that turns source code into a form a computer can run, checking the rules of the language as it goes: the compiler refused to build the project because of a missing semicolon.
- interpreter — a program that reads and carries out another program's instructions directly, without compiling it first: the Python interpreter executes the script one line at a time.
How to tell them apart
The difference is in when the work happens. A compiler does its translation up front, producing a runnable form of the whole program before execution starts; if there is an error, it can refuse to build the project at all. An interpreter works through the code as it runs, so it carries out each instruction directly rather than translating everything in advance.
Interpreter also has an everyday meaning outside computing: a person who translates spoken or signed language for others in real time, such as in a courtroom. Compiler, too, has a non-computing sense, describing someone who gathers material from various sources into a single work, like an anthology or reference book.