Types of Programming Language
Programming Paradigms
There are many ways to tackle a programming problem. Thus many different programming paradigms exist. This means that there are many different approaches to or styles of programming including procedural, object orientated (and functional, declarative which are not on in your course).
Procedural Languages.
Procedural languages carry out instructions step by step. These steps can be within procedures. This includes structured programming:
- sequence - step by step programming statements.
- selection - checking a condition with if / switch etc.
- iteration - repeating a block of code a multiple times. e.g. while, repeat, do while, for loops.
Assembly Language
Assembly language is a low level language which is one step up from machine code. It uses mnemonics which directly map to a binary instruction making it easier to decipher than binary. The instruction set for Assembly language is processor specific. Little Man Computer is an example of assembly language.
Modes of Addressing Memory
As you know machine code instructions are made up of:
- an opcode - the instruction to be performed
- an operand - the data to perform the instruction on.
Consider the instruction SUB 1001. The opcode is SUB. What is 1001?
- Immediate Addressing - The operand holds the actual data value in binary format. So 1001 is the actual data - 9 in binary. So no fetching from memory required.
- Direct Addressing - The operand holds the address of the data, rather than the data itself. So 1001 is the address of the data. This means data can be larger as no space is required for the opcode.
- Indirect Addressing - The operand holds the address of the address where the data is located. So 1001 is the address of another address which is the location of the data. This means we can use larger range of addresses because the space to store the address can be larger as no space is required for the opcode.
- Indexed Addressing - The operand is added to the index register. This is required to add an offset for data stored contiguously in memory e.g. arrays. This makes it easier to to carry out the same instruction when looping through by using it's index.
Object-oriented languages
Object orientated Languages are an abstraction of a real world problem. Classes are created to represent that which we want to model and objects for each instance of these.