Module: M4-R5: Internet of Things (IoT)
Chapter: Ch1 Computer Intro
Compilation is the process of converting high-level source code written by a programmer (like C, Java, or C++) into a machine-readable form (binary or object code) that the computer’s processor can execute directly.
In simple terms, a **compiler** acts as a translator between humans and computers — it takes your code and transforms it into a format the machine understands.
Let’s consider a simple example in **C language** (since Python is an interpreted language):
// hello.c
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
When we compile this file using gcc hello.c -o hello, it goes through all the above steps and produces an executable file hello.
Python doesn’t use a traditional compiler like C or C++. Instead, it uses an **interpreter** that executes code line by line. However, internally Python converts source code (.py) into **bytecode (.pyc)** which is then executed by the **Python Virtual Machine (PVM)** — so it does involve a kind of compilation step, but it’s not visible to the user.