A compiler is like a super-smart translator who turns your whole story into another language all at once, while an interpreter reads your story line by line and translates it as they go.
Imagine you're telling a joke to two friends: one is a compiler, the other is an interpreter.
The Compiler Friend
Your compiler friend listens to your whole joke first, then thinks about how to say it in another language, like turning "I ate 10 pizzas" into a fancy sentence that a robot can understand. Once they're done, they tell the robot the full translated joke all at once.
The Interpreter Friend
Your interpreter friend listens to one part of your joke at a time. They translate each line as you say it, like turning "I ate 10 pizzas" into robot language right when you say it. So the robot hears the joke piece by piece, as you tell it.
Both friends help robots understand what you're saying, just in slightly different ways!
Examples
- A compiler turns all the code into a game before it starts, while an interpreter checks each move as the game goes on.
- A compiler is like a chef who prepares the entire meal ahead of time; an interpreter is like someone who cooks each dish as you ask for it.
Ask a question
See also
- How Does 6 Coding Concepts You MUST Know For Beginners Work?
- How Does 6 Coding Concepts for Absolute Beginners Work?
- How Does 99% of Developers Don't Get Semaphores Work?
- How Does Continue (From This Point) Work?
- How does a Computer understand your Program?