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."