Interpreter
Also known as: Language interpreter
Program that executes instructions written in a programming language directly, statement by statement, without first producing a standalone executable.
An interpreter runs a program by reading its source code, or an internal representation of it, and carrying out the instructions as it goes, rather than translating the whole program into machine code beforehand. Running a Python script typically means handing it to the Python interpreter, which executes it immediately. Interpreters make the edit-and-run cycle very short and allow interactive sessions, called read-eval-print loops or REPLs, in which a programmer types an expression and sees its result at once. Shells such as Bash are interpreters for command languages.
The line between interpreters and compilers is blurry. Many interpreters first translate source code into a compact intermediate form called bytecode and then execute that on a virtual machine; CPython, the standard implementation of Python, works this way. Others go further with Just-in-Time compilation, turning frequently run code into machine code while the program runs. Historically, Steve Russell implemented the first Lisp interpreter in the late 1950s after realizing that John McCarthy's eval function could be turned into working code, and interpreted BASIC made programming accessible on home computers of the 1970s and 1980s.
Interpretation trades speed for flexibility. Executing instructions through an extra layer is usually slower than running native machine code, often by a large factor in tight loops, although for many programs the time is dominated by waiting on networks or disks. In return, interpreters offer portability, since the same source runs anywhere the interpreter does, along with dynamic features such as evaluating code generated while the program runs. Many languages popular for scripting, data analysis and teaching, including Python, Ruby and JavaScript, began as interpreted languages.
Key points
- An interpreter executes a program directly instead of producing a standalone executable in advance.
- Many interpreters compile source code to bytecode first and then run it on a virtual machine.
- Interactive interpreters, known as REPLs, let programmers test expressions and see results immediately.
- Interpretation is generally slower than native execution but offers portability and dynamic flexibility.
Related entries
Compiler
Program that translates source code written in one programming language, usually a high-level one, into another form such as machine code.
Just-in-Time Compilation
Technique that compiles code into native machine instructions while a program is running, combining interpreter flexibility with compiled speed.
Python
High-level, general-purpose programming language created by Guido van Rossum, known for readable syntax and widely used in data science and AI.
Bash
Unix shell and command language written for the GNU Project, long the default interactive shell and scripting language on Linux systems.
Lisp
Family of programming languages originated by John McCarthy in 1958, built on symbolic expressions and long associated with AI research.
Steve Russell
American programmer who led the creation of Spacewar!, one of the earliest and most influential digital video games, at MIT in 1962.
JavaScript
High-level programming language of the web, created at Netscape in 1995, that runs in every major browser and on servers through runtimes like Node.js.
Shell Scripting
Writing programs for a command-line shell, such as Bash, that automate sequences of commands, file operations and system administration tasks.
Featured in guides
Referenced by
Other entries that discuss or point to Interpreter.