Module 1 · Introduction to Programming · Lesson 5 of 7
Compilation vs interpretation
High-level code has to be turned into machine instructions before it can run. There are two classic ways to do it, and the difference is mostly when the translation happens.
Compiler · translate all, then run
x = 2y = 3print(x + y)
⚙ program.exe▶ 5
Interpreter · run line by line
▸
x = 2y = 3print(x + y)
▶ 5
A compiler translates your whole program ahead of time into a standalone machine-code file. After that, the computer runs the file directly — the original source isn't needed anymore.
An interpreter takes a different route: it reads your source and runs it line by line, translating on the fly each time the program runs. Python works this way — which is why the next lesson looks at exactly what an interpreter does.