interpreter

Share on Facebook Share on Twitter Email
Top
(ĭn-tûr'prĭ-tər) pronunciation
n.
  1. One who translates orally from one language into another.
  2. One who gives or expounds an interpretation: "An actor is an interpreter of other men's words, often a soul which wishes to reveal itself to the world" (Alec Guinness).
  3. Computer Science. A program that translates an instruction into a machine language and executes it before proceeding to the next instruction.

A high-level programming language translator that translates and runs the program at the same time. It converts one program statement into machine language, executes it, and then proceeds to the next statement. This differs from regular executable programs that are presented to the computer as binary-coded instructions. Interpreted programs remain in the source language the programmer wrote in, which is human readable text.

Slower, But Easier to Test

Interpreted programs run slower than their compiler counterparts. Whereas the compiler translates the entire program before it is run, interpreters translate a line at a time while the program is being run. However, it is very convenient to write an interpreted program, since a single line of code can be tested interactively.

Some languages can be both interpreted and compiled, in which case a program may be developed with the interpreter for ease of testing and debugging and later compiled for production use. See JIT compiler.

The Runtime Interpreter Must Be Present

Interpreted programs must always be run with the interpreter, commonly called a runtime module. For example, in order to run a BASIC or Foxbase program, the BASIC or Foxbase interpreter must be running as well.

Interpreted Vs. Intermediate Languages

Interpreted languages also differ from intermediate languages such as Java, which are partially converted but still require a runtime module (see Java and Java virtual machine).

Interpreters and Compilers
Unlike compiled languages which are translated into machine language ahead of time (right), interpreted languages are translated at runtime. dBASE and BASIC interpreters (middle) translate the original source code. Java and Visual Basic (left) interpreters translate "bytecode," which is an intermediate language compiled from the original source code.

Download Computer Desktop Encyclopedia to your PC, iPhone or Android.



In general: person who translates orally foreign languages for people using different languages.


Computers: program that executes a source program by reading it one line at a time and doing the specified operations immediately.
Most basic systems are interpreters.
See also compiler.

Previous:Interpolation, Interpleader, Interperiod Income Tax Allocation
Next:Interrogatories, Interstate Commerce, Interstate Commerce Commission (ICC)
Top
A cynical view of the world by Ambrose Bierce


n.

One who enables two persons of different languages to understand each other by repeating to each what it would have been to the interpreter's advantage for the other to have said.


Top
sign description: The sign for INTERPRET is followed by the PERSON MARKER AGENT.




Random House Word Menu:

categories related to 'interpreter'

Top
Random House Word Menu by Stephen Glazier
For a list of words related to interpreter, see:

Wikipedia on Answers.com:

Interpreter (computing)

Top

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[1] made by a compiler which is part of the interpreter system

Early versions of the Lisp programming language and Dartmouth BASIC would be examples of type 1. Perl, Python, MATLAB, and Ruby are examples of type 2, while UCSD Pascal is 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, contemporary versions of BASIC, Java and others, may also combine 2 and 3.

While interpreting and compiling are the two main means by which programming languages are implemented, these are not fully mutually exclusive 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.

Contents

History

The first interpreted high-level language was probably Lisp. Lisp was first implemented by Steve Russell on an IBM 704 computer. Russell had read McCarthy's paper, and realized (to McCarthy's surprise) that the Lisp eval function could be implemented in machine code.[2] The result was a working Lisp interpreter which could be used to run Lisp programs, or more properly, 'evaluate Lisp expressions.'

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 program development, the programmer makes frequent changes to source code. With a compiler, each time the programmer makes a change to the source code, s/he must wait for the compiler to make a compilation of the altered source files, and link all of the binary code files together before the program can be executed. The larger the program, the longer the programmer must wait to see the results of the change. By contrast, a programmer using an interpreter does a lot less waiting, as the interpreter usually just needs to translate the code being worked on to an intermediate representation (or not translate it at all), thus requiring much less time before the changes can be tested.

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. A cross compiler can generate binary code for the user machine even if it has a different processor than the machine where the code is compiled.

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 of the machine's architecture. However, the portability of interpreted source code is dependent on the target machine actually having a suitable interpreter. If the interpreter needs to be supplied along with the source, the overall installation process is more complex than delivery of a monolithic executable.

The fact that interpreted code can easily be read and copied by humans can be of concern from the point of view of copyright. However, various systems of encryption and obfuscation exist. Delivery of intermediate code, such as bytecode, has a similar effect to obfuscation.

Efficiency

The main disadvantage of interpreters is that when a program is interpreted, it typically runs more slowly than if it had been compiled. The difference in speeds could be tiny or great; often an order of magnitude and sometimes more. It generally takes longer to run a program under an interpreter than to run the compiled code but it can take less time to interpret it than the total time required to compile and run it. This is especially important when prototyping and testing code when an edit-interpret-debug cycle can often be much shorter than an edit-compile-run-debug cycle.

Interpreting code is slower than running the compiled code because the interpreter must analyze each statement in the program each time it is executed and then perform the desired action, whereas the compiled code just performs the action within a fixed context determined by the compilation. This run-time analysis is known as "interpretive overhead". Access to variables is also slower in an interpreter because the mapping of identifiers to storage locations must be done repeatedly at run-time rather than at compile time.

