Explain how a compiler translates a program
Trace whole-program translation, executable creation and error reporting before execution.
Section 4 · Software
This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. It covers subject content sections 4.1–4.2 only. The separately published 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding.
Before you begin
- No programming language is required. Be comfortable with place value and multiplication; each lesson introduces the computer-science notation it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
Does a compiler translate the whole program or one line at a time?
What you will learn
- Describe whole-program compilation
- Explain how an executable is produced
- Explain how compiler errors are reported
A compiler translates the whole source program
A compiler translates the complete high-level program before execution and produces an executable file. If errors are found, it can report them for the program so the programmer can fix the source and compile again.
Apply and check the rule
Once built, the executable can run without translating each source line anew, though the machine and operating-system requirements still matter. Compilation does not guarantee the program's logic is correct; tests are still needed.
Pause and explain
When does the compiler's executable run?
Worked example
A compiler finds errors in three parts of a source file. What does the programmer usually do next?
Show the worked solution
- Read the compiler's report for the detected errors.
- Correct the source code.
- Compile the whole program again to produce an executable.
Answer Fix the reported source errors and recompile the whole program.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
Put the compiler workflow in order: run executable, translate all source, report errors if found.
Give me a hint
Translation occurs before execution.
Compare my reasoning
- Translate the complete source.
- Report detected errors or produce an executable.
- Run the executable after successful compilation.
Translate all source → report errors or create executable → run executable.
Look for these in your work
- Whole source first
- Error/build result
- Run last
A compiler reports syntax errors in several locations. Why can this help during development?
Give me a hint
Consider what information the report gives before running the program.
Compare my reasoning
- The programmer can review several detected problems.
- They can correct the source and compile again.
- The report does not prove there are no logic errors.
A whole-program report can help fix several detected errors in one edit-and-compile cycle, but testing is still needed for logic errors.
Look for these in your work
- Multiple issues visible
- Correction loop
- Logic limit
A compiled program runs without syntax errors but gives the wrong answer for a valid input. Explain why compilation did not prevent the problem.
Give me a hint
Syntax and logic are different kinds of correctness.
Compare my reasoning
- The compiler checked translation and detected errors it recognises.
- The algorithm may still be logically wrong.
- Testing with suitable inputs is needed to find incorrect behaviour.
Compilation verifies that source can be translated, not that its algorithm produces the right answer. Test behaviour and correct the logic.
Look for these in your work
- Translation role
- Logic error
- Testing need
Common mistakes
- Saying the compiler executes each source line immediately
- Assuming compilation proves the program is logically correct
What can you explain now?
What does a compiler produce after translating a program?
Compare with the explanation
An executable file
Compilation translates the complete source into an executable before it is run.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
What is the compiler's output, and when is it produced?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.