Interpreter

A program that reads source code line by line and executes each instruction immediately — translating on the fly rather than producing a standalone executable, like a live translator at a conference rather than a book translator working in advance.


What is it?

An interpreter is one of two strategies for translating human-readable code into something a processor can execute. The other is a compiler.

Where a compiler translates your entire program in advance and produces a standalone executable, an interpreter reads your code one line (or one statement) at a time, translates it, and executes it immediately. There is no separate executable file. The interpreter must be present every time the program runs.1

This makes interpreted languages faster to develop with — you write a line, run it, see the result, adjust. There is no compilation step between writing and running. The trade-off is execution speed: the translation happens at runtime, adding overhead that compiled code does not have.2

Python, Ruby, and JavaScript (historically) are interpreted languages. When you run a Python script, the Python interpreter reads your .py file and executes it line by line.

In plain terms

An interpreter is a live translator at a conference. The speaker says a sentence in French, the translator immediately renders it in English, the audience hears it. No one has a written translation afterward — the translator must be present for every performance.


At a glance


How does it work?

The interpretation loop

An interpreter runs a loop:3

  1. Read the next statement from the source code
  2. Parse it into an internal representation
  3. Execute the corresponding operations
  4. Move to the next statement

This loop continues until the program ends or an error is encountered. If an error occurs, the interpreter stops at that line — unlike a compiler, which would have caught certain errors before execution began.

Think of it like...

A musician sight-reading sheet music. They see a note, play it immediately, then move to the next note. They never practise (compile) the piece in advance. Fast to start, but they cannot optimise their performance because they are always discovering what comes next.

Interactive mode: the REPL

Most interpreted languages offer a REPL — Read, Eval, Print, Loop. You type a single expression, the interpreter evaluates it, prints the result, and waits for the next input.4

This is powerful for experimentation. You can test ideas, inspect data, and debug in real time without writing a complete program. Compiled languages rarely offer this interactive experience.

Bytecode interpreters

Some “interpreted” languages add an intermediate step. Python, for instance, compiles your source code into bytecode — a simplified intermediate format — then interprets that bytecode. This is faster than interpreting raw source code but still requires the interpreter at runtime.5

Java takes this further with just-in-time (JIT) compilation: the Java Virtual Machine interprets bytecode initially, then compiles frequently-used code paths into native machine code during execution. This hybrid approach combines the portability of interpretation with the speed of compilation.6

graph LR
    SRC[Source] -->|pure| INT[Interpreter]
    SRC -->|bytecode| BC[Bytecode]
    BC --> VM[Virtual Machine]
    BC -->|JIT| MC[Machine Code]
    INT --> CPU[CPU]
    VM --> CPU
    MC --> CPU

    style SRC fill:#4a9ede,color:#fff
    style BC fill:#e8b84b,color:#fff
    style MC fill:#5cb85c,color:#fff

Why do we use it?

Key reasons

1. Rapid development. No compilation step means instant feedback. Write, run, adjust, repeat. This loop is tighter and faster than compile-run-debug.

2. Portability. Interpreted code runs on any platform that has the interpreter. A Python script runs on Windows, macOS, and Linux without recompilation.

3. Flexibility. Interpreted languages can evaluate code at runtime, modify themselves, and handle dynamic types. This enables interactive exploration and rapid prototyping.

4. Lower barrier to entry. No build tools, no compilation configuration, no linker errors. Write a file, run it. This is why Python has become the most popular first language.7


When do we use it?

  • Scripting and automation — quick tasks where development speed matters more than execution speed
  • Data science and analysis — interactive exploration of data with immediate visual feedback
  • Web development — JavaScript is interpreted (or JIT-compiled) by the browser
  • Prototyping — testing ideas before committing to a compiled implementation
  • Learning — the REPL provides immediate feedback, which is ideal for beginners

Rule of thumb

If you need to write code quickly and execution speed is acceptable, use an interpreted language. If you need maximum performance or standalone distribution, use a compiled one. Many real projects use both: Python for orchestration, C for performance-critical components.


How can I think about it?

The live translator

An interpreter is like a live translator at an international conference. The speaker says a sentence, the translator immediately renders it for the audience.

Advantages: no preparation needed, the audience hears the message in real time, and the translator can adapt to unexpected changes (improvised remarks, audience questions).

Disadvantages: slower than reading a pre-translated document. The translator must be present every time. And if the speaker says something nonsensical, the translator only catches it at that moment — not before the conference.

The GPS navigator

An interpreter is like a GPS giving turn-by-turn directions. It tells you the next turn only when you reach it. It reacts to your current position in real time.

A compiler is like printing the entire route on paper before you leave. Faster to follow once printed, but if traffic conditions change (a runtime error), the printed directions cannot adapt. The GPS can reroute. The printed directions cannot.


Concepts to explore next

ConceptWhat it coversStatus
compilerThe alternative: translating everything in advancecomplete
runtimeThe environment interpreters provide for running codecomplete
machine-codeWhat the CPU actually executes underneathcomplete

Check your understanding


Where this concept fits

Position in the knowledge graph

graph TD
    AL[Abstraction Layers] --> COMP[Compiler]
    AL --> INTP[Interpreter]
    AL --> MC[Machine Code]
    INTP -.->|compare with| COMP
    INTP -->|uses| RT[Runtime]

    style INTP fill:#4a9ede,color:#fff

Related concepts:

  • compiler — the alternative translation strategy that works in advance rather than on the fly
  • runtime — the environment an interpreter provides for executing code
  • machine-code — the underlying instructions the CPU executes, regardless of translation strategy

Sources


Further reading

Resources

Footnotes

  1. GeeksforGeeks. (2024). Difference Between Compiler and Interpreter. GeeksforGeeks.

  2. Built In. (2024). Compiler vs. Interpreter in Programming. Built In.

  3. Nystrom, R. (2021). Crafting Interpreters. Free online book covering interpreter design from scratch.

  4. Wikipedia. (2026). Read-eval-print loop. Wikipedia.

  5. Python Software Foundation. (2026). Python Developer’s Guide: CPython Internals. Python.org. CPython compiles source to bytecode (.pyc files) then interprets the bytecode.

  6. Oracle. (2026). The Java Virtual Machine. Oracle.

  7. TIOBE Index. (2026). Programming Community Index. Python has held the #1 position since 2021.