EEasy IGCSELabTracker

On a phone the notes, quizzes and tracker work fine. The 3D models and the practice lab are made for a laptop.

Specification points 4.2.1–4.2.5 ·

high-level and low-level languages, assembly language and assemblers, compilers and interpreters, and integrated development environments.

1High-level and low-level languages (4.2.1)

Definition

High-level language — a programming language that uses English-like statements and is independent of the computer's hardware, e.g. Python, Java, Visual Basic. It must be translated into machine code before it can run.

Low-level language — a programming language that relates to the hardware of one particular type of processor: machine code (binary instructions the processor runs directly) or assembly language.

The same task written at each level:

Level Code
High‑level Sum ← FirstNumber + SecondNumber
Assembly language LDA FirstNumber · ADD SecondNumber · STO Sum
Machine code 0001 00010010 · 0100 00010011 · 0000 00011010

One high-level statement usually becomes several machine code instructions (the binary shown is illustrative).

High‑level language Low‑level language
Ease of reading and writing code + English‑like, so easy to read and quick to write – mnemonics or binary are hard to read; programs take longer to write
Ease of debugging code + errors are easier to find and correct – errors are hard to spot and correct
Machine independence + the same program can be translated to run on different types of computer – machine dependent: written for one type of processor
Direct manipulation of hardware – cannot directly control registers, memory addresses or devices + can directly control the hardware
Efficiency – translated code may be larger and run more slowly + can be written to run very fast and use little memory

A programmer chooses a low-level language only when the program must directly manipulate the hardware or be as fast and small as possible (e.g. a device driver or an embedded system); otherwise a high-level language is used.

2Assembly language and the assembler (4.2.2)

Definition

Assembly language — a low-level language that uses mnemonics (short codes such as LDA, ADD, STO) in place of binary machine code instructions.

Assembler — the translator that converts an assembly language program into machine code.

In the example above, LDA FirstNumber loads the value of FirstNumber into the accumulator, ADD SecondNumber adds the value of SecondNumber to it and STO Sum stores the result in Sum. Each assembly instruction usually matches one machine code instruction. The processor can only run machine code, so an assembly program must be assembled before it can run.

3Compilers and interpreters (4.2.3)

A high-level program (the source code) is translated into machine code by a compiler or an interpreter.

Definition

Compiler — translates the whole high-level program at once, before it is executed, producing an executable file of machine code.

Interpreter — translates and executes a high-level program line by line; no executable file is produced.

COMPILER source code — whole program whole program translated in one go before anything is executed no errors errors executable file (machine code) error report for the whole code runs any number of times, without the compiler lists all errors found; no executable file INTERPRETER line 1 translate execute line 2 translate execute line 3 ✗ translate STOP: error line 4 not run execution stops at the error; that error is reported. No executable file — the program is translated again every time it is run.
Figure 1. How each translator works and how it reports errors.

Run it with a compiler, then an interpreter

Loading the interactive…

4Advantages and disadvantages of compilers and interpreters (4.2.4)

Compiler Interpreter
Speed of execution + the executable runs fast: it is already fully translated – slower: each line is translated every time it is run
Running the program + the executable runs without the compiler, so it can be distributed without the source code – the interpreter is needed every time the program runs, and users must be given the source code
Finding errors – errors are only reported after the whole program has been translated + stops at the line with the error, so it is easy to find; an unfinished program can be tested
After each change – the whole program must be recompiled before it can be tested again + the change can be run straight away

So an interpreter is mostly used while developing a program (quick testing and debugging), and a compiler is used to translate the final program for users.

5Integrated development environments (4.2.5)

Definition

Integrated development environment (IDE) — one piece of software that provides the tools a programmer needs to write, translate, run and debug program code.

Program.txt ▶ Run 1 2 3 5 6 7 4 DECLARE Total : INTEGER Total ← 0 FOR Count ← 1 TO 10 Total ← Total + Count NEXT Count OUTPUT "Total is ", Totl OUTPUT Tot Did you mean Total? Total Debugger Paused at line 4Count = 3Total = 3 translators code editor prettyprint auto-correction error diagnostics auto-completion run-time environment
Figure 2. The common functions of an IDE.

