Difference between Compiler and Interpreter
1. Compiler:
It 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.
- 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 memory. It has a slow speed because a compiler goes through the entire program and then translates the entire program into machine codes.
Figure – Compiler-Process
2. Interpreter:
An interpreter is a program that translates a programming language into a comprehensible language. –
- It translates only one statement of the program at a time.
- Interpreters, more often than not are smaller than compilers.
Figure – Interpreter-Process
Let’s see the difference between Compiler and Interpreter:
S.No. | Compiler | Interpreter |
---|---|---|
1. | The compiler scans the whole program in one go. | Translates the program one statement at a time. |
2. | 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. |
3. | The main advantage of compilers is its execution time. | Due to interpreters being slow in executing the object code, it is preferred less. |
4. | It converts the source code into object code. | It does not convert source code into object code instead it scans it line by line |
5 | It does not require source code for later execution. | It requires source code for later execution. |
6 | 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. |
7 | The machine code is stored in the disk storage. | Machine code is nowhere stored. |
8 | 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. |
9. | It is more efficient. | It is less efficient. |
10. | 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. |
Please Login to comment...