Saturday 14 September 2013

Compiler and Interpreter in Programming

Compiler and Interpreter

As we write the code in English and we know that computers can understand only 0s and 1s. So we need a translator which translates the code of our program into machine language. There are two kinds of translators which are known as Interpreter and Compilers. These translators translate our program which is written in C-Language into Machine language. Interpreters translates the program line by line meaning it reads one line of program and translates it, then it reads second line, translate it and soon. The benefit of it is that we get the errors as we go along and it is very easy to correct the errors. The drawback of the interpreter is that the program executes slowly as the interpreter translates the program line by line.

Another drawback is that as interpreters are reading the program line by line so they cannot get the overall
picture of the program hence cannot optimize the program making it efficient. Compilers also translate the English like language (Code written in C) into a language (Machine language) which computers can understand. The Compiler read the whole program and translates it into machine language completely. The difference between interpreter and compiler is that compiler will stop translating if it finds an error and
there will be no executable code generated whereas Interpreter will execute all the lines before error and will stop at the line which contains the error.

So Compiler needs syntactically correct program to produce an executable code.

No comments:

Post a Comment