High- and low-level languages and their translators Flashcards
Syllabus: 1.3.7 Textbook: pg 256 - 259
What is a low-level programming language?
A programming language that is easier for the processor to interpret but harder for humans to understand.
Two low-level languages:
- machine language/object code
- assembly language
What is machine language?
- lowest level of language
- consists of binary and/or hexadecimal
- raw instructions that the CPU carries out (processor reads machine code directly, no need to translate it)
- each CPU family has a different set of machine code
What is assembly language?
- uses abbreviations or mnemonics for each operation code
- easier to read and write than machine language
- must be translated into machine code by an assembler before it can be run by a processor
What is an assembler?
- translation program that translates processor-specific assembly code (source code) into machine code (object code) for a specific processor
- translates an entire program but does not run it
- it is rapid and reliable
List some advantages of using low-level languages
- complete freedom of choice of instructions
- direct control over the processor’s communication with its input, output and storage devices
- efficient programs can be written that:
- fir into limited storage space
- require limited RAM
- run rapidly
List some disadvantages of using low-level languages
- lack of relation to a human language makes it difficult for programmers to read
- machine-oriented nature makes it hard for a programmer to learn, as each operation code must be memorised or looked up
- processor-specific nature of the instruction set means that programs are not transferrable or portable between families of processor
- programs are relatively hard to test, debug and maintain
What is a high-level programming language?
A programming language that looks more similar to a human language or mathematical notation and is therefore easier for programmers to use. However, a program must be used to translate the language for the processor.
They are intended to help programmers solve problems rather than to micro-manage the computer’s hardware.
What is a compiler?
- a program that translates all the high-level source code by compilation
- compilation must be completed before the program can be run, i.e. the entire program must be translated before the processor can execute the instructions
- if there are errors in the source code, the compiler produces an error report, the programmer corrects the errors and compiles the whole program again
- therefore, the debugging of a large program before it can be run can be a slow, iterative process
What is an interpreter?
- program that translates high-level language statements and executes them on a specific processor and operating system
- does not create machine code
- analyses one source code statement at a time and runs appropiate subroutines to execute it
- if the interpreter finds an error in the source code, it produces an error report and stops the execution
- the process of translation slow the execution, but debugging a large program is faster as the program does not need to be re-compiled after every edit
List 5 differences between a compiler and an interpreter
- compiler produces object code; interpreter doesn’t produce object code
- compiler translates whole program in one go; interpreter translates and executes line at a time
- compiler produces list of all errors; interpreter produces error message each time an error is encountered
- compiler produces “stand alone code”; interpreter doesnt produce “stand alone code”
- compilation process is slow but resultant code runs very quickly; interpreted code runs slowly