Compilers and Interpreters
A compiler translates a whole program into machine code before it runs, while an interpreter translates and runs it line by line.
▶ Interact
Play with the controls to see the idea in action.
📘 Learn
A compiler translates a whole program into machine code before it runs, while an interpreter translates and runs it line by line.
- Compiled programs run quickly
- Interpreters help find errors
- Assemblers translate assembly language
🧠 Quick quiz
Three questions. Score 2 or more to complete the topic.
What is Compilers and Interpreters?
Within Computer Science, which covers algorithms, programming, data, networks, hardware and safe, responsible use of technology, this topic explains Compilers and Interpreters. Computing topics explain how software, hardware and data work, with diagrams and models that show each step in order.
Check that you can explain Compilers and Interpreters in your own words and give one example from everyday life. If you can do that, you have understood the core idea.
Understanding Compilers and Interpreters helps you design, test and explain programs, websites and systems, from small projects to exam questions.
Compilers and Interpreters in detail
A translator converts high-level code into machine code that the CPU can run. A compiler translates the whole program at once into an executable file, which then runs quickly without the source code, though errors are reported after compilation and the output is specific to a type of processor.
An interpreter translates and runs the code line by line, which makes testing and debugging easier since it stops at the error, but it is slower, as translation happens every time. An assembler translates assembly language. Some languages, such as Java, use a mix: compiled into bytecode and run on a virtual machine.
How the interactive helps you understand Compilers and Interpreters
Click a step, or use the Previous and Next buttons, to move through the sequence one stage at a time. Auto-play moves on for you.
Before you change anything, predict the result. Then change one value at a time and check whether your prediction was right. This is a quick way to build a correct mental model of Compilers and Interpreters.
Real-life uses and examples
- Apply Compilers and Interpreters when you design a small program, website or spreadsheet.
- Explain Compilers and Interpreters to someone new to computing by comparing it to a familiar process.
- Trace through a process that uses Compilers and Interpreters to check what it does step by step.
Common mistakes to avoid
- Testing only the normal case and forgetting the edge cases.
- Using the term without being able to say what the computer actually does.
- Learning the definition without testing it. Use the quiz and the interactive to check that you can apply the idea.
Frequently asked questions about Compilers and Interpreters
What is Compilers and Interpreters?
A compiler translates a whole program into machine code before it runs, while an interpreter translates and runs it line by line.
What are the most important points about Compilers and Interpreters?
The main points are: Compiled programs run quickly; Interpreters help find errors; Assemblers translate assembly language.
Why is Compilers and Interpreters useful?
Understanding Compilers and Interpreters helps you design, test and explain programs, websites and systems, from small projects to exam questions.
How can I practise Compilers and Interpreters?
Open the interactive at the top of this page and change the controls one at a time. Predict the result before each change, then take the three-question quiz. A score of two or more marks the topic as complete on this device.
Which topics are related to Compilers and Interpreters?
Related topics in Computer Science include Introduction to CSS, How the Internet Works, Protocols and TCP/IP.