GCSE · Computer Science · Eduqas · Spec C500QS

Compilers

You press Run and nothing appears. Not even the first line. The mistake is on the very last line, so why did the whole program refuse to start?

Computer Science · Translators

Press Run, then watch the translator go first

This short program should print three lines and then the total of 4 + 3. Press Run and read what comes back. If something is wrong, choose the fix that makes it work.

In the result, the first line shows the translation finishing. The lines after it are what the program printed once the executable ran.

Example high-level language
  1. print("Welcome to the quiz")
  2. total = 4 + 3
  3. print("Adding up...")
  4. print("Total:")
  5. print(total

Illustrative: the messages are written for this lesson, not copied from a real compiler. Real translators word their messages differently.

Why a compiler?

?

Reason it through

Why does a high-level program need a compiler at all?

Link 1 of 4

First link · your turn

Start with the processor. What kind of instructions can it execute?

2
Locked — reveal the link above first
3
Locked — reveal the link above first
4
Locked — reveal the link above first

Computer Science · Order of events

The life of a compiled program

the order things happen in, for a compiled program

1 · Happens first5 · Happens last
  1. A machine-code executable is produced

  2. The same executable is run again, with no new translation

  3. Source code is written in a high-level language

  4. The executable is run

  5. The whole program is translated by the compiler

Computer Science · What do you think?

Which idea is closest to yours?

A friend has just compiled a program and then run it. They are explaining to you what the compiler did.

Which of these is closest to what you think a compiler does?
How sure are you?

Computer Science · Have a go

Write it in your own words

Describe what a compiler does and when it does it. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

How a whole program gets translated into machine code before it ever runs

What you need to know

  • A compiler is a translator: a program that converts program code from one language into another.
  • Your processor is fussy. It can only execute machine code, which is binary instructions.
  • So a program written in a high-level language must be translated into machine code before it can be executed.
  • Have a goPicture the processor as someone who only speaks machine code, and your program as a speech in another language. What job does a compiler do here?

    It is the translator: it converts the program into machine code for the processor.

    The processor can't use your high-level program as written, so a translator has to convert it into the one form it can execute.

  • The compiler's job: turn source code in a high-level language into machine code (object code) the processor can execute.
  • It translates the whole program in one go, not one statement at a time.
  • Have a goRavi is very sure that a compiler translates one statement at a time as it goes. He is also wrong. What do you tell him?

    It translates the whole program in one go, not one statement at a time.

    Translating bit by bit is the tempting picture, but a compiler works through the whole program in one go.

  • It does this before the program is run: compile first, then execute the machine code.
  • What comes out is a machine-code version of the program, called an executable.
  • That executable can be run again and again without being translated again.
  • Have a goA program is compiled once, then the executable is run 5 times with no edits. How many times has it been translated?

    Once.

    The executable can be run again and again without being translated again, so extra runs add executions, not translations.

The big picture

A compiler is a translator that converts a whole program written in a high-level language into machine code before the program runs. The processor can only execute machine code, and the executable the compiler produces can be run again and again without being translated again.

Key points

1A compiler is a translator: high-level source code goes in, machine code comes out.
2The processor can only execute machine code, which is why the translating has to happen at all.
3The whole program is translated in one go, before it is run.
4The executable that comes out can be run again and again with no new translation.

Worked example

Problem

Mia compiles her program and runs it on Monday. On Tuesday she changes one line of the source code. What must she do before the changed program can run, and why can't she just run Monday's executable again?

⚠ Watch out

Thinking the compiler runs the program, or translates it a statement at a time while it runs. It does neither: it translates everything first, and then the processor executes the machine code it made.

🧠

Memory hook

Compile first, run after. C comes before R, and in a compiled program the translating comes before the running.

✓

Check yourself

A friend says, "The compiler runs my program." Say what is wrong. Check: it translates the whole program into machine code first; the processor then executes that.

Flashcards

(8)
What is a compiler?
A type of translator: a program that converts program code from one language into another.
What is the only kind of code a processor can execute?
Machine code (binary instructions).
What goes into a compiler, and what comes out?
In: source code written in a high-level language. Out: machine code (object code) that the processor can execute.
Does a compiler translate the whole program or one statement at a time?
The whole program, in one go.
When does a compiler do its translating?
Before the program is run. The program is compiled first, then the machine code is executed.
What is the output of a compiler?
A machine-code (executable) version of the program.
You run an executable a second time. Is it translated again?
No. It can be run repeatedly without being translated again.
What is object code?
Another name for the machine code a compiler produces from the source code.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 16 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.