High-level and low-level languages
A CPU can only run machine code: instructions in binary. Programmers usually write in a language that is easier for people, which is then translated.
| High-level languages | Low-level languages | |
|---|---|---|
| Examples | Python, Java, C#, Visual Basic | Machine code (binary) and assembly language (mnemonics) |
| Looks like | English words and maths: if score > 50 | Binary (10110000 01100001) or short codes (LDA 25) |
| One statement | Usually becomes many machine code instructions | Assembly: one instruction becomes one machine code instruction |
| Portability | Portable: the same code runs on different types of computer (with the right translator) | Specific to one type of CPU: won't run on a different processor |
| Writing and debugging | Easier and quicker; easier to read and maintain | Hard and slow; easy to make mistakes |
| Control of hardware | Little: memory is managed for you | Direct: specific memory locations and registers |
| Speed and size | Translated code may be larger and slower | Can be very fast and small |
| Translator | Compiler or interpreter | Assembler (for assembly); machine code needs none |
When to use each
| Use a high-level language when … | Use a low-level language when … |
|---|---|
| Writing most applications: games, websites, apps, business software | Writing device drivers or parts of an operating system that control hardware directly |
| The program must run on different types of computer | Programming embedded systems with very little memory (e.g. a washing machine controller) |
| Development needs to be quick, and the code easy to maintain | Speed is critical and every instruction counts |
| A team of programmers will share the code | The exact memory and registers used must be controlled |