Difference between Compiler and Interpreter

Compilers and interpreters often deal with how program codes are executed. Program codes are human readable texts written in high level programming languages, such as C or Fortran, to accomplish certain tasks. One thing you should know that program codes can not be executed on its own. Either, they needs to be converted into executable, the machine language code; then the executable runs independently, or the program codes would be used as input of another executable which performs the instructions specified in the program codes. That’s where the compilers and interpreters are different. Compilers convert the program codes into executable, whereas, the interpreters itself run and take the program codes as input. The interpreters follow the instructions written in the program codes.

Another important difference is, the compilers do not have any role in time of executing the program. Compiler converts the program into intermediate object code which are eventually converted into machine code (the executable) by linker. If you want to send the final executable you don’t need to send the compiler with that. The user would be able to run that executable without the compiler. Interpreters are very different in this regard. Interpreters always run in time of executing the program. Whoever wants to run the program needs to have the corresponding interpreters also.

Difference between Compiler and Interpreter

Compiler Interpreter
Compiler converts the program codes into intermediate object codes that are eventually converted into machine language code (executable) Interpreter does not convert the code into any intermediate code but executes the statements of the program one after another.
Compiler is not required in time of running the program. Interpreter is always required in time of running the program.
Any syntax errors are caught in time of compilation. There will not be any syntax error in time of executing the program. The syntax error could be discovered in time of executing the program.
Program codes are generally written in high level language like C, C++, Fortran etc. Program codes are generally written in scripting language like Perl, TCL. Python etc.

Note:
There are certain exceptions of the above descriptions.

  • Compilers do not always generate object codes which can be converted into machine language code. Rather, they generate byte codes that can be executed under virtual machine. Here also the compiler is not required during the program execution.
  • Sometimes the scripts are converted into compiled codes and compiled codes can be used as input of interpreters. TCL script is one such example.
0

Author: Srikanta

I write here to help the readers learn and understand computer programing, algorithms, networking, OS concepts etc. in a simple way. I have 20 years of working experience in computer networking and industrial automation.


If you also want to contribute, click here.

Leave a Reply

Your email address will not be published. Required fields are marked *

0
0
0
0
0
0