Difference Between Compiler and Interpreter

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Difference Between Compiler and Interpreter

Basis of
Compiler Interpreter
difference
 Create the program.
 Compile will parse or
analyses all of the
language statements for
its correctness. If  Create the Program
incorrect, throws an error  No linking of files or machine code
Programming  If no error, the compiler generation
Steps will convert source code to  Source statements executed line by
machine code. line DURING Execution
 It links different code files
into a runnable
program(know as exe)
 Run the Program

The program code is already


translated into machine code. Interpreters are easier to use, especially f
Advantage
Thus, it code execution time is beginners.
less.
You can't change the program
Interpreted programs can run on compute
Disadvantage without going back to the source
that have the corresponding interpreter.
code.
Basis of
Compiler Interpreter
difference
Store machine language as
Machine code Not saving machine code at all.
machine code on the disk
Running time Compiled code run faster Interpreted code run slower
It is based on language
Model It is based on Interpretation Method.
translationlinking-loading model.
Generates output program (in
Do not generate output program. So they
Program the form of exe) which can be
evaluate the source program at every time
generation run independently from the
during execution.
original program.
Program execution is separate
from the compilation. It Program Execution is a part ofInterpretatio
Execution
performed only after the entire process, so it is performed line by line.
output program is compiled.
Target program
Memory executeindependently and do The interpreter exists in the memory durin
requirement not require the compiler in the interpretation.
memory.
For web environments, where load times
Bounded to the specific target
are important. Due to all the exhaustive
machine and cannot be ported.
analysis is done, compiles take relatively
Best suited for C and C++ are a most popular a
larger time to compile even small code tha
programming language which
may not be run multiple times. In such
uses compilation model.
cases, interpreters are better.
The compiler sees the entire
Interpreters see code line by line, and thu
Code code upfront. Hence, they
optimizations are not as robust as
Optimization perform lots of optimizations that
compilers
make code run faster
Difficult to implement as
Dynamic Interpreted languages support Dynamic
compilers cannot predict what
Typing Typing
happens at turn time.
It is best suited for the It is best suited for the program and
Usage
Production Environment developmentenvironment.
Compiler displays all errors and
The interpreter reads a single statement
warning at the compilation time.
Error execution and shows the error if any. You must
Therefore, you can't run the
correct the error to interpret next line.
program without fixing errors
Input It takes an entire program It takes a single line of code.
Basis of
Compiler Interpreter
difference
Compliers generates Interpreter never generate any intermedia
Output
intermediate machnie code. machnie code.
Display all errors after,
Errors compilation, all at the same Displays all errors of each line one by one
time.
Pertaining
C,C++,C#, Scala, Java all use
Programming PHP, Perl, Ruby uses an interpreter.
complier.
languages

You might also like