Introduction
Introduction
Prerequisites
ACTIVITY
TYPE DATE MARKS CO
SL.NO.
Source Program
Target Program
Source Program
Interpreter Output
Input
Output Compiler generates an intermediate object Interpreter does not produce any intermediate
code. object code.
Working The compilation is done before execution. Compilation and execution takes place
mechanism simultaneously.
Speed Compiled codes run faster than Interpreter. Interpreted codes run slower than Compiler.
Memory Memory requirement is more due to It requires less memory as it does not create
creation of object code. intermediate object code.
Errors Errors are displayed after Compilation, all at Errors are displayed in every single line.
the same time.
Recompilation Any change in the source program after the Any change in the source program during the
compilation requires recompiling the entire translation does not require retranslation of the
code. entire code.
5. Any change in the source program after the compilation 5. Any change in the source program during the
requires recompiling the entire code. translation does not require retranslation of the
entire code.
6. Errors are displayed in Compiler after Compiling 6. Errors are displayed in every single line.
together at the current time.
CD / Module-I / Jasaswi 20 17 January 2024
Compiler vs Interpreter – contd…
Compiler Interpreter
7. The compiler can see code upfront which helps in 7. The Interpreter works by line working of Code, that’s
running the code faster because of performing why Optimization is a little slower compared to
Optimization. Compilers
8. It does not require source code for later execution. 8. It requires source code for later execution.
9. Execution of the program takes place only after the 9. Execution of the program happens after every line is
whole program is compiled. checked or evaluated.
10. Compilers more often take a large amount of time for 10. In comparison, Interpreters take less time for
analyzing the source code. analyzing the source code.
11. CPU utilization is more in the case of a Compiler. 11. CPU utilization is less in the case of a Interpreter.
12. The use of Compilers mostly happens in Production 12. The use of Interpreters is mostly in Programming and
Environment. Development Environments.
13. Object code is permanently saved for future use. 13. No object code is saved for future use.
14. Programming languages that are compiler-based: C, 14. Programming languages that are interpreter-based:
C++, C#. Python, Perl, MATLAB.
CD / Module-I / Jasaswi 21 17 January 2024
3. Types of Compiler
1. Native Compiler (Native Code Compiler):
• Native Compiler is a compiler which is used to convert source code into target code for the same machine
on which it runs.
• Example: Turbo C, GCC.
4. Bytecode Compiler:
• Bytecode Compiler is a compiler which is used to convert high level language source code
into bytecode.
• Example: Java
High Level Bytecode Bytecode
Language Compiler
Machine A Run on Machine A Machine B
The symbol table is a data structure containing a record for each variable name,
with fields for the attributes of the name.
The data structure should be designed to allow the compiler to find the record for
each name quickly and to store or retrieve data from that record quickly.