⬅ Previous Topic
What is ProgrammingNext Topic ⮕
Introduction to Compilers and Interpreters⬅ Previous Topic
What is ProgrammingNext Topic ⮕
Introduction to Compilers and InterpretersAt a high level, a computer is an electronic machine that follows instructions. But those instructions must be in a language the computer can understand — binary (0s and 1s). As humans, we write code using high-level programming languages, like Python, Java, or C. The key question is: how does this human-readable code become machine-readable binary?
Computers use two main types of tools to understand our code:
Imagine writing a simple instruction to add two numbers. In high-level code, it may look like:
start
set a to 5
set b to 10
set result to a + b
print result
end
The compiler takes this entire block and transforms it into machine code all at once. Then, the CPU executes that binary.
15
Now let’s look at the same pseudocode through the lens of an interpreter. It reads line-by-line:
>> set a to 5
>> set b to 10
>> set result to a + b
>> print result
The interpreter executes each line immediately after reading it. There’s no separate build step — it's real-time.
15
Both compiled and interpreted code must ultimately be translated into machine code, which is binary instructions. These instructions tell the CPU what to do — add, subtract, load data, store data, etc. Each line in your high-level code may translate to multiple binary instructions.
Q: Why can't computers run human-readable code directly?
A: Computers only understand binary. High-level code is for humans. A translator (compiler/interpreter) is required to convert it to binary.
Q: Which is faster: compiled or interpreted?
A: Generally, compiled code is faster because it's already translated to binary before execution. Interpreters add overhead by translating on the fly.
Think of it like this:
Computers don’t understand Python, Java, or C — they understand only machine instructions. Whether your code goes through a compiler or interpreter, it must eventually be transformed into a set of binary instructions that the CPU can execute. Understanding this process is fundamental to grasping how programming works at its core.
⬅ Previous Topic
What is ProgrammingNext Topic ⮕
Introduction to Compilers and InterpretersYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.