CSS Prepare

optional · CSS study notes

Classification of Compilers

Definition

Compilers can be classified by number of passes over the source, and by the relationship between source/target platforms.

Key Points

  • By number of passes
    • Single-pass compiler: scans source once (e.g., Pascal) — fast, limited optimization
    • Multi-pass compiler: multiple scans, each pass builds on the previous (e.g., most modern compilers) — better optimization, more memory/time
  • By platform relationship
    • Native compiler: generates code for the same machine it runs on
    • Cross compiler: runs on one machine, generates code for another (common in embedded systems)
    • Source-to-source (transpiler): converts one high-level language to another (e.g., TypeScript → JavaScript)
  • By execution model
    • Bootstrap compiler: written in the language it compiles, used to build itself
    • Just-In-Time (JIT) compiler: compiles at runtime, blending compilation and interpretation (e.g., JVM, V8)

Example

  • Cross compiler: compiling ARM firmware code on an x86 desktop
  • JIT: Java HotSpot compiling hot bytecode paths to native code during execution

📌 CSS Frequency: Low-moderate — usually a short definitional sub-part of a broader compiler-types question.

Model Answer (short)

"Compilers are classified by passes (single-pass vs multi-pass) and by platform (native vs cross-compiler vs source-to-source translator). A cross compiler is especially important in embedded systems, where code is compiled on a powerful host machine but targets a resource-constrained device."

📜 Past-Paper Questions & MCQs (CSS 2016–2026)

MCQs

2024 P-I · Q14. A high-level language compiler that runs on one computer and generates code for another is known as:

  • (A) One pass compiler
  • (B) Multipass compiler
  • (C) Cross compiler ✅
  • (D) None of these
  • Answer: (C) Cross compiler.
  • Why: a cross compiler runs on a host machine and produces code for a different target machine (for example building ARM code on an x86 PC). One-pass and multi-pass describe how many times the compiler reads the source, not which machine it targets.