Teach Computing

Revision notes, activities, lesson plans, teaching ideas, and other resources for GCSE, A-Level, and IB Computer Science teachers and students.

What's New

Device specifications

Device Specifications is a simple site with a huge database of smart phones...

Smart phone specs explained

This excellent site is a detailed guide to smart phone specifications, expl...

Software as a Service (Saas)

This short video gives an overview of Software as a Service (SaaS), which s...

Amazon EC2 - Elastic Cloud Server

Amazon Elastic Cloud (Amazon EC) is a good example of Infrastructure as a S...

Changeover notes

IGCSE ICT provide short but clear notes and diagrams covering the different...

CommandPoint CAD

CommandPoint by Northrop Grumman offers a range of CAD systems for various ...

CAD+911 System

TriTech Software Systems is a company that specialises in Computer Aided Di...

London Ambulance CAD failure

The 1992 London Ambulance Service CAD failure is probably the most notoriou...

Washington State 911 Failure

A 911 emergency telephone system in Washington State and Oregon shut down f...

Resources discount offer

Programming Languages

GCSE Computer Science topics

  • Edexcel GCSE Computer Science: 4.5 Programming languages
  • Cambridge / OCR Computer Science: 2.5 Translators and facilities of languages
  • AQA GCSE Computer Science: 3.2.13 Classification of programming languages
[?] These computer science theory notes are labelled for the Edexcel GCSE course. The equivalent topics in other GCSE Computer Science courses are listed above.

4.5.1 High Level languages and low level languages

Programming languages are divided into two general categories: low level languages and high level languages. The 'low' and 'high' refer to how 'distant' a language is from the hardware of a computer system. You can also think of this as how abstract a language is.

A high level language is relatively 'far' from the hardware, and has a greater number of abstract features (such as 'IF...THEN' statements and loops). This means high level languages are more English like.

In contrast, a low level language is 'closer' to the hardware, with fewer abstractions. Low level programming languages include instructions for directly manipulating the contents of CPU registers and memory addresses. These technical features are hidden by the abstraction of higher level languages.

For example, in a high level language a programmer might write the code 'IF grade == 90 THEN'. In a low level language, a programmer would need to break down the process into several steps: load the data for 'grade' into memory or a register. Load the data '90' into memory or a register. Compare the two pieces of data. Jump to the address of the appropriate instruction if the comparison showed they were they same. Optionally jump to the address of the appropriate instruction if the comparison showed they were

Types of programming language
High level and low level programming languages

Low level languages

Low level languages feature fewer abstractions (such as 'IF' statements or loops) than higher level languages. In a low level programming language the programmer must deal with a larger number of technical concepts, such as memory addresses and registers. These technical features are hidden by the abstraction of higher level languages. For example, instead of using named variables common in higher level languages, programmers will need to instructions for manipulating data in registers and memory addresses, and manually keep track of where items of data are stored.

Low level programming languages are more closely 'tied' to hardware than high level languages. Low level languages have instructions specific to a certain make of CPU. This means programs written in low level languages are less portable - for example, an assembly language program written for an Intel x64 CPU will not run on an ARM CPU.

The two main examples of low level languages are machine code and assembly language.

Machine code

Machine code is simply a binary representation of a CPU's instructions. Each instruction a CPU can 'understand' has its own binary representation. Since binary is the only thing a computer can process, all computer programs need to be translated into machine code before they can be run. To make it easier to read, machine code is often written in hexadecimal.

It is possible to write programs in machine code, but it is extremely difficult. Reading a machine code program (such as the one below) is extremely hard without a thorough understanding of the CPU's instruction set.

Machine code example
A machine code program to calculate the nth Fibonacci number. Each group of 8 hexadecimal digits represents a 32 bit instruction. (Source)

Assembly language

Assembly language uses short mnemonics ('opcodes') to represent each machine code instruction. For example, instead of the machine code instruction 8B (hexadecimal) or 10001011 (binary), assembly language might use the mnemonic 'MOV'. This makes assembly language significantly easier to read and write than machine code.

However, assembly language is still significantly harder to learn than a high level programming language. There are still no high level abstractions to aid the programmer. The assembly language example below shows the same program as the machine code above. Although it is slightly clearer than a collection of hexadecimal numbers, you still need a thorough understanding of the CPU's instruction set to understand the purpose of the program.

Assembly language example
The assembly language version of the Fibonacci program above. (Source)

High level languages

High level programming languages let programmers write code using 'English-like' statements. Although code might seem hard to understand to non-programmers, it is much clearer and easier to read than low level languages. Python, Java, Pascal, and C++ are examples of high level languages.

High level language example
The same program as above (calculate the nth Fibonacci number) in Python

Advantages and disadvantages

The main advantage of high level programming languages is that code is easier to read, write, and debug. This reduces development and maintenance time, which should also reduce costs. Another key advantage is that high level languages tend to be more portable. For example, a Python program written on a PC should run and produce the same output using the Python environment on a Mac. This is possible because high level languages do not have features specific to one type of hardware. In contrast, an assembly language program written for one CPU type will not work on a different type of CPU.

A disadvantage of high level programming languages is that programs must be translated into machine code before execution. This is done using a translator (either a compiler or an interpreter). Translation takes time, so can slow down the execution of a program compared to one written in a low level language. In general, high level languages are also less memory efficient than low level languages.

Another potential drawback of high level languages is that they do not let the program control hardware directly. This type of control might be essential when connecting some types of external devices.

4.5.2 Assemblers, compilers, and interpreters

Translators

The only language a computer can 'understand' is binary (machine code). Humans can understand binary (sort of!) but we prefer to write programs in programming languages such as Python, Java, or C. This means we need a way of converting a program written in a language such as these into machine code.

Translators are programs to do this conversion. Translators convert a program written in a high level or low level language into machine code. Assemblers, interpreters, and compilers are all types of translator.

Types of translator
The relationship between assemblers, compilers, and interpreters

Assemblers

An assembler translates assembly language programs into machine code. An assembler is a type of translator.

Interpreters

An interpreter translates a high level language into machine code. The difference between an interpreter and a compiler is the way the translation is performed. An interpreter translates one line of code into machine code, executes that code, and then translates the next line of the program.

  1. Repeat
  2. Translate one line of code into machine code
  3. Execute this line of code
  4. Until the end of the program

Compilers

A compiler translates a high level language into machine code. The difference between a compiler and an interpreter is the way the translation is performed. A compiler translates an entire program into machine code before executing any of the code.

  1. Translate each line of code into machine code
  2. Start the execution of the program

Internet resources

Use these resources to help you learn more about programming languages and translators.