Low and High Level Languages

Contents
  1. Instruction Sets
  2. Machine Code
  3. Assembly Language
  4. High Level Languages

1. Instruction Sets

An Instruction Set is all of the instructions a CPU can execute.

Instructions are stored in memory (RAM) as machine code - they are binary patterns. These are the instructions that are fetched, decoded and executed by the CPU.

Instruction Sets are linked to specific CPUs and a program written in machine code using one instruction set will not be compatible with a CPU that uses a different or updated instruction set.


2. Machine Code

Machine Code are the binary instructions that CPUs can understand.

Each instruction is a binary number that represents a specific instruction the CPU can carry out. These instructions are stored in memory before being transferred to the CPU in the Fetch Decode Execute cycles

Machine code is the lowest level language a computer can be programmed in as each instruction is directly linked to hardware and logic built into the CPU. 

Advantages of Machine Code

  • As the lowest level language any program written in machine code can be very efficient.

Disadvantages of Machine Code

  • Machine code is difficult or impossible to read and understand by humans
  • Machine code is difficult to write
  • Programs written in machine code are not portable to different hardware

3. Assembly Language

Due to the difficulties humans have reading and writing machine code in binary, we created Assmebly Language. 

Assembly Language uses mnemonics - commonly 3 letter abbreviations of English words. Each mnemonic is directly linked to one machine code instruction.

When a program is written in Assembly Langauge, the mnemonics are converted to their binary machine code equivalents to be ran on the CPU. This translation is done by an Assembler.

Advantages of Assembly Languages

  • It's easier to write programs in Assembly Language than machine code due to mnemonics
  • Due to each mnemonic being linked directly to one machine code instruction, Assembly Language programs are very memory efficient

Disadvantages of Assembly Language

  • Assembly Language programs are not portable because of the direct link to Machine Code
  • While using mnemonics is easier than writing binary machine code, it is not as easy to write and understand as higher level languages

4. High Level Languages

Over time we produced easier to use languages which are much closer to plain English, and therefore much easier to write, read and understand. We refer to these languages as being "High Level".

High level languages include: Python, JavaScript, C, C#, Swift and Java.

Each high level language uses keywords, for example: print, input, if, else, while.

Unlike a mnemonic, a keyword does not directly link to machine code and will need to be translated to machine code. When translating a keyword to a machine code instruction one keyword may produce many machine code instructions.

Due to not being linked directly to one instruction set, high level languages can be portable between different hardware configurations. For example an application written in C# can be ran on a variety of different types of CPUs and hardware platforms.

Advantages of High Level Languages

  • Programs written in High Level Languages can be portable between different hardware, saving developers time if a program needs to work on different types of computer systems
  • it is easier to read, write and understand High Level Language due to plain English keywords

Disadvantages of High Level Languages

  • The disconnect between High Level Langauges and machine code means that programs use more memory and more CPU cycles
  • Programs written in High Level Langauges must be translated down to machine code in order to run on a CPU