Home > DeveloperSection > Interviews > What is difference between interpreter and compiler?

Posted on    October-23-2010 12:00 AM

 1 Answer(s)
  899  View(s)
Rate this:

Pushpendra Singh

Total Post:241

Posted on    October-30-2010 12:00 AM

An interpreter reads the source code one instruction or line at a time, converts this line into machine code and executes it. The machine code is then discarded and the next line is read. The advantage of this is it's simple and you can interrupt it while it is running, change the program and either continue or start again. The disadvantage is that every line has to be translated every time it is executed, even if it is executed many times as the program runs. Because of this interpreters tend to be slow.
A compiler reads the whole source code and translates it into a complete machine code program to perform the required tasks which is output as a new file. This completely separates the source code from the executable file. The biggest advantage of this is that the translation is done once only and as a separate process. The program that is run is already translated into machine code so is much faster in execution. The disadvantage is that you cannot change the program without going back to the original source code, editing that and recompiling

Don't want to miss updates? Please click the below button!

Follow MindStick