0% found this document useful (0 votes)
14 views

Compiler vs. Interperter

Uploaded by

Avantika Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Compiler vs. Interperter

Uploaded by

Avantika Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Compiler and

Interpreter
Compiler

Compilers convert the Source Code (HLL) to Machine Code (understandable


by Computer).
In general, computer programs exist in High-Level Language that a human
being can easily understand.
But computers cannot understand the same high-level language, so for
computers, we have to convert them into machine language and make them
readable
What is Compiler?
The Compiler is a translator that takes input i.e., High-Level Language, and
produces an output of low-level language i.e. machine or assembly
language.
 The work of a Compiler is to transform the codes written in the
programming language into machine code (format of 0s and 1s) so that
computers can understand.
 A compiler is more intelligent than an assembler it checks all kinds of limits,
ranges, errors, etc.
 Program run time is longer 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.
What is the role of a Compiler?

• For Converting the code written in a high-level language into


machine-level language so that computers can easily understand
• use a compiler. Converts basically convert high-level language to
intermediate assembly language by a compiler and then
assembled into machine code by an assembler.
Advantages of Compiler

• Compiled code runs faster in comparison to Interpreted code.


• Compilers help improve the security of Applications.
• Compilers give Debugging tools, which help in fixing errors easily.
Disadvantages of Compiler

• The compiler can catch only syntax errors and some semantic errors.
• Compilation can take more time in the case of bulky code.
What is an Interpreter?

• An Interpreter is a program that translates a programming language into a


comprehensible language.
• The interpreter converts high-level language to an intermediate language. It
contains pre-compiled code, source code, etc.
• It translates only one statement of the program at a time.
• Interpreters, more often than not are smaller than compilers.
Role of an Interpreter

• The simple role of an interpreter is to translate the


material into a target language.
• An Interpreter works line by line on a code.
• It also converts high-level language to machine
language.
Advantages of Interpreter

• Programs written in an Interpreted language are easier to debug.


• Interpreters allow the management of memory automatically, which
reduces memory error risks.
• Interpreted Language is more flexible than a Compiled language.
Disadvantages of Interpreter

• The interpreter can run only the corresponding Interpreted program.


• Interpreted code runs slower in comparison to Compiled code.
Difference Between
Compiler and
Interpreter
Any change in the source program after the compilation Any change in the source program during the translation does
requires recompiling the entire code. not require retranslation of the entire code.

Errors are displayed in Compiler after Compiling together at the


Errors are displayed in every single line.
current time.

The compiler can see code upfront which helps in running the The Interpreter works by line working of Code, that’s why
code faster because of performing Optimization. Optimization is a little slower compared to Compilers.

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 Execution of the program happens after every line is checked or
program is compiled. evaluated.

Compilers more often take a large amount of time for analyzing In comparison, Interpreters take less time for analyzing the source
the source code. code.

CPU utilization is more in the case of a Compiler. CPU utilization is less in the case of a Interpreter.

The use of Compilers mostly happens in Production The use of Interpreters is mostly in Programming and Development
Environment. Environments.

Object code is permanently saved for future use. No object code is saved for future use.

C, C++, C#, etc are programming languages that are compiler- Python, Ruby, Perl, SNOBOL, MATLAB, etc are programming
based. languages that are interpreter-based.

You might also like