Interpreter (computer): Difference between revisions
imported>G. Del Merritt mNo edit summary |
imported>G. Del Merritt m (add some links to existing text) |
||
Line 1: | Line 1: | ||
==Overview== | ==Overview== | ||
In computer science, an interpreter is anything that turns one set of instructions into another set of instructions that are then immediately (or nearly immediately) executed. In the abstract, "instructions" can be anything. But to most computer scientists, an interpreter can be considered two "steps away" from getting code to run on a particular platform. | In computer science, an interpreter is anything that turns one set of instructions into another set of instructions that are then immediately (or nearly immediately) executed. In the abstract, "instructions" can be anything. But to most computer scientists, an interpreter can be considered two "steps away" from getting code to run on a particular platform because the command (or instruction or statement) being interpreted must then be mapped to a machine instruction and then executed. Contrast an interpreter with a [[Compiler|compiler]]. | ||
An interpreter is itself a computer program that runs in a loop of: | |||
# get a statement | # get a statement | ||
Line 10: | Line 10: | ||
===Example=== | ===Example=== | ||
An analogy from outside computer science is the homologous "interpreter" of human languages. If Al can only speak in English, and Frank can speak in English or French, and Gretchen can only speak French or German, then Al can only communicate verbally with Gretchen by using Frank as his interpreter. (In this example, Gretchen can can also use Frank communicate back to Al, which, while interesting, is currently less commonly considered as a function of being an interpreter in the computer science domain.) Taken a step further, Al can call Frank and order a product. Frank, in turn, can call Gretchen in order to get the order fulfilled. | An analogy from outside computer science is the homologous "interpreter" of human languages. If Al can only speak in English, and Frank can speak in English or French, and Gretchen can only speak French or German, then Al can only communicate verbally with Gretchen by using Frank as his interpreter. (In this example, Gretchen can can also use Frank communicate back to Al, which, while interesting, is currently less commonly considered as a function of being an interpreter in the computer science domain.) Taken a step further, Al can call Frank and order a product. Frank, in turn, can call Gretchen in order to get the order fulfilled. Notice that there is (usually) an immediacy of translation in the act of interpretation. Contrast this with, for instance, the translation of a book from one language into another. | ||
A more specific example within computer science is the popular Perl language. Perl is itself a program implemented in the C | A more specific example within computer science is the popular Perl language. Perl is itself a program implemented in the [[C programming language]]; C is a compiled language. Perl, however, has a set of commands (or statements or instructions or operators) that it "understands" and allows programmers to use. The Perl interpreter will take statements in its language and cause them to be run (or "executed") on the user's system "on the fly". Contrast this with a compiler, which also takes a set of commands but instead generates "object" code that cannot itself be immediately run on the user's system without additional processing. | ||
==Deeper look== | ==Deeper look== | ||
Line 26: | Line 26: | ||
Some common and popular interpreters are: | Some common and popular interpreters are: | ||
* Perl | * [[Perl]] | ||
* Python | * [[Python programming language|Python]] | ||
* Basic (also commonly compilable) | * Basic (also commonly compilable) | ||
* Java's byte-code interpreter | * [[Java platform|Java]]'s byte-code interpreter | ||
* The non-GUI command line processor of a "terminal", e.g., bash, sh, csh, tcsh, ksh, (all popular Unix/ | * [[Javascript]] | ||
* The command interface - GUI or text-based - to databases, e.g., SQL | * The non-GUI command line processor of a "terminal", e.g., [[bash]], [[sh]], [[csh]], [[tcsh]], [[ksh]], (all popular [[Unix]]/[[Linux]] command shells) and Microsoft's command.exe, which is sometimes called "the DOS prompt" | ||
* The command interface - [[GUI]] or text-based - to databases, e.g., [[SQL]] | |||
[[Category:CZ Live]] | [[Category:CZ Live]] | ||
[[Category:Stub Articles]] | [[Category:Stub Articles]] | ||
[[Category:Computers Workgroup]] | [[Category:Computers Workgroup]] |
Revision as of 19:16, 24 March 2008
Overview
In computer science, an interpreter is anything that turns one set of instructions into another set of instructions that are then immediately (or nearly immediately) executed. In the abstract, "instructions" can be anything. But to most computer scientists, an interpreter can be considered two "steps away" from getting code to run on a particular platform because the command (or instruction or statement) being interpreted must then be mapped to a machine instruction and then executed. Contrast an interpreter with a compiler.
An interpreter is itself a computer program that runs in a loop of:
- get a statement
- convert the statement into something that can "execute"
- execute the statement
- go back to #1 and start all over again
Example
An analogy from outside computer science is the homologous "interpreter" of human languages. If Al can only speak in English, and Frank can speak in English or French, and Gretchen can only speak French or German, then Al can only communicate verbally with Gretchen by using Frank as his interpreter. (In this example, Gretchen can can also use Frank communicate back to Al, which, while interesting, is currently less commonly considered as a function of being an interpreter in the computer science domain.) Taken a step further, Al can call Frank and order a product. Frank, in turn, can call Gretchen in order to get the order fulfilled. Notice that there is (usually) an immediacy of translation in the act of interpretation. Contrast this with, for instance, the translation of a book from one language into another.
A more specific example within computer science is the popular Perl language. Perl is itself a program implemented in the C programming language; C is a compiled language. Perl, however, has a set of commands (or statements or instructions or operators) that it "understands" and allows programmers to use. The Perl interpreter will take statements in its language and cause them to be run (or "executed") on the user's system "on the fly". Contrast this with a compiler, which also takes a set of commands but instead generates "object" code that cannot itself be immediately run on the user's system without additional processing.
Deeper look
It is in fact the case that the line between an "interpreter" and a "compiler" can be a bit blurry. An example of this is the Java language. Java statements - which are reminiscent of the C and C++ languages in form - are first compiled into "byte-code". This byte-code is a compact equivalent of the original source. The byte code can then be interpreted by the Java run-time environment and run on the target platform/system. Another blurring of the line is typical of embedded systems, wherein a very complex device - e.g., a printer or a mouse - has one or more interpreters that allow it to communicate with other systems or peripherals.
The ultimate interpreter in a system is the hardware that executes "machine code".
Popular Interpreters
There are many interpreted computer languages. Some may also support being compiled. As noted above, sometimes the line is difficult to draw.
Some common and popular interpreters are:
- Perl
- Python
- Basic (also commonly compilable)
- Java's byte-code interpreter
- Javascript
- The non-GUI command line processor of a "terminal", e.g., bash, sh, csh, tcsh, ksh, (all popular Unix/Linux command shells) and Microsoft's command.exe, which is sometimes called "the DOS prompt"
- The command interface - GUI or text-based - to databases, e.g., SQL