3.3 Programming Languages (B03) Flashcards
how does CPU run high level code?
Your high level code is translated to ‘low level’ instructions by a compiler or interpreter.
An assembler then converts the assembly code instruction into binary code (known as machine code and sometimes as object code) that the CPU can understand.
Some translators convert your high level code straight to machine code.
features of high level languages
Each line of code may = multiple low level instructions.
Platform-independent – can be translated to a particular CPU architecture.
It abstracts away specific details of how parts of the code operates: we can store variables without needing to know the machine’s memory structure.
The drawback of this is that we don’t have as much control over the CPU in some languages, so some programs may be less efficient because they cannot make optimal use of the CPU’s architecture.
Must be translated before it can be run.
features of low level languages
One assembly code construction = one line of machine code, doing one specific action.
Assembly code instructions are specific to a particular machine/CPU architecture.
Programmer needs to know about specific operations of the CPU, e.g. how memory is managed.
More control over what the hardware does, therefore can be more efficient.
Can be executed directly without needing to translate/interpret.
Difficult to manage, read or update code.
key difference between high- and low-level languages
High level languages are friendlier to read, but programs run more slowly because the code structure is based on a human-friendly structure.
In contrast, programs written in low level languages can run very quickly as it is based on the computer’s hardware architecture.
exam question!
machine code
the lowest level programming language - written in binary
commands that can be directly executed by a processor
instruction set
all the different machine code instructions a microprocessor (CPU) can execute