Compiler vs Interpreter vs Assembler
Learn the difference between a compiler, interpreter and assembler for GCSE Computer Science, including what each translates and when a program runs.
A compiler, interpreter and assembler are all translators, but they translate different kinds of code or work in different ways. A compiler and an interpreter work with high-level programming languages. An assembler works with assembly language.
Compiler
A compiler translates a whole program written in a high-level language into machine code before the program runs. Machine code is the instructions a processor can execute. The translated program can then be run without translating the source code again. If the compiler finds an error it cannot translate, the program must be corrected and compiled again.
Interpreter
An interpreter translates and runs a high-level program as it goes, usually one instruction at a time. It does not normally produce a separate machine-code program to run later. If it reaches an instruction with an error, it stops there. Instructions reached before the error may already have run.
For example, imagine a program that displays a message and then reaches a misspelled instruction. An interpreter may display the message before stopping at the mistake. A compiler would report the mistake during translation, before the compiled program could run. This example assumes the first instruction is valid and the error prevents translation.
Assembler
An assembler translates assembly language into machine code. Assembly language uses short instructions that closely correspond to a processor's machine-code instructions. Unlike a compiler or interpreter, the key distinction here is the language being translated.
Exam mistake to avoid: Do not say that an assembler translates a high-level language, or that an interpreter always checks the entire program before anything runs. Remember: compiler = whole high-level program before running; interpreter = translate and run as you go; assembler = assembly language to machine code.