What Is Programming? Compiled vs Interpreted Languages – What Beginners Need to Know
So you’ve decided to learn programming — brilliant! But now you’re hearing words like compiler, interpreter, libraries, packages. Feeling overwhelmed?
Don’t worry — this post explains everything using something everyone understands: cooking.
Quick Analogy: Programming Is Like Cooking
Real Life | Programming |
---|---|
You (the chef) | You (the programmer) |
Recipe in another language | Code (C++, Python, etc.) |
Robot cooks | Computer hardware |
Translator | Compiler / Interpreter |
Spice mixes & sauces | Libraries / Packages |
You want your robot cooks (your computer) to follow your recipe (your code), but they only understand machine language (1s and 0s). So you need a translator — either a compiler or an interpreter — to help.
Compiled Languages (e.g. C, C++)
Analogy: You translate the entire recipe before cooking starts.
How It Works
- You write your recipe in C/C++.
- A compiler translates the entire code into machine language.
- Your computer runs the translated version quickly and efficiently.
C code → compiler → machine code → run
Pros
- Very fast after translation
- Can be optimised to run better (e.g. simplify steps, reuse values)
Cons
- Slower to start — you must compile before running
- Harder to debug — errors show up after full translation
What You Need to Install
- A compiler (e.g.
g++
) - Optional libraries (e.g. for graphics, maths, sound)
How to Make a .exe File (C++)
When you compile C++ code using g++
, it already creates a .exe
file on Windows:
1
g++ hello.cpp -o hello.exe
Double-click the .exe file to run your program without the terminal!
Want a Basic Graphical Interface (UI)?
Use a library like WinAPI, SFML, or Qt (a bit more advanced):
1
2
3
4
5
6
#include <windows.h>
int main() {
MessageBox(0, "Hello!", "Greeting", MB_OK);
return 0;
}
Compile it the same way — and your .exe pops up a window!
Interpreted Languages (e.g. Python)
Analogy: A live translator reads the recipe step-by-step as you cook.
How It Works
- You write your recipe in Python.
- An interpreter reads and runs each line in real time.
Python code → interpreter reads line-by-line → runs immediately
Pros
- Quick to start and test
- Easy to fix mistakes — interpreter stops exactly where the error happens
Cons
- Slower performance — it reads as it goes
- Less optimised — it doesn’t improve your code
What You Need to Install
- Python interpreter
- Packages (e.g. numpy, pandas)
- Package managers like pip or conda
How to Make a .exe File (Python)
Python normally runs in the terminal, but you can convert your script to a .exe file using:
1
2
pip install pyinstaller
pyinstaller --onefile hello.py
This creates dist/hello.exe — now your Python script runs like a standalone app!
Want a Basic Graphical Interface (UI)?
Use the built-in Tkinter module:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import tkinter as tk
def say_hello():
name = entry.get()
label.config(text="Hello, " + name + "!")
root = tk.Tk()
root.title("Greeting App")
entry = tk.Entry(root)
entry.pack()
button = tk.Button(root, text="Say Hello", command=say_hello)
button.pack()
label = tk.Label(root)
label.pack()
root.mainloop()
Save as hello_gui.py, then convert to .exe:
1
pyinstaller --onefile --windowed hello_gui.py
Now you have a basic .exe app with a window interface!
Why It Matters in Machine Learning
- Python is the go-to language — easy to write, read, and test ideas.
- Behind the scenes, tools like TensorFlow and PyTorch use compiled C++ for performance.
- It’s like Python is the friendly head chef, and C++ is the super-fast robot sous chef.
Side-by-Side Comparison
Feature | Compiled Language (C/C++) | Interpreted Language (Python) |
---|---|---|
Translator | Compiler | Interpreter |
When Code Runs | After compiling | While reading each line |
Speed | Very fast | Slower |
Debugging | Harder — fix after compile | Easier — errors show up live |
Beginner-Friendly? | Less — more setup | Yes — quick to try things |
Used in ML? | Yes — behind the scenes | Yes — main interface |
What to Install | Compiler + Libraries | Interpreter + Packages |
Can Make .exe ? | Yes — auto from compiler | Yes — using PyInstaller |
UI Option | WinAPI, Qt, SFML (advanced) | Tkinter (built-in) |
Let’s Try a Simple Program: “Hello, {Your Name}”
1 - Python (Interpreted Language)
What to install:
- Python interpreter
- Any text editor (e.g. Notepad or VS Code)
Code:
1
2
name = input("What's your name? ")
print("Hello, " + name + "!")
Run:
1
python hello.py
Make into .exe:
1
pyinstaller --onefile hello.py
2 - C++ (Compiled Language)
What to install:
- A C++ compiler like g++
- A text/code editor
Code:
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
int main() {
string name;
cout << "What's your name? ";
cin >> name;
cout << "Hello, " << name << "!" << endl;
return 0;
}
Compile & run:
1
2
g++ hello.cpp -o hello.exe
./hello
Your .exe is ready to share!
Final Thought
Knowing whether your language is compiled or interpreted is like knowing whether you’re cooking from scratch or using a meal kit.
- Want full control and speed? Compiled languages are great.
- Want fast results and simplicity? Interpreted languages like Python are perfect.
- Want a real .exe app with buttons? You can do it in both — just pick your tool.
Programming is like cooking — it’s not about having the fanciest kitchen. It’s about learning the basics, experimenting, and making things that work.