A compiler or an interpreter is a program that converts a program written in a high-level language into machine code understood by the computer. The major differences between a compiler and interpreter are given below.
Difference between Compiler and Interpreter
1) A compiler converts the whole program to machine language directly.
|1) An interpreter translates the high-level language program one line at a time to some intermediate form and then executes that converted line. The next line is then executed and so on.|
|2) The converted program can be stored somewhere in memory and this .exe file can be executed without requiring the presence of a compiler||2) The presence of an interpreter is a must while executing the program.
|3) Complex software.||3) Usually smaller and simpler software.|
|4) Execution of program can start only if the code is free of errors.||4) Execution continues until an error is found.|
|5) Faster, because only once the .exe file is generated and for future executions, this file is used.||5) Slower, as conversion of source code to machine code is done for every execution.|
|6) A compiler is Machine dependent. The object code generated for one machine cannot be used for another machine.||6) An interpreter generates machine-independent code.|
|7) The programming language like C, C++ use compilers.||7) The programming language like Python, Ruby use interpreters.|