---
title: "Compiler versus interpreter"
subject: "Computer Programming"
chapter: 1
key: "semester_1/computer_programming:compiler-vs-interpreter"
source: https://www.bctengineer.com/q/semester_1/computer_programming/compiler-vs-interpreter
site: BCT Engineering
---

# Compiler versus interpreter

Computer Programming · Chapter 1: Overview of computer software & programming languages

- Asked in: 2071 Chaitra, 4 marks; 2069 Chaitra, 2 marks; 2067 Asoj, 2 marks (asked 3 times)
- Video: [Compiler and Interpreter: Compiled Language vs Interpreted Programming Languages](https://www.youtube.com/watch?v=I1f45REi3k4) — Coding Mentors
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/compiler-vs-interpreter
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-1

## Question

What is compilation? What is interpretation? How do these two processes differ? (Differentiate between compiler and interpreter.)

## Short answer

A compiler translates the whole source program into machine code at once, producing an executable file and reporting all errors after compilation. An interpreter translates and executes one statement at a time without an object file, stopping at the first error and running slower.

## Answer

**Compilation** is the process of translating the whole source program of a high-level language into machine code (object code) in one go, reporting all errors after reading the full program. The translator is called a **compiler**.

**Interpretation** is the process of translating and executing the source program one statement at a time, without producing a separate object file. The translator is called an **interpreter**.

| Compiler | Interpreter |
|---|---|
| Translates the whole program at once | Translates one statement at a time |
| Produces an object/executable file | Produces no object file |
| Execution is fast, since translation is done once | Execution is slow, since it translates every time |
| Shows all errors after compilation | Stops at the first error found |
| Needs more memory for the object code | Needs less memory |
| Debugging is harder | Debugging is easier |
| Examples: C, C++, FORTRAN compilers | Examples: BASIC, Python, JavaScript interpreters |

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Compilation translates
   A. one statement at a time and executes it
   B. only the syntax errors of the program
   C. object code back to source code
   D. the whole source program into object code in one go
   Answer: D. A compiler translates the entire program at once. (Key point: Compilation)

2. How does an interpreter report errors?
   A. It stops at the first error found
   B. It reports all errors after reading the whole program
   C. It never reports errors
   D. It reports errors only at the linking stage
   Answer: A. An interpreter works statement by statement, so it stops at the first error. (Key point: Error reporting)

3. Why is compiled code execution fast?
   A. It translates every statement during each run
   B. Translation is done once, not every time the program runs
   C. It uses no memory
   D. It has no object file
   Answer: B. An interpreter retranslates every time; a compiler translates once. (Key point: Execution speed)

4. Which pair is correctly matched?
   A. Compiler: no object file; Interpreter: produces object file
   B. Compiler: stops at first error; Interpreter: shows all errors
   C. Compiler: produces object file, needs more memory; Interpreter: no object file, needs less memory
   D. Compiler: easier debugging; Interpreter: harder debugging
   Answer: C. Compilers produce an object file and need more memory; interpreters do not. (Key point: Examples and memory)

## Related in Computer Programming

- [Structure versus array](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astructure-vs-array) — Computer Programming, chapter 8, asked 4×
- [High level languages; C versus FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Ahll-types-c-vs-fortran) — Computer Programming, chapter 1
- [Algorithm versus pseudo-code](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgorithm-vs-pseudocode) — Computer Programming, chapter 2
- [Call by value versus call by reference](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Acall-by-value-vs-reference) — Computer Programming, chapter 6, asked 8×
- [do...while versus for/while loops](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Ado-while-vs-for-while) — Computer Programming, chapter 5, asked 2×
- [Text file versus binary file](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Atext-vs-binary-file) — Computer Programming, chapter 10

## Related in other subjects

- [Test: two bulb brands differ in quality](https://www.bctengineer.com/question.md?key=semester_5%2Fprobability_and_statistics%3Alight-bulbs-two-brands-differ-quality) — Probability and Statistics, chapter 6
- [Test: mean weights of two processes](https://www.bctengineer.com/question.md?key=semester_5%2Fprobability_and_statistics%3Abulbs-factory-two-processes-weights) — Probability and Statistics, chapter 6
- [Two-stroke versus four-stroke engines](https://www.bctengineer.com/question.md?key=semester_5%2Fautomotive_technology%3Atwo-stroke-vs-four-stroke) — Automotive Technology, chapter 1
- [Deadlock, postponement, prevention, 2 processes](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Adeadlock-postponement-two-process-three-resource) — Operating System, chapter 7
