Skip to content
Know.itKnow.it
Create a visual lesson
~2 min

Compiler vs. Interpreter: What's the Difference?

TechnologySide-by-sideWritten comparisonAll comparisons

Read the comparison below, or explore it visually. Create a visual lesson comparing compiler and interpreter using available credits or plan allowance.

A compiler translates a whole program into machine code before it runs, producing a separate executable file, while an interpreter reads and executes the source code statement by statement while the program runs. Compiled programs, such as those written in C, usually run faster; interpreted ones, such as Python scripts, are quicker to test and change. Many modern languages combine both approaches.

At a glance

CompilerInterpreter
Translation timingWhole program, before it runsStatement by statement, while it runs
OutputA standalone executable fileNo separate executable file
Run speedUsually fasterUsually slower
Error reportingReports many errors before the program runsStops at the first error it reaches
Example languagesC, C++, Rust, GoPython, Ruby, classic BASIC

Which should you use?

Compiler

A compiler suits software where speed and easy distribution matter, such as a game engine or operating system written in C++ and shipped as ready-to-run executables.

Interpreter

An interpreter suits quick experiments and learning, such as a CBSE student typing Python commands into an interactive shell and seeing each result immediately.

Frequently asked questions

Is Python compiled or interpreted?
Both, in a way. The standard implementation, CPython, first compiles source code into bytecode, then the Python virtual machine interprets that bytecode. Because the user never runs a separate compile step, Python is usually called an interpreted language.
Is Java compiled or interpreted?
Java uses both. The javac compiler turns source code into bytecode, and the Java Virtual Machine runs it, first interpreting it and then using a just-in-time (JIT) compiler to turn frequently used parts into native machine code.
What is a JIT compiler?
A just-in-time compiler translates code into machine code while the program is running, concentrating on the parts used most often. It combines an interpreter's flexibility with much of a compiler's speed and is used for Java, C# and modern JavaScript engines.