English dictionary, thesaurus, translations & etymology
FreeDict.com

compiler vs interpreter

What's the difference between compiler and interpreter? Here's the clear answer, with examples of each.

Quick answer

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.

Frequently asked questions

Does a compiler run the program itself?
No. A compiler translates the source code into a form the computer can run; a separate step then executes that translated version.
Why might an interpreter be slower than compiled code?
Because an interpreter carries out instructions directly each time the program runs, rather than working from a form that was already translated and optimised in advance.
Can the word compiler mean something other than a programming tool?
Yes, a compiler can also be a person who gathers material from various sources and assembles it into a single work, such as an anthology.
Usage guides: FreeDict original editorial.