Interpreter vs Compiler: What’s the Difference?
Source: Dev.to

Interpreter vs Compiler – What’s the Difference?


When we write code, the computer does not understand it directly.
Computers only understand machine language (0s and 1s), so programming languages use translators to convert human‑readable code into machine‑readable code.
There are two main types of translators:
- Interpreter
- Compiler
Let’s understand both in a very simple way 👇
What is an Interpreter?
An interpreter reads and executes code line by line.
How it works
- Reads one line of code
- Converts it to machine language
- Executes it
- Moves to the next line
If an error occurs, the program stops immediately.
Key Points of Interpreter
- Executes code line by line (slower execution)
- Stops at the first error
- No executable file is created
Languages That Use an Interpreter
- JavaScript
- Python
- PHP
- Ruby
Example (JavaScript)
console.log("Hello");
console.log(a); // error
console.log("World"); // this will not run