3.7 High- & Low-level Languages Flashcards
Instruction set
A set of binary numbers that match every instruction that can be understood by the CPU
*different computers may have different instruction sets
Machine code
(The general term for) the number code that matches numbers to instructions / binary instructions that a computer understands
Low-level language
LLLs relate to the specific architecture and hardware of a particular type of computer.
eg. machine code, assembly language
4 advantages of low-level languages
- Works directly on registers/CPU; code can be executed faster
- Programmer has more control over what happens in computer
- Can use machine specific functions
- Code takes up less storage / memory efficient
4 disadvantages of low-level languages
- Difficult to read, write and understand
- Easier to make mistakes
- Time-consuming to write programs
- Programs written in LLL may not work on other makes of computer
Assembly language is often used to create device drivers for new types of hardware. What are device drivers?
Device drivers are instructions that let the CPU communicate with peripherals
High-level language
- Closer to human language / English
- Independent of a particular type of computer // portable language
- A language such as Python, Java, Pascal
3 advantages of high-level languages
- Close to human language
- Easier/faster to read and write
- Portable code - programs written in HLL can be run on any computer once they have been translated into that computer’s machine code
3 disadvantages of high-level languages
- Take additional time to translate program to machine code
- Generally less memory efficient, compared to LLLs
- Programs are slower than low-level language programs
Translators - Assembler
A program that translates a program written in assembly language into machine code.
- An executable file of machine code is produced, so assembled programs can be used without the assembler
- executable file creates a smaller file size, so more saleable
- An assembled program is usually distributed (sold/shared) for general use
Translators - Compiler
A program that translates the whole high-level language program into machine code at once.
- An executable file of machine code is produced, so compiled programs are used without the compiler (it will be quicker to run)
- executable file creates a smaller file size, so more saleable
- A report/list of errors in the code is created
- A compiled program is distributed (sold/shared) for general use
- However, if you make a change the program must be compiled again
- Source code cannot be accessed, so code cannot be stolen/plagiarised
Translators - Interpreter
A program that translates a high-level language program a statement at a time, and the machine code is directly executed.
- Will identify an error as soon as it finds one in a line of code
- No executable file of machine code is produced, so interpreted programs cannot be used without the interpreter
- However, if you make a change you can test the effect immediately, so an interpreter is often used when a program is being developed
2 types of error
- Syntax error - where a program statement doesn’t obey the rules of the programming language
- Logic error - where the program doesn’t do what the programmer wanted it to do
Why is a compiler or an interpreter needed when running a high-level program on a computer?
- Code is required to be converted into machine code/binary
2. Code needs to be produced that can be understood by the computer