Find the IDE tools

Loading the interactive…

  • Code editor — where code is typed and edited, so no separate text editor is needed.
  • Translators — a built-in compiler and/or interpreter, so code can be translated without leaving the IDE.
  • Run-time environment — runs the program inside the IDE so it can be tested, and shows its output; usually with a debugger to run one line at a time or stop at a set point and view variable values.
  • Error diagnostics — highlights errors and reports what and where they are, so they can be found and fixed quickly.
  • Auto-completion — suggests the rest of a keyword or identifier as it is typed, saving time and preventing spelling mistakes.
  • Auto-correction — automatically corrects common mistakes, such as a misspelt keyword.
  • Prettyprint — colour-codes keywords, strings and comments and indents the code, making it easier to read.
Traps
  • Machine code needs no translation. Only high-level and assembly language programs are translated.
  • An interpreter produces no executable file; a compiler does.
  • A compiler reports all the errors found; an interpreter stops at the first error it meets.
  • Machine independence is an advantage of high-level languages; low-level languages are machine dependent.

Quick check

12 multiple-choice questions. Pick an answer to see whether it is right and why.

  1. Which of these can the processor run directly, without translation?

  2. In the instruction ADD SecondNumber, what is ADD?

  3. FirstNumber is 4 and SecondNumber is 9. After LDA FirstNumber and ADD SecondNumber, what does STO Sum do?

  4. Which is an advantage of a high-level language over a low-level language?

  5. Which translator converts an assembly language program into machine code?

  6. What does a compiler produce when it finds no errors?

  7. A four-line program with one error, on line 3, is run with an interpreter. What happens?

  8. The same four-line program, with its error on line 3, is compiled. What happens?

  9. Why does a program run more slowly with an interpreter than as a compiled executable?

  10. A programmer changes one line of a compiled program. What must happen before it can be tested again?

  11. Which IDE function colour-codes keywords and indents the code?

  12. What does auto-completion do in an IDE?

Exam-style questions

Write your answer, then show the answer and compare. Nothing here is marked for you: you decide how close you were. What you write is saved in this browser.

Questions

1

Explain what is meant by a high-level language.

2 marks
2

Give two advantages of writing a program in a high-level language rather than a low-level language.

2 marks
3

A programmer is writing a device driver for a new graphics card. Explain why they might choose a low-level language.

2 marks
4

State what is meant by a mnemonic in assembly language.

1 mark
5

Explain why an assembler is needed.

2 marks
6

Describe how a compiler translates a high-level program and how it reports errors.

4 marks
7

Describe how an interpreter translates a high-level program and how it reports errors.

4 marks
8

Give one advantage and one disadvantage of using an interpreter.

2 marks
9

A company has finished writing a game and will sell it to customers. Explain why it should use a compiler to translate the final version.

3 marks
10

Explain why an interpreter is often used while a program is being developed.

2 marks
11

State three functions of an IDE and explain how each helps a programmer.

6 marks
12

True or false: (a) machine code must be translated before it can run; (b) an interpreter produces an executable file; (c) low-level languages are machine dependent.

3 marks

How well do you know this?

Rate each specification point. It is saved to your tracker as a new revision round.

All points:
  • 4.2.1Explain what is meant by a high-level language and a low-level language, including the advantages and disadvantages of each
  • 4.2.2Understand that assembly language is a form of low-level language that uses mnemonics, and that an assembler is needed to translate an assembly language program into machine code
  • 4.2.3Describe the operation of a compiler and an interpreter, including how high-level language is translated by each and how errors are reported
  • 4.2.4Explain the advantages and disadvantages of a compiler and an interpreter
  • 4.2.5Explain the role of an IDE in writing program code and the common functions IDEs provide

Settings

Your subjects

Untick the subjects you don't take. They leave the menu, the home page and the tracker. Your ratings are kept, so you can bring a subject back at any time.

Page style

Colours