You are on page 1of 24

Interpreter

12/07/21 Vipul Ray Gaur 1


Topics of Discussion
 System Programming Domains
 Language Processors
 Interpreter
 Advantages and Disadvantages of Interpreter
 Quantitative Comparison of Interpreter and
Compiler
 List of frequently used Interpreter Languages
12/07/21 Vipul Ray Gaur 2
System Programming Domains
 Application Domain or Specification Domain
 Programming Language (PL) Domain
 Execution Domain

12/07/21 Vipul Ray Gaur 3


These Domains are here explained for the proper analysis of System
Programming and for better understanding of it.

12/07/21 Vipul Ray Gaur 4


Application Domain

The ideas expressed by the Designer is related to


the Application Domain.

12/07/21 Vipul Ray Gaur 5


Programming Language (PL) Domain
Implementing these Ideas in the form of a
Programming Language is PL Domain.

In simple, Coding the Specification in


Programming Language like Pascal, C, C++,
Java etc.

12/07/21 Vipul Ray Gaur 6


Execution Domain

Execute or Run the program written under PL


domain for desired results comes under the
Execution Domain.

12/07/21 Vipul Ray Gaur 7


Execution Gap
It is semantic gap between a
Program which is written in
High Level Language and
Execution of that program
by the Machine in Machine
Language form.
Execution Gap can be bridged
by the Language Processors

12/07/21 Vipul Ray Gaur 8


Language Processor
It is software which bridges a Execution Gap.

It can be termed as Language Translator which converts or


process one Language to another language which is
understandable to the system or machine

Terminology for Language Processor


1. Source Program: Input to Language Processor
2. Target Program: Output of Language Processor

12/07/21 Vipul Ray Gaur 9


Language Processor

12/07/21 Vipul Ray Gaur 10


Interpreter
An Interpreter is a Language Processor which
bridges the execution gap without generating
the machine language program.

Hence we can say that Interpreter executes the


program written in PL domain and thus the
execution gap vanishes totally.

12/07/21 Vipul Ray Gaur 11


Interpreter

12/07/21 Vipul Ray Gaur 12


Program Interpretation
Interpreter reads the source program, analyses it,
know the meaning of it, stores it in its
memory and then execute it just like the CPU
do. This is done under the interpretation cycle
like the CPU’s instruction execution cycle.

12/07/21 Vipul Ray Gaur 13


Program Interpretation
Steps under interpretation
cycle:
 Fetch the statement
 Analyze the statement
and determine the
meaning viz. the
computation to be
performed and its
operands
 Execute the meaning of
the statement

12/07/21 Vipul Ray Gaur 14


Classification of Interpreter
 Pure Interpreter
 Impure Interpreter

12/07/21 Vipul Ray Gaur 15


Pure Interpreter
Pure Interpreter are simple interpreter we have
discussed which analyses the source program
and execute it.

12/07/21 Vipul Ray Gaur 16


Impure Interpreter
Impure Interpreters performs preliminary processing of source
program to minimize analysis overheads and generates an
Intermediate Representation (IR) of source program, which is
done through pre-processor

12/07/21 Vipul Ray Gaur 17


Advantages of Interpreter
 it is better to use program interpretation if a program is
modified between execution.
 Platform independence (Java's byte code, for example) ie. It
is portable
 Dynamic Typing
 Smaller executable program size
 Dynamic Scoping

12/07/21 Vipul Ray Gaur 18


Disadvantages of Interpreter
 The main disadvantage of interpreting is a much slower speed
of program execution compared to direct machine code
execution on the host CPU

12/07/21 Vipul Ray Gaur 19


Quantitative Comparison of Interpreter and
Compiler
Lets take following notation for a Source Program “P”:
Tc = Average Compilation time per statement
Te = Average Execution time per statement
Ti = Average Interpretation time per statement
S = Total number of statement in P
SE= Total number of statement Executes in P
Here Tc ≈ Ti and Te << Tc

12/07/21 Vipul Ray Gaur 20


Lets take a problem in which value of S = 200.
P executes as follows: 20 statement for initialization purpose, followed by 10
iterations of a loop containing 8 statements in it and then followed by 20
printing statements.
Thus the total number of executed statement can be calculated as
SE = 20 + 10×8 + 20 = 120 ;
Thus,
Total execution time using the compilation model
= 200×Tc + 120×Te
=200 ×Tc + 120×(Tc/20) [such that Tc= 20×Te => Te = Tc/20]
≈ 206 .Tc
Total execution time using the interpretation model
= 120×Ti
≈ 120 .Tc [such that Ti ≈ Tc]
Conclusion: Execution time taken by Interpreter is much less than Execution time taken
by Compiler.

12/07/21 Vipul Ray Gaur 21


List of Frequently Used Interpreter Languages
 BASIC (Beginner's All-purpose Symbolic Instruction Code )
 ASP (Active Server Pages) Web page scripting language

 JavaScript

 MATLAB

 PHP

 COBOL

 JAVA

And many more….

12/07/21 Vipul Ray Gaur 22


Queries

12/07/21 Vipul Ray Gaur 23


Thanks

12/07/21 Vipul Ray Gaur 24

You might also like