Detailed · Deep study
1High-level and low-level languages
A programming language that uses English-like words and is independent of the computer hardware, e.g. Python, Java.
A programming language that relates closely to the instruction set of a particular CPU: machine code or assembly language.
| High-level | Low-level | |
|---|---|---|
| ease of reading and writing | easier: English-like statements; one statement does many machine operations | hard to read and write; many instructions needed |
| ease of debugging | easier to find and correct errors | harder to debug |
| machine independence | portable – can run on different types of computer (after translation) | written for one type of CPU |
| direct manipulation of hardware | cannot usually manipulate hardware directly | can control registers and memory directly; programs can be faster and use less memory |
| translation | needs a compiler or interpreter | assembly needs an assembler; machine code needs none |
2Assembly language
Assembly language is a low-level language that uses mnemonics – short codes such as LDA (load), ADD, STO (store) and JMP (jump) – in place of binary machine code. Each mnemonic usually matches one machine code instruction. An assembler is needed to translate an assembly language program into machine code.
LDA 20 ; load the value at address 20 into the accumulator
ADD 21 ; add the value at address 21
STO 22 ; store the result at address 223Compilers and interpreters
| Compiler | Interpreter | |
|---|---|---|
| translation | translates the whole code at once, before executing it | translates and executes the code line by line |
| output | produces an executable file (machine code) | no executable file |
| errors | provides an error report for the whole code if errors are detected | stops execution when an error is found |
| advantages | executable runs fast and can be run again without translating; source code is not given away; no translator needed by the user | easy debugging: errors found one at a time, and code can be tested in parts; runs straight away |
| disadvantages | harder to debug: all errors reported at the end; must recompile after every change | slower to run: translated every time; interpreter needed to run the program; source code must be shared |
An interpreter is mostly used while a program is being developed, because errors can be found and fixed quickly. A compiler is used to translate the final program for distribution.
4Integrated development environments (IDEs)
A piece of software that provides the tools a programmer needs to write, translate, test and debug program code.
| Function | What it does |
|---|---|
| code editor | lets the programmer type and edit code, often with colour-coded keywords |
| run-time environment | lets the program be run and tested within the IDE, showing output |
| translator | a built-in compiler and/or interpreter |
| error diagnostics | highlights errors and explains them, e.g. line number and type of error |
| auto-completion | suggests the rest of a keyword or identifier as it is typed |
| auto-correction | automatically corrects common mistakes, e.g. spelling of keywords |
| prettyprint | formats code with indentation and colour so it is easier to read |
5Exam focus
Key words: high-level; low-level; machine code; assembly language; mnemonic; assembler; compiler; interpreter; executable; IDE; error diagnostics; prettyprint.
Quick self-check
Answer in your head first, then reveal.
Any two: easier to read/write; easier to debug; machine independent (2).
An assembler (1).
Translates the whole program at once (1); produces an executable file (1); gives an error report for the whole program (1).
Stops at the error / errors are found one at a time (1); so they can be corrected and the code tested in sections (1).
Any three: code editor; run-time environment; translator; error diagnostics; auto-completion; auto-correction; prettyprint (3).
