Revision Notes
AQA A-Level Computer Science (7517): Types of program translator – Revision Notes
Condensed AQA 7517 section 4.6.3 recall: assembler, compiler and interpreter, source and object code, bytecode, and when to use each, with a self-test.
- Subject
- Computer Science
- Level
- A LEVELS
- Topic
- Fundamentals of computer systems
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to AQA A Level Computer Science (7517), 2015-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): AQA A Level Computer Science.
Syllabus points this page covers
7517
- 4.6.3 Types of program translator
This page covers 1 of the 5 subtopics in topic 6, Fundamentals of computer systems.
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (7517).
Condensed recall for 4.6.3 Types of program translator, AQA A-Level Computer Science (7517). Fuller explanations are in the types of program translator study guide; exam-style questions are in the types of program translator practice questions.
Source and object code
| Term | Meaning |
|---|---|
| Source code | The program as written by the programmer (assembly language or high-level language) |
| Object code (executable code) | The translated machine code that the processor can run |
A translator takes source code as input and produces object code. A processor can only run machine code, so translation is essential.
The three translators
| Translator | Translates | When | Output |
|---|---|---|---|
| Assembler | Assembly language into machine code | Before running | Object code |
| Compiler | A whole high-level program into machine code (or bytecode) | Before running | Object code file |
| Interpreter | A high-level program, one statement at a time | While running | No object code file |
Compiler against interpreter
| Compiler | Interpreter | |
|---|---|---|
| Translation | Whole program first | Statement by statement as it runs |
| Speed of running | Fast (already machine code; can be optimised) | Slower (re-translates statements, for example in loops) |
| Development | Slower: recompile after each change | Faster: run and test immediately |
| Errors | Reported after the whole program is translated; no object code if errors | Stops at the first error, which is easy to locate |
| Source code at run time | Not needed | Needed |
| Source code protected | Yes, if only object code is released | No |
| Portability | Object code only for one processor | Source runs wherever there is an interpreter |
When to use each
- Compiler: finished software to be distributed and run many times; speed matters; source code should be private.
- Interpreter: development and testing; learning; short scripts; running the same source on many types of machine.
- Many programmers interpret while developing, then compile for release.
Bytecode
- Bytecode is an intermediate language: compact, low-level instructions for a virtual machine, not a real processor.
- Some compilers output bytecode instead of machine code.
- It is then run by an interpreter (a virtual machine) on the target computer.
- Why:
- Portability: the same bytecode runs on any machine with a virtual machine, with no recompiling. Only the virtual machine is written for each processor.
- Quicker to run than interpreting source: the checking and much of the translation have already been done.
- Source code is not distributed.
- Compact files.
- Cost: slower than native machine code. Some systems translate hot spots of bytecode into machine code at run time.
Sequence: source code, then compiler, then bytecode, then virtual machine on each computer.
Worked scenarios
| Situation | Translator | Reason |
|---|---|---|
| A student testing a short Python program many times | Interpreter | Immediate run, errors pointed to the statement |
| A commercial video game released to customers | Compiler | Fast execution; source code hidden |
| A program that must run on phones, PCs and tablets without separate versions | Compiler to bytecode plus a virtual machine on each device | Portability |
| A hand-written routine in assembly language | Assembler | Assembly language needs an assembler |
Features of compiled code to remember
- Translated once; can be run many times without the compiler.
- Runs quickly and can be optimised.
- Specific to the type of processor. Another processor means recompiling with a different compiler.
Features of interpreted code to remember
- Must have the interpreter installed on every machine.
- Repeated statements are translated again each time round a loop.
- Good for debugging, because the program can be run and altered quickly.
Quick contrasts to learn
- Once against every time: a compiler pays the translation cost once; an interpreter pays it every run.
- Developer against user: the compiler’s work is done by the developer; the interpreter’s work is done on the user’s machine.
- Error timing: a compiler finds syntax errors before the program runs at all; an interpreter finds them when execution reaches the faulty statement.
Exam traps
- Compiler “line by line”. That is an interpreter.
- Interpreted code faster. It is slower.
- Source and object code swapped.
- Compiled code portable. The object code is specific to a processor.
- Bytecode called machine code. It needs a virtual machine.
- One-sided comparison. State points for both translators.
Key terms
| Term | Definition |
|---|---|
| Translator | A program that converts a program from one language into another |
| Assembler | Translates assembly language into machine code |
| Compiler | Translates a whole high-level program into object code before it runs |
| Interpreter | Translates and executes a program one statement at a time |
| Source code | The program written by the programmer |
| Object code | The translated, executable machine code |
| Bytecode | An intermediate language run by a virtual machine |
| Virtual machine | Software that executes bytecode on a real computer |
Self-test
- What does an assembler translate?
- What does a compiler produce?
- Why can a compiled program run without the compiler?
- Why do interpreted programs run more slowly?
- Why is an interpreter useful during development?
- State two reasons for producing bytecode.
- What runs bytecode?
- Why is compiled object code not portable between types of processor?
- Which translator would you use for a program that is released to the public and must run fast?
- What is the difference between source code and object code?
Answers
- Assembly language into machine code.
- Object code (machine code, or bytecode in some cases) as a separate file.
- The object code is already machine code that the processor can execute directly.
- Each statement is translated every time it is executed, including each time round a loop.
- The program can be run and tested at once after a change, and an error is reported against the statement that caused it.
- Any two: portability; faster than interpreting source code; source code not distributed; compact.
- A bytecode interpreter (virtual machine).
- It contains the instructions of one processor’s instruction set, which other processors do not understand.
- A compiler.
- Source code is the program as the programmer wrote it; object code is the translated machine code that the processor runs.
More resources on this topic
Related resources
-
Study guides
AQA A-Level Computer Science (7517): Boolean Algebra
Deeper guide to AQA 7517 section 4.6.5 Boolean algebra: identities, De Morgan's laws and step-by-step simplification of Boolean expressions.
Computer Science · AQA · A Level
Read guide -
Practice questions
AQA A-Level Computer Science (7517): Boolean Algebra – Practice Questions
Original AQA 7517 section 4.6.5 questions with answers: Boolean identities, De Morgan's laws and simplifying expressions step by step.
Computer Science · AQA · A Level
Try questions -
Revision notes
AQA A-Level Computer Science (7517): Boolean Algebra – Revision Notes
Condensed AQA 7517 section 4.6.5 recall: Boolean identities, De Morgan's laws, a simplification method, common slips and a self-test.
Computer Science · AQA · A Level
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.