Skip to the page
Year 10 · Computer Science · Summer 1 · Software

Languages and translators

What this lesson covers

4.2 Types of programming language, translators and IDEs

Cambridge IGCSE Computer Science 0478 · Topic 4: Software · Paper 1

You will learn to

  • Compare high-level and low-level languages, with one advantage and one disadvantage of each.
  • Explain what assembly language and mnemonics are, and what an assembler does.
  • Compare how a compiler and an interpreter translate a program.
  • Explain when a compiler is the better choice, and when an interpreter is.

Success criteria

  • I can give one reason a programmer might still write in a low-level language.
  • I can say what an assembler does in one sentence.
  • I can complete a compiler-versus-interpreter table in mark-scheme words.
The syllabus points for this section
  • Explain the difference between high-level and low-level languages, with advantages and disadvantages.
  • Explain what assembly language and mnemonics are, and what an assembler does.
  • Compare how a compiler and an interpreter translate a program.
  • Say when a compiler or an interpreter is the better choice.
  • Describe the common features of an IDE.

Key words

Say each word, then read what it means. Every one is in the glossary too.

System software
Software that runs and manages the computer, such as the operating system and utilities.
Device driver
A small program that lets the OS communicate with one particular device.
High-level language
A programming language close to English, which works on many types of processor.
Low-level language
A language close to machine code, written for one type of processor.
Machine code
Binary instructions that the processor can run directly.
Assembly language
A low-level language that uses mnemonics; each line matches one machine code instruction.
Mnemonic
A short, easy-to-remember code for a machine instruction, such as LDA or ADD.
Assembler
A translator that turns assembly language into machine code.
Compiler
A translator that turns the whole high-level program into machine code at once and creates an executable file.
Interpreter
A translator that translates and runs a high-level program one line at a time.
Executable file
A file of machine code that can run on its own, without the source code or translator.
IDE
Integrated development environment: one program with the tools to write, translate, run and debug code.

The explanation

Read it here, or open the study page below to go one step at a time with things to try.

High-level and low-level languages

The processor only understands machine code: binary instructions such as `10110000 01100001`.

A low-level language is close to machine code. It is written for one type of processor. Machine code and assembly language are low-level.

A high-level language is close to English and maths. Python, Java and Visual Basic are high-level. One line of high-level code becomes many machine code instructions.

High-level languageLow-level language
Easy to read, write and debug?Yes: uses English-like wordsNo: hard to read and follow
Runs on different processors?Yes: portable (machine-independent)No: written for one processor (machine-dependent)
Control of hardwareLittle direct controlDirect control of memory and registers
Speed and memoryMay be slower and use more memoryCan be very fast and compact
Needs translating?Yes, by a compiler or interpreterAssembly needs an assembler; machine code needs nothing
Typical useMost apps, websites, gamesDevice drivers, embedded systems, very fast code
?Why?

High-level languages save programmers time and reduce mistakes. Low-level languages are used when every byte and every microsecond matters, for example in a washing machine's chip.

!Watch out

"Low-level" does not mean "worse". It means "close to the hardware".

Assembly language and mnemonics

Assembly language is a low-level language. Each instruction matches one machine code instruction.

Instead of binary, it uses short codes called mnemonics. A mnemonic is a few letters that are easy to remember, such as `LDA` for "load" or `ADD` for "add".

Assembly lets the programmer work directly with memory addresses and the accumulator (ACC) register.

LDA 20    // copy the number at memory address 20 into the ACC
ADD 21    // add the number at address 21 to the ACC
STO 22    // store the ACC into address 22
END       // stop

If address 20 holds 7 and address 21 holds 5:
after LDA 20  ACC = 7
after ADD 21  ACC = 12
after STO 22  address 22 holds 12
# The same job in one high-level line
c = a + b
?Why?

Assembly is easier for humans than binary but still gives full control of the processor. That is why it is used for device drivers and small embedded systems.

!Watch out

The exact mnemonics change between processor types. In the exam, you will not need to learn a set; you need to know what a mnemonic is.

The assembler

The processor cannot run assembly language directly. It must be translated into machine code first.

