Compilers

Which correctly distinguishes a compiler from an interpreter?

  1. AA compiler translates before running; an interpreter executes while reading
  2. BA compiler translates line by line while running; an interpreter translates everything before running
  3. CA compiler handles only numeric computation, and an interpreter only text processing
Show answer and explanation

Answer: A. A compiler translates before running; an interpreter executes while reading

A compiler translates an entire program to machine code or similar before execution and then runs the result. Translation takes time, but execution is faster and optimization can be thorough. An interpreter reads and executes the program as it goes, so it is quick to try but tends to run slower. In practice many systems combine the two, translating to bytecode, interpreting it and JIT-compiling hot parts. They are not distinguished by the kinds of tasks they handle.

  • A. Correct. The difference is translating beforehand versus executing while reading.
  • B. The description is reversed.
  • C. They are not distinguished by the kinds of tasks handled.
Practice this topic Back to topic

More Compilers questions

  1. Which describes a runtime that uses JIT compilation?
  2. Which describes the basic structure of LLVM?
  3. When is the no-optimization setting of a compiler (such as -O0) commonly used?
  4. Which describes profile-guided optimization (PGO)?
  5. Which optimization does link-time optimization (LTO) make possible?