GGCSE Revision Hub

3.4.4 Classification of programming languages and translators

AQA Computer Science 8525Topic 3.4 — Computer systemsFoundation & Higher

This topic is about the machine itself: what it is made of, how it thinks in ones and zeros, what software runs on it, and how the hardware inside it works. It is where the ideas of the data representation topic meet physical components — a bus carries the bits, a register holds them, the clock times them. Much of this topic is definitional, and exam questions reward precise terms, so learn the vocabulary and then the reasoning behind it.

What you need to know

Low level and high level

Know that there are different levels of programming language: low-level and high-level. Most computer programs are written in high-level languages, and that is because a high-level language is closer to English, so it is quicker to write and easier to get right. The trade-off is that the computer has more work to do to turn it into something it can run.

Key fact: Most programs are written in high-level languages because they are quicker to write and easier to get right.

Machine code and assembly language

Machine code and assembly language are both low-level languages. Processors execute machine code, and each type of processor has its own specific machine code instruction set — so machine code written for one processor will not run on a different one. Assembly language is often used to develop software for embedded systems and for controlling specific hardware components, and it has a 1:1 correspondence with machine code: each assembly instruction becomes exactly one machine code instruction.

Key fact: Machine code is processor-specific; assembly language has a 1:1 correspondence with machine code.

Why low level is used at all

The advantage of low-level languages is control and efficiency. Because assembly maps so closely onto the processor, you can produce code that is very small and very fast, and you can drive particular hardware directly — which is why it is used in embedded systems. The disadvantages are that it is extremely hard to write, it takes a long time, and it is tied to one processor.

Key fact: Low-level code is small, fast and precise, but it is slow to write, hard to read and tied to one processor.

The three translators

There are three common types of program translator: interpreter, compiler and assembler. Assemblers and compilers translate their input into machine code directly, and each line of assembly language is assembled into a single machine code instruction. Interpreters do not generate machine code directly; they call appropriate machine code subroutines within their own code to carry out statements.

Key fact: Three translators: interpreter, compiler and assembler. Assemblers and compilers produce machine code; interpreters do not.

Interpreter against compiler

A compiler translates the whole program at once, before it runs, and produces an executable that can be run many times without translating again. An interpreter works through the program line by line while it runs, so there is no separate executable, but the translation happens every time. That makes compilers faster to run and interpreters better for debugging, because the error is found at the point it happens.

Key fact: A compiler translates everything first and produces an executable; an interpreter translates line by line as it runs.

When to use each

Understand when it would be appropriate to use each type of translator. Use an assembler for assembly language, since that is its only possible translator. Use a compiler for high-level languages when you want a fast standalone program, which is how most commercial software and games are produced. Use an interpreter for teaching, scripting and debugging, because you can step through the code and change a line and run it again immediately.

Key fact: Assembler for assembly, compiler for a fast standalone program, interpreter for teaching and debugging.

Flashcards

Exam questions

Written in the style of AQA Computer Science, with a mark scheme for each one. No question here is a real past paper question.

mcq1 mark

Which statement about the relationship between assembly language and machine code is correct?

  • Assembly language is a high-level language
  • Machine code is processor-independent
  • Each line of assembly language becomes a single machine code instruction
  • An interpreter is needed to translate assembly language

Mark scheme: 1 mark for identifying the 1:1 correspondence between assembly language and machine code. Assembly language is low-level, machine code is specific to each processor, and assembly language is translated by an assembler.

short3 marks

Explain in English the difference between an interpreter and a compiler, and give one situation in which each would be chosen.

Mark scheme: 1 mark for stating that a compiler translates the whole program at once and produces machine code or an executable, while an interpreter translates and runs it line by line as it runs. 1 mark for explaining the practical consequences, that a compiled program runs faster and an interpreted one is easier to debug. 1 mark for giving a correct situation for each, such as a compiler for a commercial game and an interpreter for a lesson in programming.

six6 marks

Explain in English the differences between low-level and high-level languages and between the three types of translator.

Mark scheme: Level 1 (1-2 marks): A short answer saying low-level languages are close to the machine and high-level ones are close to English. Level 2 (3-4 marks): A structured answer covering machine code, assembly language and the three translators. Level 3 (5-6 marks): A detailed answer explaining that machine code is processor-specific and assembly language has a 1:1 correspondence with it and is used for embedded systems, explaining that high-level languages are quicker to write but slower to run, describing how a compiler translates the whole program at once and produces an executable while an interpreter works through it line by line without producing machine code directly, describing the assembler as the only translator that can deal with assembly language, and giving a justified situation for each.

Other sections in this topic

Practise these questions

Answer them in the interactive view and they get marked against the same mark scheme, one mark at a time, with the reason for each mark.

Open the interactive topic →