Skip to content

Compilers, Interpreters and Assemblers

1.2.2 Applications generation · Paper 1 · 4 flashcards · 6 questions

Definition
A translator is a program that converts high-level source code written by programmers into low-level object code that a computer's CPU can execute.

Compiler

Definition
A compiler translates the entire high-level code into machine code in one go. During this process, the compiler checks the code for errors and reports them back.
Key Point
Compiler Characteristics:
• Translates entire program at once
• Produces standalone executable file
• Execution is fast (no translation during runtime)
• Error reporting happens before execution
• If errors found, must recompile entire program after fixes

Interpreter

Definition
An interpreter translates and executes code line-by-line. If an error is found, the interpreter stops and reports the error immediately.
Key Point
Interpreter Characteristics:
• Translates and executes line-by-line
• No standalone executable produced
• Slower execution (translation happens every run)
• Immediate error detection
• Useful for development and debugging
• Source code must be present to run

Assembler

Definition
An assembler converts assembly language code (low-level language specific to a computer's architecture) into machine code. Each line of assembly typically corresponds to a single machine code instruction.
Key Point
Assembler Characteristics:
• Translates assembly to machine code
• One-to-one correspondence (mostly)
• Allows direct hardware control
• Highly efficient code
• Not portable across different CPU architectures
• Used for system-level programming

Translator Comparison

Key Point
Input
• Compiler: High-level language
• Interpreter: High-level language
• Assembler: Assembly language

Output
• Compiler: Machine code/executable
• Interpreter: Direct execution
• Assembler: Machine code

Execution Speed
• Compiler: Fast
• Interpreter: Slower
• Assembler: Fast

Error Detection
• Compiler: Before execution
• Interpreter: During execution
• Assembler: During assembly

Portability
• Compiler: Compiled for specific platform
• Interpreter: Source portable (needs interpreter)
• Assembler: Architecture-specific

Use Case
• Compiler: Production software
• Interpreter: Development, scripting
• Assembler: System programming
Exam Tip
When to use each:
• Compiler - Production software where speed matters
• Interpreter - Development, testing, scripting languages (Python, JavaScript)
• Assembler - Operating systems, device drivers, embedded systems