A computer program can run in many ways. 
A computer program can run in many ways. 
This helper can turn code into a middle step. This makes the code run faster. It can also run on many different machines. You do not need a new version for every machine.
Some helpers work very quickly. They can even act like a different computer. This is helpful for testing new ideas. It is a clever way to use code.
Computers run code in different ways. One way is to use an interpreter. An interpreter is software that runs code directly. It does not turn the code into machine code first. 
Most programs use a compiler. A compiler translates code into machine code before it runs. This can be slow for the person writing the code. An interpreter can be faster for testing new ideas. It lets you change and run code quickly. This is called a short edit-build-run cycle.
Some interpreters use a middle step. They turn the code into bytecode. Bytecode is an intermediate format. This helps the code run faster. Some systems use just-in-time compilation. This is also called JIT. It turns bytecode into machine code while the program is running. This gives you the best of both worlds.
Interpreters are very useful. They can act like a virtual machine. This lets one computer act like a different kind of system. This is helpful for emulation. Emulation is when one system mimics another. You can also use them for sandboxing. This helps keep a computer safe by blocking bad code.
An interpreter is a special kind of software. It allows a computer to run source code directly. Most programs use a compiler to work. A compiler translates code into machine code before it ever runs. An interpreter does not do that first step. Instead, it executes the code as it reads it. 
How does an interpreter work? It often uses a middle step to be faster. It might turn the source code into bytecode first. Bytecode is an intermediate format that is easier to read. Some systems use just-in-time compilation, or JIT. JIT turns that bytecode into machine code while the program is running. This helps the program run at a high speed. 
Interpreters have a long and interesting history. In the early days, compilers were much more common. This was because old hardware could not support interpreters easily. However, people used interpreters as early as 1952. They helped programmers work around limited storage space. The first high-level language to use an interpreter was Lisp. 
There are many specific facts about how they are used. Interpreters are often used for commands and scripts. They are also used for virtualization. This is when an interpreter acts like a virtual machine. It can even emulate a different computer system. 
Using an interpreter is like having a live translator. A compiler is like a book translator who finishes the whole book first. An interpreter translates each sentence as you speak it. This makes the process slower for the computer. This extra work is called interpretive overhead. 
In the world of computing, an interpreter is a specific type of software. Its primary job is to execute source code without first translating it into machine code. Most programs rely on a compiler to perform this translation before the program ever runs. An interpreter, however, processes the instructions as it reads them. This creates a different kind of runtime environment. Instead of running CPU-native executable code, the computer follows the interpreter's direct instructions. This flexibility allows the same code to run on any platform that possesses a compatible interpreter. This is a major advantage over compiled code, which often requires a unique version for every different platform.
How an interpreter functions depends on the specific design used. Some interpreters translate source code into an intermediate format called bytecode. Bytecode is a middle-ground format that is easier for the software to process than raw text. To improve speed, many modern systems use a hybrid approach called just-in-time (JIT) compilation. In a JIT system, the computer translates the bytecode into machine code while the program is actually running. This method attempts to combine the flexibility of an interpreter with the high speed of compiled code. This is how popular environments like Java and .NET manage to run efficiently.
There are several distinct ways to implement an interpreter. One method uses an abstract syntax tree (AST). An AST interpreter transforms the source code into a tree-like structure that represents the program's logic. The software then traverses this tree to execute the commands. Another method is the bytecode interpreter, which processes the intermediate format mentioned earlier. Some specialized systems use a threaded code interpreter. Instead of using bytes, a threaded interpreter uses pointers to jump between different instruction sequences. Finally, a template interpreter maintains an array of bytecode mapped directly to native machine instructions. This design makes the interpreter behave very much like a JIT compiler.
The history of interpretation began in the early days of computing. During that era, compilers were much more common than interpreters. This was because early hardware often lacked the resources to support both an interpreter and the code it was running. However, interpreters were used as early as 1952 to help programmers work around hardware limits. They helped manage small storage spaces and provided support for math functions that the hardware could not do natively. The first high-level language to use an interpreter was Lisp. Steve Russell implemented the first Lisp interpreter on an IBM 704 computer. He took a theoretical paper by John McCarthy and turned the "eval" function into working machine code. This moment essentially created the form of Lisp that we use today.
As computing evolved, the need for interactive systems changed how interpreters were built. In the 1960s, the introduction of time-sharing systems allowed many users to access one computer at once. This made editing interpreters essential for managing code in real-time. One notable early example was the EDT system, developed for the PDP-1 computer in the late 1960s. EDT allowed users to edit and debug programs using commands and macros. This helped pave the way for the modern text editors and development environments we use now. Today, interpreters are still vital for running commands, scripts, and managing virtual machines.
While interpreters are useful, they do come with a specific cost known as interpretive overhead. This is the extra time and processing power required to run code through an interpreter instead of running native machine code. Interpreting is generally slower because the software must perform multiple steps for every single instruction. For example, accessing variables is slower because the interpreter must repeatedly map names to storage locations during runtime. However, this speed trade-off is often worth it for developers. The shorter "edit-build-run" cycle allows for much faster prototyping and testing. Developers can change a line of code and see the results almost instantly.
Interpreters also play a massive role in complex modern systems like virtualization and emulation. An interpreter can act as a virtual machine to run code designed for a different hardware architecture. It can even emulate an entire computer system to run software written for a completely different machine. Furthermore, interpreters can be used for sandboxing. This provides a layer of security by allowing the software to block code that violates specific rules. Because of these diverse capabilities, interpreters remain a fundamental pillar of computer science and software development.
🖼️ Images & Media (1)
More to explore
✨ What else?
Related topics you might enjoy
🔬 Go deeper
More advanced topics to explore
🪜 Step back
Simpler topics to build understanding
What is Nepedia?
A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.