Difference between compiler and interpreter

 Difference between compiler and   interpreter:

As we know that commuter understands only machine language or the language which is in the form of 0 and 1. computer didn't understand any another language. But it is so difficult to write a program in machine language therefore we write programs in high level programming languages like c,c++,java, python etc. which are easily understandable by human.in order to translate high level programming languages into machine language. We use translator tools which are compiler and interpreter. They translate high level programming languages into machine language.

Compiler and interpreter both are translate high level programming languages into machine language. But there are lots of differences between compiler and interpreter. A compiler and interpreter can differentiate on the basis of their working.

Difference between compiler and interpreter

Difference between compiler and interpreter:

  • A compiler is a program which converts the entire source code of a programming language into executable machine code for a CPU. But an interpreter takes a source program and runs it line by line, translating each line as it comes to it.
  • A compiler translates source code into object code as a whole. But an interpreter statement of the source code one by one and then execute immediately.
  • compiler creates an object file. But interpreter does not create an object file.
  • In compiler execution is fast. But in interpreter execution is slow.
  • In compiler program not required to translate each time to run the program. But in interpreter program required to translate each time to run.
  • In compiler it is not easy to correct the mistakes in the source code. But in interpreter it is easy to correct the mistakes in source code.
  • A compiler generates the error message only after scanning the whole program, so debugging is comparatively hard as the error can be present anywhere in the program. But in interpreter its debugging is easier as it continues translating the program until the error is met. 
  • A compiler generates intermediate object code. But in interpreter no intermediate object code is generated.
  • A compiler stores the machine language on the disk in the form of machine codes. But an interpreter does not save the machine language.'
  • In compiler the compile code runs faster as compared to interpreter. But in interpreter the compile code run slower as compared to compiler.
  • A compiler works on the basis of the language-translation linking loading model. But an interpreter works on the basis of the interpretation method.
  • A compiler displays all the errors after compiling together at the same time. But an interpreter displays the errors of every single line one by one.
  • Most high-level programming languages use compiler like c,c++,FORTRAN. Few high-level programming languages use interpreter like LISP,Python,Basic etc.


Post a Comment

Previous Post Next Post