Interpreted

Updated: 12/06/2024 by Computer Hope

In computer programming, an interpreted programming language does not need to be compiled before its programs are executed. Instead, another program, called an interpreter, reads the program line by line, translates, and executes it on the fly at run time.

Benefits of compiling vs. interpreting programs

A compiled program generally performs better for the end user because its machine code can be highly optimized during compilation. In contrast, interpreted languages can offer unique benefits to the programmer. One example is a REPL (Read-Eval-Print Loop), which allows the programmer to interact with the program while it is being written.

Many computer languages can be either compiled or interpreted. For instance, the C programming language is usually compiled, but interpreters for C are available. JavaScript is generally considered an interpreted language, where the client (usually a web browser) is the interpreter. However, in most modern browsers, some form of JIT (Just-In-Time) is used to compile JavaScript code before it runs. Lisp, often considered an interpreted language, can mix interpreted code and compiled bytecode in a single program.

What is an interpreted string?

An interpreted string is a string in a programming language that allows variables, expressions, and special characters to be replaced when executed. For example, in the following Perl code, the print line would print the $name variable instead of printing "$name" to return "Hello Nathan."

use strict;
my $name = "Nathan";
print "Hello $name";

In contrast, if the string were a literal string, it would be printed exactly as written in the code.

Tip

Because an interpreted string attempt to interpret any special characters (e.g., dollar sign and quotes), if these characters need to be printed, they'd need to be escaped.

Examples of interpreted languages

Common examples of interpreted programming languages include:

Compiled, Literal string, Programming terms