Thursday, August 26, 2010


INTERPRETER
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language. An interpreter may be a program that either
  1. Executes the source code directly.
  2. Translates source code into some efficient intermediate representation (code) and immediately executes this.
  3. Explicitly executes stored precompiled code made by a compiler which is part of the interpreter system.
Perl, Python, MATLAB, and Ruby are examples of type 2, while UCSD Pascal and Java are type 3: Source programs are compiled ahead of time and stored as machine independent code, which is then linked at run-time and executed by an interpreter and/or compiler (for JIT systems). Some systems, such as Smalltalk, BASIC and others, may also combine 2 and 3.
While interpretation and compilation are the two principal means by which programming languages are implemented, these are not fully distinct categories, one of the reasons being that most interpreting systems also perform some translation work, just like compilers. The terms "interpreted language" or "compiled language" merely mean that the canonical implementation of that language is an interpreter or a compiler; a high level language is basically an abstraction which is (ideally) independent of particular implementations.
Bytecode interpreters
There is a spectrum of possibilities between interpreting and compiling, depending on the amount of analysis performed before the program is executed. For example, Emacs Lisp is compiled to bytecode, which is a highly compressed and optimized representation of the Lisp source, but is not machine code (and therefore not tied to any particular hardware). This "compiled" code is then interpreted by a bytecode interpreter (itself written in C). The compiled code in this case is machine code for a virtual machine, which is implemented not in hardware, but in the bytecode interpreter. The same approach is used with the Forth code used in Open Firmware systems: the source language is compiled into "F code" (a bytecode), which is then interpreted by a virtual machine.
Advantages and disadvantages of using interpreters
Programmers usually write programs in high level code which the CPU cannot execute. So this source code has to be converted into machine code. This conversion is done by a compiler or an interpreter. A compiler makes the conversion just once, while an interpreter typically converts it every time a program is executed (or in some languages like early versions of BASIC, every time a single instruction is executed).


Development cycle
During programs development the programmer makes frequent changes to source code. A compiler needs to make a compilation of the altered source files, and link the whole binary code before the program can be executed. Interpreter usually just needs to translate to an intermediate representation or not translate at all, thus requiring less time before the changes can be tested.
This often makes interpreted languages generally easier to learn and find bugs and correct problems. Thus simple interpreted languages tend to have a friendlier environment for beginners.
Distribution
A compiler converts source code into binary instruction for a specific processor's architecture, thus making it less portable. This conversion is made just once, on the developer's environment, and after that the same binary can be distributed to the user's machines where it can be executed without further translation.
An interpreted program can be distributed as source code. It needs to be translated in each final machine, which takes more time but makes the program distribution independent to the machine's architecture.
Execution environment
An interpreter will make source translations during runtime. This means every line has to be converted each time the program runs. This process slows down the program execution and is a major disadvantage of interpreters over compilers. Another main disadvantage of interpreter is that it must be present on the machine as additional software to run the program.


 PIYUSH THAKUR (CR)
 POOJA SUTAR      (ACR)

No comments:

Post a Comment