Programming

What is the difference between a compiler and an interpreter?

Short answer

A compiler translates an entire program into machine code before it runs, while an interpreter translates and executes code line by line, as the program runs.

Both are ways of turning human-readable source code into instructions a computer can execute, but they work differently.

Compiled languages

Languages like C, C++, and Rust are typically compiled — the whole program is translated into a standalone executable file ahead of time. This usually makes the final program run faster, but you need to recompile after every code change, and errors are caught all at once before running.

Interpreted languages

Languages like Python and JavaScript are typically interpreted — the interpreter reads and executes code one line at a time, without a separate compile step. This makes development faster to iterate on, since there's no build step, though execution is often slower than compiled code.

Many modern languages blur the line — Java compiles to intermediate bytecode that's then interpreted (or further compiled) by a virtual machine, and JavaScript engines use "just-in-time" compilation to speed up interpreted code while it runs.

Last reviewed: September 2026