An assembler is the translator for assembly language. It turns each mnemonic into its matching binary instruction.

Because one assembly line equals one machine code instruction, assembling is a simple one-to-one translation.

e.g.Example
LDA 20 → assembler → 0001 0100 (made-up example code) ADD 21 → assembler → 0011 0101 The binary values depend on the processor's instruction set.
?Why?

Each processor has its own instruction set, so each needs its own assembler.

Translators for high-level languages: the compiler

A translator turns source code (the code a person writes) into machine code. There are three types: assembler, compiler and interpreter.

A compiler translates the whole program in one go, before it runs.

If there are errors, it lists all of them at the end in an error report. The program will not run until every error is fixed.

When there are no errors, it produces an executable file (for example a `.exe`). This file can run again and again without the compiler and without the source code.

e.g.Example
A games studio finishes a game. They compile it once into an executable. Players download and run the executable. Players never see the source code, and they do not need a compiler.
?Why?

Translation happens once, so the finished program runs fast. Keeping the source code hidden also protects the company's work from being copied.

Translators for high-level languages: the interpreter

An interpreter translates and runs the program one line at a time.

It reads line 1, translates it and runs it. Then it moves to line 2, and so on.

When it meets an error, it stops at that line and reports it. The lines before the error have already run.

It does not create an executable file. The program must be translated again every time it runs, so the interpreter must be present every time.

e.g.Example
A student runs a Python program with a typing mistake on line 3. Lines 1 and 2 run and show their output. At line 3, the interpreter stops with an error message naming line 3. The student fixes it and runs again.
?Why?

Stopping at the exact line makes it easy to find and fix mistakes. That is why interpreters are used mainly while a program is being developed.

Compiler or interpreter? Compare them

Try the translators toy. The same program has an error on line 3. Run it with the compiler, then with the interpreter. Notice which lines run before you see the error.

In the exam, give the point for both sides when you compare, for example "a compiler translates the whole program at once, whereas an interpreter translates one line at a time".

CompilerInterpreter
How it translatesWhole program at onceOne line at a time, then runs that line
ErrorsLists all errors at the end; nothing runs until all are fixedStops at the first error; earlier lines have already run
OutputCreates an executable fileNo executable file
Running againRun the executable; no translation neededMust translate again every time
Speed when runningFastSlower, because each line is translated as it runs
Needed by the user?No: users only need the executableYes: the interpreter must be on the user's computer
Source codeCan be kept secretMust be given to the user
Best used forThe finished program, ready to sell or shareDevelopment and debugging
!Watch out

A compiler does not "run" the program. It only translates it. The executable runs afterwards.

There is something to try for this step in the IGCSE library.

The IDE: a programmer's toolbox

An IDE (integrated development environment) is one program that holds all the tools for writing, translating and testing code. Examples are IDLE, Thonny, Visual Studio Code and PyCharm.

Cambridge lists seven features. Learn each one with what it does for the programmer.

IDE featureWhat it doesWhy it helps
Code editorA text area for typing and editing source code, often with line numbersCode can be written, saved and changed in one place
Run-time environmentLets the program run inside the IDE, often with tools to step through it line by line and watch variablesYou can test and see the program working straight away
TranslatorsA built-in compiler and/or interpreterNo need to use a separate program to translate code
Error diagnosticsHighlights errors, says which line and what type, and may suggest a fixErrors are found and fixed faster
Auto-completionSuggests the rest of a keyword or variable name as you typeSaves typing and avoids spelling mistakes in names
Auto-correctionAutomatically fixes some typing mistakes, such as a misspelt keywordFewer small errors stop the program
PrettyprintShows keywords, strings and comments in different colours and adds tidy indentationCode is easier to read and mistakes stand out
e.g.Example
Typing in Thonny: You type `pri` and the IDE offers `print` (auto-completion). You forget a closing bracket and the line is underlined in red (error diagnostics). `print` shows in one colour and the text in quotes in another (prettyprint).
!Watch out

Auto-completion and auto-correction are different. Auto-completion suggests what comes next. Auto-correction changes a mistake you already typed.

Study it

Open the study page and go one step at a time.

The steps for this lesson

Try it

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.