Menu

Languages

High-level languages

High-level languages are programming languages written to be close to English and to maths. You write them as statements built from readable keywords such as for, def and return, so the code looks like a set of instructions a person can follow.

Each statement does a lot of work. When it is translated, one statement usually turns into many machine code instructions. For example, one statement that works out the average of the values in a list has to load each value in turn, add it to a running total, count how many values there are, divide the total by the count and store the answer — many machine code instructions from the single line you wrote.

One high-level statement, a condition testing whether the total has gone past the limit, is translated by a compiler or interpreter into four machine-code instructions: fetch the total, fetch the limit, compare, jump if true.

Benefits

  • Programs are quicker to write and simpler to read, follow and fix when something goes wrong, because the statements mean something to a person.
  • Fewer lines of code are needed to get a job done.
  • You do not need to know how the processor works — there are no registers or memory addresses to manage.
  • The language already provides built-in features such as lists for storing data and named functions you can call, so many common tasks are solved for you.
  • High-level languages are portable: the code you write is not tied to one type of processor, so one set of instructions can be translated for a completely different make of computer and still work.

Drawbacks

  • You have less direct control over the hardware, so you cannot fine-tune exactly which memory locations or registers are used.
  • A finished program built this way can be slower, and may need more memory, than a carefully written low-level program.
  • Any program written in a high-level language must be translated into machine code before it will run, because a processor only executes machine code.

Despite these drawbacks, high-level languages are used for most general-purpose programming because they are much easier to work with.

Practise this