Computers only understand machine code — binary instructions specific to their processor. The programs we write in Python, Java, or any other high-level language must first be translated into machine code before they can run. Two different types of program perform this translation: compilers and interpreters. At KS3, understanding the difference between them is a key exam topic.

What is the difference between high-level and low-level languages?

Programming languages exist on a spectrum from low-level to high-level, based on how close they are to the hardware.

Low-level languages — machine code (binary) and assembly language — are closely tied to the processor. Machine code is directly executable by the CPU but is almost impossible for humans to write or read. Assembly language uses short mnemonics (like MOV, ADD, JMP) as a thin layer above machine code.

High-level languages — Python, Java, C#, JavaScript — are designed to be readable by humans. They use words and structures close to English and mathematical notation. A single high-level statement can represent dozens of machine code instructions.

The trade-off: high-level languages are easy to write and maintain, but the CPU cannot execute them directly. They must be translated first.

What is source code?

Source code is the program as the human programmer writes it — in Python, Java, C, or any other high-level (or assembly) language. It is stored as text and is readable.

Machine code (also called object code) is the binary representation of instructions that the CPU can execute directly. It is specific to the processor architecture (e.g. Intel x86, ARM) and is not human-readable.

Intermediate code (such as Python bytecode or Java bytecode) sits between the two: it is not specific to one hardware platform, but it requires a runtime environment to execute.

What is a compiler?

A compiler is a program that translates the entire source code of a program into machine code (or intermediate code) before the program runs. The translation step is called compilation. The output is a standalone executable file.

The process:

Source code (.py / .java / .c)
        │
        ▼
    COMPILER
        │
        ▼
Machine code executable (.exe / binary)
        │
        ▼
  Runs directly on the CPU

Key characteristics of compilation:

  • Translation happens once — run the executable as many times as you like without retranslating.
  • Faster at runtime — no translation overhead while the program runs.
  • All errors reported before running — the compiler checks the entire program before producing an executable. If there are errors, it reports them all at once and produces no executable.
  • Platform-specific — a compiled Windows executable cannot run on macOS without recompilation.

Examples of compiled languages: C, C++, Rust, Go, Fortran.

What is an interpreter?

An interpreter is a program that translates and executes source code line by line, at runtime. There is no separate compilation step and no standalone executable produced.

Source code (.py)
        │
        ▼
  INTERPRETER (reads and executes one line at a time)
        │
        ▼
  Program runs while being translated

Key characteristics of interpretation:

  • Translated and executed simultaneously — the interpreter reads each line, translates it, executes it, then moves to the next line.
  • Slower at runtime — translation overhead at every execution.
  • Errors discovered at runtime — the interpreter stops at the first error it encounters and reports it. Lines before the error will already have executed.
  • Platform-independent — the same source code runs on any platform that has the correct interpreter installed.
  • Easier to debug interactively — you can run one line at a time, inspect variables, and experiment.

Compiler vs interpreter: side-by-side comparison

Feature Compiler Interpreter
Translation timing Before execution (all at once) During execution (line by line)
Output Standalone executable file No separate output file
Execution speed Fast (no translation at runtime) Slower (translates as it runs)
Error reporting All errors reported before running Stops at first error encountered
Source code on target machine Not needed (once compiled) Always needed
Cross-platform Requires recompilation per platform Runs anywhere the interpreter is installed
Typical languages C, C++, Rust, Go Python, Ruby, early JavaScript

Which does Python use?

Python is primarily an interpreted language, which is why it is popular in education: you can type a single line into the Python shell, press Enter, and see the result immediately. This makes it ideal for learning, testing ideas, and teaching programming concepts step by step.

Technically, CPython (the standard Python implementation) does compile source code to bytecode (.pyc files) as an intermediate step, but this bytecode is then executed by the Python Virtual Machine (PVM), not directly by the CPU. At KS3 and GCSE, Python is treated as interpreted.

Languages like C and C++ use traditional compilers. Java uses both: a compiler produces bytecode, which a Just-In-Time (JIT) interpreter/compiler then executes. These details are typically GCSE or A-level territory.

Frequently asked questions

What is the difference between a compiler and an interpreter at KS3?

A compiler translates the entire source code into machine code before the program runs, producing a standalone executable. An interpreter translates and executes the source code line by line at runtime, without producing a separate file. Compiled programs run faster; interpreted programs are easier to debug and run on any platform with the appropriate interpreter.

Why is Python an interpreted language?

Python was designed with ease of use and readability as priorities. An interpreter allows you to run Python code interactively — typing one line and seeing the result immediately — which is extremely useful for learning, data exploration, and prototyping. The trade-off is slower execution compared to compiled languages, which matters less than it used to given modern processor speeds.

What is source code?

Source code is the program as written by the human programmer, in a high-level language such as Python, Java, or C. It is human-readable text that must be translated into machine code (either by a compiler or interpreter) before the CPU can execute it.

What happens when a compiler finds an error?

A compiler analyses the entire source code before producing any output. If it finds syntax errors or type errors, it lists them all and refuses to produce an executable. This means you must fix all compilation errors before you can run the program at all. An interpreter, by contrast, stops at the first error it encounters at runtime — lines that ran before the error will already have executed, which can make debugging different (and sometimes harder) than with a compiled language.


For Socratic computing tutoring at KS3 and GCSE — see aitutors.me.