Dictionary Definition
interpreted adj : understood in a certain way;
made sense of; "a word taken literally"; "a smile taken as
consent"; "an open door interpreted as an invitation" [syn:
taken]
User Contributed Dictionary
English
Pronunciation
Verb
interpreted- past of interpret
Extensive Definition
In computer
science, an interpreter normally means a computer
program that executes,
i.e. performs, instructions written in a programming
language. 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. An interpreter may be a program that either
- executes the source code directly
- translates source code into some efficient intermediate representation (code) and immediately executes this
- 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 the
Java virtual machine are type 3: Java 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 (virtual machine). Some
systems, such as Smalltalk, and
others, may also combine 2 and 3.
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.
Efficiency
The main disadvantage of interpreters is that when a program is interpreted, it typically runs slower 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 (e.g., 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. For example, some
BASIC
interpreters replace keywords with single byte
tokens which can be used to find the instruction in a jump table. An
interpreter might well use the same lexical
analyzer and parser
as the compiler and then interpret the resulting abstract
syntax tree.
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.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), and then proceeding to execute the program following this tree structure. In this approach each sentence needs to be parsed just once. As and advantage over bytecode, the AST keeps the global program structure and relations between statements (which in a bytecode representation is lost), and provides a more compact representation.Thus, 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. An AST-based
Java
interpreter has been proved to be faster than a similar
bytecode-based interpreter, thanks to the more powerful
optimizations allowed by having the complete structure of the
program available during execution, and with higher
abstraction.
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.Just-in-time compilation has gained mainstream
attention amongst language implementors in recent years, with
Java,
Python and the .NET
Framework all now including JITs.
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.Foot notes
See also
- command line interpreter (a technically related but much simpler form of interpreter)
- interpreted languages
- compiled languages
- dynamic compilation including the section on incremental compilation.
- partial evaluation
- Metacircular Interpreter
External links
- DrPubaGump A tiny Interpreter written in Scheme, which provides to interpret PUBA-GUMP (a subset of BASIC) in Scheme
- IBM Card Interpreters page at Columbia University
interpreted in Arabic: مفسر (برمجة)
interpreted in Czech: Interpret (software)
interpreted in Danish: Fortolker
interpreted in German: Interpreter
interpreted in Estonian: Interpretaator
interpreted in Spanish: Intérprete
(informática)
interpreted in French: Interprète
(informatique)
interpreted in Korean: 인터프리터
interpreted in Croatian: Interpreter
interpreted in Icelandic: Túlkur
(tölvunarfræði)
interpreted in Italian: Interprete
(informatica)
interpreted in Hebrew: מפרש (תוכנה)
interpreted in Lithuanian:
Interpretatorius
interpreted in Hungarian: Értelmező
interpreted in Dutch: Interpreter
interpreted in Japanese: インタプリタ
interpreted in Polish: Interpreter
interpreted in Portuguese: Interpretador
interpreted in Romanian: Interpretor
interpreted in Russian: Интерпретатор
interpreted in Simple English: Interpreter
(computing)
interpreted in Slovak: Interpreter
(programovanie)
interpreted in Serbian: Интерпретатор
interpreted in Finnish: Ohjelmointikielen
tulkki
interpreted in Swedish: Interpretator
interpreted in Thai: โปรแกรมแปลคำสั่ง
interpreted in Vietnamese: Trình thông
dịch
interpreted in Turkish: Yorumlayıcı
interpreted in Ukrainian: Інтерпретатор
interpreted in Chinese: 直譯器