Compilers and Interpreters of Programming Languages



Computers are made up of electronic circuits that understand and operate on binary numbers made up of 1ís and 0ís. So the special native language made up of 1 and 0 is called the machine language. We can say that the machine language is the interface where hardware and software meet inside a computer. The hardware is designed to fetch, interpret and execute, instructions given in machine language. The problem with machine language is that it is difficult to be used and understood by humans who are used more to the everyday languages such as English, French, etc. The solution lie in writing programs using a high level programming language( close to human languages), easily understood by programmers (after some training), such as Java, C, C++ which is then transformed into machine language and then executed.

Simplified Example: Suppose we need to add two numbers A and B

This may be programmed as follows

'add A and B' (this language is understood by humans but not by computers)

We now assign a machine codes (made up of 1's and 0's) as follows

let 'add' be '1100'

let 'A' be '1101'

and 'B' be '0110'

Assigning a code to add, A and B has the advantage of being understood by a computer. So 'add A and B' may be written in machine code as follows: 1100 1101 0110

There are two ways that high level programming languages may be transformed: using either an interpreter or a compiler and sometimes a combination of the two.

Compiler

A compiler is a special software program designed to scan an entire high level programming language such java, C. It then compiles into a executable file with an '.exe' extension. When this compiled file is run, it is understood and then executed by the processor in order to perform the tasks according to the instructions in the original high level programming language. You can run the program as many times as needed without having to recompile it again.

Interpreter

The interpreter is also a special software that interprets a high level programming language, taking one part at the time. It then executes the interpreted part then continues with the next part. No interpreted file is generated; each time the program need to be executed, it will be interpreted first.