There are various compromises between the development speed when using an interpreter and the execution speed when using a compiler. Some systems (such as some Lisps) allow interpreted and compiled code to call each other and to share variables. This means that once a routine has been tested and debugged under the interpreter it can be compiled and thus benefit from faster execution while other routines are being developed. Many interpreters do not execute the source code as it stands but convert it into some more compact internal form. Many BASIC interpreters replace keywords with single byte tokens which can be used to find the instruction in a jump table. Others achieve even higher levels of program compaction by using a bit-oriented rather than a byte-oriented program memory structure, where commands tokens can occupy perhaps 5 bits of a 16 bit word, leaving 11 bits for their label or address operands.

An interpreter might well use the same lexical analyzer and parser as the compiler and then interpret the resulting abstract syntax tree.

Regress

Interpretation cannot be used as the sole method of execution: even though an interpreter can itself be interpreted and so on, a directly executed programme is needed somewhere at the bottom of the stack.

Variations

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.

Control tables - that do not necessarily ever need to pass through a compiling phase - dictate appropriate algorithmic control flow via customized interpreters in similar fashion to bytecode interpreters.

Abstract Syntax Tree interpreters

In the spectrum between interpreting and compiling, another approach is transforming the source code into an optimized Abstract Syntax Tree (AST) then executing the program following this tree structure, or using it to generate native code Just-In-Time.[3] In this approach, each sentence needs to be parsed just once. As an advantage over bytecode, the AST keeps the global program structure and relations between statements (which is lost in a bytecode representation), and when compressed provides a more compact representation.[4] Thus, using AST has been proposed as a better intermediate format for Just-in-time compilers than bytecode. Also, it allows to perform better analysis during runtime.

However, for interpreters, an AST causes more overhead than a bytecode interpreter, because of nodes related to syntax performing no useful work, of a less sequential representation (requiring traversal of more pointers) and of overhead visiting the tree.[5]

Just-in-time compilation

Further blurring the distinction between interpreters, byte-code interpreters and compilation is just-in-time compilation (or JIT), a technique in which the intermediate representation is compiled to native machine code at runtime. This confers the efficiency of running native code, at the cost of startup time and increased memory use when the bytecode or AST is first compiled. Adaptive optimization is a complementary technique in which the interpreter profiles the running program and compiles its most frequently-executed parts into native code. Both techniques are a few decades old, appearing in languages such as Smalltalk in the 1980s.[6]

Just-in-time compilation has gained mainstream attention amongst language implementers in recent years, with Java, the .NET Framework and most modern JavaScript implementations now including JITs.

Applications

  • Interpreters are frequently used to execute command languages, and glue languages since each operator executed in command language is usually an invocation of a complex routine such as an editor or compiler.
  • Self-modifying code can easily be implemented in an interpreted language. This relates to the origins of interpretation in Lisp and artificial intelligence research.
  • Virtualisation. Machine code intended for one hardware architecture can be run on another using a virtual machine, which is essentially an interpreter.
  • Sandboxing: An interpreter or virtual machine is not compelled to actually execute all the instructions the source code it is processing. In particular, it can refuse to execute code that violates any security constraints it is operating under.

Punched card interpreter

The term "interpreter" often referred to a piece of unit record equipment that could read punched cards and print the characters in human-readable form on the card. The IBM 550 Numeric Interpreter and IBM 557 Alphabetic Interpreter are typical examples from 1930 and 1954, respectively.

See also

Notes and references

  1. ^ In this sense, the CPU is also an interpreter, of machine instructions.
  2. ^ According to what reported by Paul Graham in Hackers & Painters, p. 185, McCarthy said: "Steve Russell said, look, why don't I program this eval..., and I said to him, ho, ho, you're confusing theory with practice, this eval is intended for reading, not for computing. But he went ahead and did it. That is, he compiled the eval in my paper into IBM 704 machine code, fixing bug, and then advertised this as a Lisp interpreter, which it certainly was. So at that point Lisp had essentially the form that it has today..."
  3. ^ AST intermediate representations, Lambda the Ultimate forum
  4. ^ A Tree-Based Alternative to Java Byte-Codes, Thomas Kistler, Michael Franz
  5. ^ http://webkit.org/blog/189/announcing-squirrelfish/
  6. ^ L. Deutsch, A. Schiffman, Efficient implementation of the Smalltalk-80 system, Proceedings of 11th POPL symposium, 1984.

External links

This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.


Translations:

Interpreter

Top

Dansk (Danish)
n. - oversætter, tolk, fortolker

Nederlands (Dutch)
tolk, vertolker

Français (French)
n. - interprète, (Comput) traductrice, interpréteur (un programme)

Deutsch (German)
n. - Interpret, Dolmetscher

Ελληνική (Greek)
n. - διερμηνέας, (Η/Υ) διερμηνευτής, λογισμικό μετάφρασης

Italiano (Italian)
interprete

Português (Portuguese)
n. - intérprete (m) (f)

Русский (Russian)
устный переводчик, интерпретатор

Español (Spanish)
n. - intérprete, actor, traductor

Svenska (Swedish)
n. - tolk, återgivare, framställare

中文(简体)(Chinese (Simplified))
直译程序, 翻译员, 解释者

中文(繁體)(Chinese (Traditional))
n. - 直譯程式, 翻譯員, 解釋者

한국어 (Korean)
n. - 해석자, 통역자, 연출자

日本語 (Japanese)
n. - 解釈者, 説明者, 通訳者, 通訳, 解説者

العربيه (Arabic)
‏(الاسم) المترجم ( بين متحدثين بلغتين مختلفتين)‏

עברית (Hebrew)
n. - ‮פרשן, מתורגמן - מתרגם בע"פ, תוכנית מחשב המבצעת תוכנית שורה-שורה‬


Post a question - any question - to the WikiAnswers community:

Copyrights:

Mentioned in

PostScript emulation (technology)
interpreted language (technology)