Introduction to Programming

Module 1 · Introduction to Programming · Lesson 7 of 7

Compilation vs interpretation: pros & cons

Neither approach is simply “better.” Each buys an advantage by accepting a cost somewhere else. Here's how they line up on the things that matter most in day-to-day programming.

CompilerInterpreter
Execution speed
Fast — already machine code
Slower — translated each run
Portability
Binary tied to one platform
Same code runs anywhere
Debugging & iteration
Recompile to test a change
Run instantly, edit, repeat
Distribution
Ship one file, hide the source
Needs source + an interpreter
When errors show up
Many caught before it runs
Surface at runtime

Compiling shines when speed and distribution matter: the program is already machine code, so it runs fast, and you can ship a single file without the source. The price is flexibility — the binary is built for one kind of machine, and every change means compiling again.

Interpreting trades raw speed for convenience: the same code runs anywhere the interpreter exists, and you can change a line and run it instantly. That fast, forgiving feedback loop is a big reason Python is such a friendly place to start — and exactly what the rest of this course builds on.