Menu

Languages

Benefits and drawbacks of low-level languages

Low-level languages – assembly language and machine code – work at the level of the instructions the processor actually carries out. That closeness brings real advantages, but it asks a great deal of the programmer.

Benefits of low-level languages

  • Direct control over the hardware. You choose exactly which memory locations and registers hold each value, rather than leaving those decisions to something else.
  • Speed and size. Because you pick every instruction yourself, you can optimise a program to run as fast as possible or to use as little memory as possible, whichever matters more.
  • No translation for machine code. Machine code is already in the form the processor executes, so it runs straight away without being converted first.

For example, the routine that redraws a game screen sixty times a second might be written at a low level, so that each frame is finished before the next one is due. A low-level program can also be trimmed byte by byte to squeeze into a tiny memory limit, where a translated high-level version would not fit.

Drawbacks of low-level languages

  • Slow and fiddly to produce. Writing code, working out what an existing program does and tracking down mistakes all take much longer than with a high-level language: each instruction does one tiny job, so even a simple task becomes a long list of them, and there are no readable statements to skim when you are hunting for a bug.
  • You need detailed knowledge of the processor. You must understand its registers, its instruction set and how memory is laid out before you can write anything useful.
  • Not portable. Each type of processor understands its own set of instructions, so code built for one chip will not run on another and must be rewritten for the new chip.

That is why low-level languages are used only when their benefits are essential: where memory is very limited, or where part of a program must run as fast as possible. For most other work, the ease of a high-level language is worth more than the control you give up.

Practise this