📚 Knowledge Library — Topic 4.5 — Software

Translators Explained Simply

Learn why programs need to be translated into machine code, and understand the difference between a compiler, interpreter and assembler.

1. Invitation

The CPU only understands machine code.

Humans usually write programs using high-level languages because they are easier to read and write.

The problem is simple: the processor does not understand high-level code. It only understands machine code.

💡 Remember: a translator converts program code into machine code the CPU can execute.
Figure 1.1
Why Translation Is Needed
Human-friendly code

Translator

Machine code
2. Big Idea

A translator changes one programming language into another.

A translator is software that converts source code into machine code.

This lets a program written by a programmer become instructions that the computer hardware can actually process.

💡 Key idea: source code goes in, machine code comes out.
Figure 2.1
Source Code to Machine Code
Source code

Translator

Machine code

CPU
3. FutureLogic Bridge

Think of a book translator and a live interpreter.

A compiler is like translating an entire book before anyone reads it.

An interpreter is like a live translator who translates one sentence at a time and stops if something does not make sense.

💡 Bridge: compiler = whole book first. Interpreter = one sentence at a time.
Figure 3.1
Translation Bridge
Compiler
whole program

+

Interpreter
line by line
4. Worked Example

A Python-style program must be translated before the CPU can run it.

A programmer might write an instruction such as:

score = score + 1

This is readable to a human, but the processor needs machine code. A translator converts it into instructions the CPU can execute.

Simple example

High-level code
Translator
Machine code
Model answer: "A translator converts source code into machine code so it can be executed by the CPU."
Figure 4.1
Program Flow
score = score + 1

translator

CPU instructions
5. Compiler

A compiler translates the whole program at once.

A compiler translates the entire program before it is executed.

It creates an executable file. Once this file exists, the program can run without the source code or compiler being present.

💡 Compiler = translates all the code first, then the program can run.
Figure 5.1
Compiler Model
Whole program

Compiler

Executable file
6. Interpreter

An interpreter translates and runs one line at a time.

An interpreter translates and executes the program one statement at a time.

If it finds an error, it stops at that point. This makes it useful during development and debugging.

💡 Interpreter = line by line, stops when an error is found.
Figure 6.1
Interpreter Model
Line 1

Translate + run

Line 2

Translate + run
7. Assembler

An assembler translates assembly language.

An assembler is the translator used for assembly language.

Assembly language uses short codes called mnemonics, such as ADD or MOV. The assembler converts these into machine code.

💡 Assembler = assembly language into machine code.
Figure 7.1
Assembler Model
ADD
MOV
LDA

Assembler

Machine code
8. Compare Them

Three translators, three jobs.

Each translator has a different purpose. The exam often checks whether you can match the correct translator to the correct situation.

TranslatorMain job
CompilerTranslates the whole program and creates an executable file
InterpreterTranslates and executes one line at a time
AssemblerTranslates assembly language into machine code
Figure 8.1
Quick Memory Hook
Compiler
whole program

Interpreter
line by line

Assembler
assembly only
9. Exam Tip

Read whether the question asks how or when.

Cambridge often asks when it is best to use a compiler or interpreter. That is different from asking how it works.

Use an interpreter during development because it helps find errors. Use a compiler when the program is finished and ready to distribute.

🎯 Exam Tip: "when" questions need a stage and a reason — not just a definition.
Figure 9.1
How vs When
HOW?
what it does



WHEN?
development or distribution
10. Common Mistake

Do not give a how answer to a when question.

Students often know the translator, but answer the wrong question.

⚠️ Common Mistake:

Question: "When is it most appropriate to use an interpreter?"

Student answer: "It translates one line at a time."

❌ This describes how it works, but not when to use it.

Better answer: "An interpreter is most appropriate during development because it stops when an error is found, making the program easier to debug."
Figure 10.1
Better Exam Wording
Weak answer
line by line



Better answer
during development
because debugging
11. Summary

Translators in one screen.

A translator converts source code into machine code so the CPU can execute the program.

A compiler translates the whole program and creates an executable file. An interpreter translates and executes one line at a time. An assembler translates assembly language.

💡 Key idea: computers run machine code, so most programs must be translated first.
Figure 11.1
Translator Summary
Compiler
Interpreter
Assembler

Machine code

CPU