Skip to main content

Compiler versus interpreter

Short answer

A compiler translates the whole source program into machine code at once, producing an executable file and reporting all errors after compilation. An interpreter translates and executes one statement at a time without an object file, stopping at the first error and running slower.

What is compilation? What is interpretation? How do these two processes differ? (Differentiate between compiler and interpreter.)

Compilation is the process of translating the whole source program of a high-level language into machine code (object code) in one go, reporting all errors after reading the full program. The translator is called a compiler.

Interpretation is the process of translating and executing the source program one statement at a time, without producing a separate object file. The translator is called an interpreter.

CompilerInterpreter
Translates the whole program at onceTranslates one statement at a time
Produces an object/executable fileProduces no object file
Execution is fast, since translation is done onceExecution is slow, since it translates every time
Shows all errors after compilationStops at the first error found
Needs more memory for the object codeNeeds less memory
Debugging is harderDebugging is easier
Examples: C, C++, FORTRAN compilersExamples: BASIC, Python, JavaScript interpreters

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Programming chapter 1 questions →