A compiler is a computer program that accepts a computer code, written in a certain format as input and outputs the object code, which can be executed by a user. Compilers were developed to make the processes of writing a computer program fairly easy and simple.

Computer programs used to be written in machine language, which means that, any instruction given to the computer must be translated into binary (0 or 1) before feeding it to the computer. This process was cumbersome and error prone. It was also necessary at the time to know the internal addressing of the computer the code is being written for, making such code machine dependent. Compilers have eliminated this problem. Code is written in simple English-like statements and then also, the compiler takes care of addressing issues, freeing the programmer from that.

Compilers use a whole process called compilation, which is also subdivided into sub processes to compile a computer program. They also have certain characteristics that distinguish them.


Ever compiler has a defined syntax in which programs are written. The syntax is the form and structure of the statements making the language. Failure to follow such syntax may result in an error. For instance, in the C programming compiler, every executable statement must end with a semi- colon and also, a variable must be declared before use. If one or more of the statements fed into the compiler does not have these features, the compiler declares a syntax error and will not compile the code until the error is corrected.


Semantics is the meaning attached to each statement. Due to the structure defined for a particular programming language, the statements may have special meaning. For instance in C programming, any statement that starts with a data type followed by a name and a semi-colon will mean declaring a variable with the name and of the data type. This statement may be followed by an equal sign and then a value, meaning the value must be assigned to that variable. If this does not come, the compiler assigns its own value to such a variable.

Compilers have gone through a lot of innovation, producing the intelligent compilers we have today. They come with in-built code editors, in which code is typed. Compilers are also able to detect errors in ones code and indicate it. Some of the languages will wait till an attempt is made to compile before they point out the error, while others are able to detect an error as soon as a statement is types. Some compilers may say clearly where the error is and what it is, while others may only tell you there is an error, but not the kind of error or what it is. Others may tell you what it is but not where it is but other compilers will tell you where the error is but not what is causing it.

Using a compiler make programming fairly easy. The programmer needs not know the internal addressing mode of the computer as the compiler does the addressing by itself. This makes the code written on any computer to be able to run on any other computer. Compilers also do the translation of programming code from natural language to machine language, giving more time to the programmer to concentrate on his code rather than on translating into binary.

If you have never tried a compiler, try one today and enjoy the freedom it offers to programmers.

About Author / Additional Info: