optional · CSS study notes
Translators — Compiler vs Interpreter vs Assembler
Definition
A translator converts a program from one language to another. The three core types differ in when and how translation happens.
Key Points
- Compiler: reads the entire source program, translates it fully into target/machine code, then execution happens separately. Errors reported after full scan. Faster execution, slower translation.
- Interpreter: translates and executes line-by-line at runtime, no separate object file produced. Slower execution, immediate feedback, easier debugging.
- Assembler: translates low-level assembly (symbolic mnemonics) into machine code — roughly one-to-one mapping, unlike a compiler's complex high-level-to-low-level mapping.
- Hybrid: some languages (Java, Python) use both — compile to bytecode, then interpret/JIT-compile.
Example
- C/C++ → compiled (gcc)
- Python, PHP shell → interpreted
- 8085 Assembly → assembled
- Java → compiled to bytecode (javac), then interpreted/JIT by JVM
📌 CSS Frequency: Conceptual, asked almost every year as a short/definition-type question (2–5 marks).
Model Answer (short)
"A compiler translates the whole source program into machine code before execution, giving faster runtime but slower initial translation and error detection only after a full scan. An interpreter translates and executes statement-by-statement, giving immediate error feedback but slower execution. An assembler performs a near one-to-one translation of assembly mnemonics into machine code, unlike the compiler's semantic transformation from high-level constructs."
📜 Past-Paper Questions & MCQs (CSS 2016–2026)
2016 · Paper-I · Q7(b) · 5 marks
Q. Compare and contrast compiler, interpreter and assembler.
Ans.
| Basis | Compiler | Interpreter | Assembler |
|---|---|---|---|
| Input | High-level language program | High-level language program | Assembly language program |
| Output | Object or machine code (whole program) | No separate output; executes directly | Machine code (object file) |
| Translation unit | Whole program at once | One statement at a time | One-to-one: each mnemonic becomes one machine instruction |
| Speed | Fast execution after compiling | Slower, because translation repeats on every run | Fast |
| Errors | Reported after scanning the whole program | Reported at the line being executed | Reported per source line |
| Examples | C, C++ compilers | Python, JavaScript, BASIC | NASM, MASM |