Compiler is a translator which takes input i.e., High-Level Language, and produces an output of low-level language i.e. machine or assembly language An interpreter is a program that translates a programming language into a comprehensible language.
Difference between compiler and interpreter are stated below
Compiler | Interpreter |
---|---|
The compiler scans the whole program in one go. | Translates the program one statement at a time. |
As it scans the code in one go, the errors (if any) are shown at the end together. | Considering it scans code one line at a time, errors are shown line by line. |
The main advantage of compilers is its execution time. | Due to interpreters being slow in executing the object code, it is preferred less. |
It converts the source code into object code. | It does not convert source code into object code instead it scans it line by line |
It does not require source code for later execution. | It requires source code for later execution. |
Execution of the program takes place only after the whole program is compiled. | Execution of the program happens after every line is checked or evaluated. |
The machine code is stored in the disk storage. | Machine code is nowhere stored. |
Compilers more often take a large amount of time for analyzing the source code. | In comparison, Interpreters take less time for analyzing the source code. |
It is more efficient. | It is less efficient. |
CPU utilization is more. | CPU utilization is less. |
Eg. C, C++, C#, etc are programming languages that are compiler-based. | Python, Ruby, Perl, SNOBOL, MATLAB, etc are programming languages that are interpreter-based. |