Difference between compiler and interpreter


Compiler:

  • The compiler translates the entire source program into machine language program at once. The source code remains intact.
  • Once a program is compiled it can be run as many times as required, without being required to be recompiled.
  • A compiler can translate only those programs which have been written in the language for which it is designed. Also each machine has to have its own compiler.
  • A compiler is a program which normally resides on the secondary storage device.
  • It is a program which translates a high level language program into a machine language program.

Interpreter:

  • The interpreter is the program which translates a high level language program into machine language
  • It translates only one statement of the program at a time. It reads only one statement of program, translates it and executes it.
  • Then it reads the next statement of the program again translates it and executes it. In this way it proceeds further till all the statements are translated and executed.
  • The interpreted programs are generally slower than compiled programs. However, if any changes are made in the source program it can interpret only those statements and it is not required to compile the entire program again.
  • Interpreters are relatively easy to write and smaller in size as compared to compilers.