Skip to study material
← Question index

QUESTION 01 · Program development

Define a programming language and name two language levels.

2 marks

Answer

A programming language provides symbols and rules for expressing instructions to a computer.

  • Machine language represents instructions the processor can execute.
  • High-level languages, such as C, express operations using readable statements.

QUESTION 02 · Program development

What is a programming language? Compare machine, assembly and high-level languages.

5 marks

Answer in brief

A programming language is a set of words, symbols and rules used to write instructions for a computer.

Types of programming languages

  1. Machine language: Instructions are written as machine codes, usually shown using 0s and 1s. The processor can execute the correct machine code directly. It is difficult for people to read and write.
  2. Assembly language: Short names such as ADD are used instead of binary instructions. An assembler converts assembly code into machine code. The instructions depend on the processor.
  3. High-level language: Instructions are written using readable words and expressions. Examples include C and Python. A suitable translator is needed before or during execution.

Example

To add two numbers in C, we can write total = a + b;. The compiler translates the C instructions for the selected computer. We do not need to write the processor’s binary instructions ourselves. The translated code may contain several machine instructions.

Advantages of high-level languages

  1. Easy to read: Meaningful names and familiar expressions make programs easier to understand.
  2. Easy to maintain: A programmer can find and change the required part more easily.
  3. Better portability: The same source can often be used on different computers when suitable compilers and libraries are available.

Compiler and interpreter

A compiler translates a program into another form before the translated program runs. An interpreter carries out instructions through another program. These are ways of implementing a language. C programs are commonly compiled. A language and a compiler are different: C is a language, while GCC is one compiler that supports it.

Reference tables

↔ Scroll horizontally on a small screen
Levels of programming languages
LevelHow instructions are writtenTranslation and use
Machine languageEncoded processor instructions, commonly represented as binary or hexadecimalExecuted by the matching processor; difficult for people to maintain.
Assembly languageMnemonic instructions such as ADD, with symbolic labelsAn assembler produces machine code for a particular architecture.
High-level languageExpressions, functions and control structures close to human reasoningA compiler or interpreter implements the language. C source is commonly compiled.
↔ Scroll horizontally on a small screen
Translation methods
MethodTypical behaviourWhat to remember
CompilationTranslates a source program into another representation before the resulting program runs.C implementations commonly compile source to native code.
InterpretationExecutes a representation of the program through another program.A language may have more than one implementation strategy.

Key points

  • Machine code is processor-specific.
  • An assembler translates assembly; a compiler can translate C.