Compiled vs. Interpreted Languages
Computers do not understand C++, Java, or Python. They only understand Machine Code (Binary instructions like 101100). How do we get from code to binary?
Compiled Languages (C, C++, Go, Rust)
The Translator Approach.
You write the code. You run a compiler. The compiler reads the entire program, optimizes it, and translates it into a standalone executable file (.exe).
- Pros: Extremely fast execution. The user doesn't need the source code.
- Cons: Slow "build" time. You have to recompile every time you change a line. Platform dependent (a Windows
.exewon't run on Mac).
Interpreted Languages (Python, JavaScript, PHP)
The Simultaneous Interpreter.
You write the code. You give the source code to an interpreter. The interpreter reads line 1, translates it to binary, runs it. Then reads line 2...
- Pros: Instant startup. Easy to debug. Platform independent (runs anywhere the interpreter is installed).
- Cons: Slower execution. The computer is doing translation work while running the program.
JIT (Just-In-Time) Compilation
Modern languages like Java and JavaScript (V8 Engine) use a hybrid.
They start as interpreted (fast start), but the "Hot" parts of the code (functions used often) are compiled into binary in the background while the app is running. This gives near-native speed with the flexibility of a script.