🗣️ Interpreter
6th Grade 💻 Coding
An interpreter is a program that reads code and carries it out as it goes, line by line, without first making a complete translated file.
If a compiler is a book translator, an interpreter is a live interpreter at a meeting: it translates and acts on each sentence the moment it’s spoken. The advantage: you can run code right away and try things quickly, which is great for learning. The downside: it’s usually slower than a program that was compiled ahead of time.
Python and JavaScript are usually run by an interpreter (in practice, behind the scenes there’s a mix of both methods). That’s why, when an error happens while the program is running, the lines before it have already run and the lines after it haven’t. In Python, you can also open an interactive window where you type a line and see the result immediately.
For example
- Type
2 + 3in Python’s interactive window, and 5 appears right away. - In a Python program with an error on line 5, the first four lines already ran before the program stopped.
📌 Remember: Interpreter = live translator. Compiler = book translator.
Quick quiz
What does an interpreter do?
Which language is usually run by an interpreter?
Why is an interpreter handy for learning?