Interpreter and Compiler


Interpreter

  • An interpreter is a program which translates statements of a program into machine code.
  • 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.
  • An interpreter reads only one line of a source program at a time and converts it to object codes.

Compiler

  • After the C pre-processor has included all the header files and expanded all macros, the compiler can compile the program.
  • It does this by turning the C source code into an object code file, which is a file ending in .o which contains the binary version of the source code.
  • Object code is not directly executable, though. In order to make an executable, you also have to add code for all of the library functions that were #included into the file (this is not the same as including the declarations, which is what #include does).
  • It is a program which translates a high level language program into a machine language program.
  • A compiler is more intelligent than an assembler.
  • It checks all kinds of limits, ranges, errors etc. But its program run time is more and occupies a larger part of the memory.
  • It has slow speed. Because a compiler goes through the entire program and then translates the entire program into machine codes.