CSS Prepare

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.

BasisCompilerInterpreterAssembler
InputHigh-level language programHigh-level language programAssembly language program
OutputObject or machine code (whole program)No separate output; executes directlyMachine code (object file)
Translation unitWhole program at onceOne statement at a timeOne-to-one: each mnemonic becomes one machine instruction
SpeedFast execution after compilingSlower, because translation repeats on every runFast
ErrorsReported after scanning the whole programReported at the line being executedReported per source line
ExamplesC, C++ compilersPython, JavaScript, BASICNASM, MASM