Languages and their Translators

 

In this section we will look at what a programming language is, and how your computer understands them. We will look at the two different types of programming language - low-level programming and high level programming as well as object-oriented and procedural.

WHAT IS A PROGRAMMING LANGUAGE

A programming language is a language used to communicate between humans and computers. Computers don't speak English, or any other human language for that matter, and so programming languages were created to allow us to tell them what to do. However, you may remember from previous lessons that computers only understand 0s and 1s. If this is true, then how do they understand programming languages.

The simple answer is that they don't. However, to program just in binary code would make even the most simple software creation an incredibly difficult task. Programming languages therefore, stand between human language and computer language and allow us to speak to them without using 0s and 1s. Another piece of software is used in between to translate the programming language to the language the computers understand, but more about those later.

MACHINE CODE AND ASSEMBLY LANGUAGE

Machine code is a set of instructions which are carried out directly by the CPU. They are hardcoded to be understood by the processor and deal with performing very specific tasks such as transferring from memory to the ALU (arithmetic logic unit) and loading instructions in to the CPU register. The image below shows some machine code instructions.

machinecode

Assembly language is like machine code in that it is very simple instructions that are easily translated in to 0s and 1s for the computer to understand. Assmebly language however, isn't hardcoded in to the hardware for it to understand. It is converted in to machine code by a piece of software called the 'assembler'. It is used because it allows us to carry out complex instructions more simply than typing them in using machine code.

LOW LEVEL PROGRAMMING LANGUAGES

Machine code and assembly language are examples of low-level programming languages. A low level programming language is a language which usually contains short, specific instructions for a computer to carry out. The languages can be used to control things you normally wouldn't control while programming, such as transferring things from one part of the memory to another and telling the hardware what to do. Assembly language, shown below, gives you a good idea of what low-level programming languages look like.

assembly

You could, in theory do anything with a low-levek programming language, but because it would take so long we now use high-level programming languages for more complex tasks.

HIGH PROGRAMMING LANGUAGES

A high level programming language looks much more like the English language than a low-level one. Statements can easily be understood, often even by someone without a knowledge of computer languages. They also allow us to use certain tools to make things easier such as arrays, functions and somtimes objects. They are usually used to create more complex programs and pieces of software where low-level programming languages would prove too limited. An example of a high-level programming language - Python - is shown below.

pythonexample

INTERPRETERS AND COMPILERS

Because programming languages can't be understood by the computer straight away, they need to be translated in to a language the computer understands. There are two ways of doing this:

So to sum-up

Compiler

Creates a single file at the end || Only has to be compiled once || Takes the entire code at once || Outputs any errors at the end || Takes more memory to convert || Uses an intermediate code || Executes loops slower

Interpreters

Does not create a single file || Has to be interpreted every time it's run || Takes the program line-by-line || Stops and gives error messages after each line || Does not use an intermediate code || Executes loops slower

1) Give two differences between interpreters and compilers

2) Give an example of a high and low level programmign language