- Practice
- About 13 min
- 5 practice questions
Language translators: compiler, interpreter, assembler
Explain what each language translator does and choose the right one in exam questions.
If something looks wrong, please tell us.
A computer understands only machine language, made of 0s and 1s. Programmers write in easier languages, so a translator is needed. Three translators appear in almost every paper: the assembler, the compiler and the interpreter.
What each translator does
| Translator | Translates | Method |
|---|---|---|
| Assembler | Assembly language to machine code | Converts the whole program |
| Compiler | High-level language to machine code | Translates the whole program at once, then reports all errors together |
| Interpreter | High-level language to machine code | Translates and runs one statement at a time, stopping at the first error |
Language levels
Machine language is the lowest level and runs directly. Assembly language uses short symbolic names (mnemonics) such as ADD. High-level languages use English-like statements and are easier to write and read. High-level and assembly languages are source programs; the translated result is the object code.
Worked examples
Example 1. A program is translated fully before it is run and all errors are listed together. Which translator? A compiler.
Example 2. A beginner wants a program to stop at the exact line where the first error occurs. Which translator helps? An interpreter, because it works line by line.
Compiler = whole program, then run. Interpreter = line by line. Assembler = assembly language only.
Key takeaways: compiler works on the whole program, interpreter works line by line, assembler handles assembly language, and only machine language runs directly.
Check your understanding
-
1. A program is translated fully before it is run, and all its errors are listed together. Which translator is this?
- Interpreter
- Compiler
- Device driver
- Text editor
Show answer
Answer: B. A compiler translates the whole program at once and reports all errors together. An interpreter stops at the first error.
-
2. A beginner wants a program to stop at the exact line where the first error occurs. Which translator helps?
- Compiler
- Assembler
- Interpreter
- Antivirus
Show answer
Answer: C. An interpreter translates and runs one statement at a time, so it stops at the first error.
-
3. Short symbolic names such as ADD, used in assembly language, are called
- Object code
- Pseudocode
- Binary digits
- Mnemonics
Show answer
Answer: D. Assembly language uses short symbolic names called mnemonics, such as ADD.
-
4. The translated result of a source program is called
- Source code
- Pseudocode
- Assembly language
- Object code
Show answer
Answer: D. The program as written is the source program; the translated result is the object code.
-
5. Which language does a computer run directly, without any translator?
- Assembly language
- High-level language
- Pseudocode
- Machine language
Show answer
Answer: D. Only machine language, made of 0s and 1s, runs directly. Assembly needs an assembler; high-level languages need a compiler or interpreter.
Sign in to keep track of the lessons you finish.