Programming Languages

Discover the differences between low-level and high-level programming languages. Understand the importance of various programming languages in developing software and solving complex problems.


Contents
  1. Instruction Sets
  2. Machine Code
  3. Assembly Language
  4. High Level Languages
  5. Translators
  6. Interpreters
  7. Compilers
  8. Linkers

Common Questions

What is machine code?

Machine code consists of binary instructions that a CPU can understand and execute directly. It is the lowest level of programming language, directly linked to the hardware and logic of the CPU, making it efficient but difficult for humans to read, write, and port to different hardware.

What is assembly language?

Assembly language, created to address the difficulties of reading and writing machine code, uses mnemonics to represent binary instructions. Each mnemonic corresponds to a specific machine code instruction, making it easier to write and understand. An assembler translates these mnemonics into machine code. Assembly language is memory-efficient but not portable across different systems and remains more complex than higher-level languages.

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.

Edexcel GCSE Computer Science

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
Edexcel GCSE Computer Science

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
Edexcel GCSE Computer Science

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

 

 

Edexcel GCSE Computer Science

CPUs can only understand Machine Code, therefore any program written in another language must be translated to Machine Code so that the CPU can execute its instructions.

There are three types of translators:

  • Assemblers - translating Assmebly Langauge to Machine Code
  • Interpreters - translating specific High Level Langauges line by line to Machine Code
  • Compilers - translates specific High Level Languages to Machine Code ahead of time
Edexcel GCSE Computer Science

An interpreter reads source code and translates it one line at a time into machine code to be executed on the CPU. Once the machine code instructions have been executed, the next line of source code is then translated, and so on.

To run a program that is written in an interpreted language the computer it runs on must have the interpreter installed.

interpretered Langauges include: Python, JavaScript, PHP, and Ruby.

In order for a user to run an interpreted program the user must have the source code. This means that the user will have access to change the source code and could copy it. 

Interpreted Langauges tend to be highly portable, and can be ran on a computer system providing the interpreter is available for the specific hardware.

Due to interpreter programs being translated like by line, the programs tend to be less performant and are not used in applications which require higher performance.

Interpreted Langauges are easier to debug because the program will crash as they are translated at the line of source code where there is an error.

Edexcel GCSE Computer Science

A Compiler translates all the source code for a program into machine code before it is executed. This process is carried out by the developer when they are ready to ship their program.

A compiler produces an executable which contains the machine code instructions which allows it to run its instructions on a CPU. This can be ran without the source code or the compiler being installed. Due to being converted into machine code ahead of time compiled programs tend to be more performant.

Executables cannot be shared between different types of CPU. A different executable must be compiled for each type of CPU or platform it needs to run on. If download a program off the internet you may find various versions of an executable, for example x86, x86_64 and ARM64.

Edexcel GCSE Computer Science

Some larger programs are broken into modules to make them more manageable. At compilation, each module is compiled into an object file and a linker is used to combine them into a single executable file.