Notes
What is an Interpreter?
An interpreter is a language translator that
translates and executes a high-level program
line by line.
💡 In Simple Words
An interpreter reads one statement, translates it,
executes it, and then moves to the next statement.
How an Interpreter Works
SOURCE PROGRAM
↓
INTERPRETER
↓
READ ONE LINE
↓
TRANSLATE
↓
EXECUTE
↓
NEXT LINE
Example Process
- Read the first statement.
- Translate the statement.
- Execute the statement.
- Move to the next statement.
- Continue until the program ends or an error occurs.
Important Characteristics
-
Translates and executes the program line by line.
-
Generally does not create a separate executable file.
-
If an error occurs, execution can stop at that point.
-
Makes testing and debugging easier because errors can be identified
during execution.
-
Execution is generally slower than already compiled code.
Interpreter vs Compiler
| Feature |
Compiler |
Interpreter |
| Translation |
Whole program |
Line by line |
| Execution |
After compilation |
During interpretation |
| Speed |
Generally faster at runtime |
Generally slower |
| Error Handling |
Reports errors during compilation |
Can stop when an error is encountered |
| Executable File |
Generally produced |
Separate executable generally not produced |
📌 Remember
Compiler = Whole Program
|
Interpreter = Line by Line
Examples
Interpreters are commonly associated with languages and environments
such as Python, JavaScript, Ruby and PHP.
Advantages of an Interpreter
- Easy to test and debug.
- Errors can be identified during execution.
- No separate executable file is generally required.
Limitations of an Interpreter
- Generally slower execution than compiled code.
- The source program is interpreted during execution.
Quick Revision
| Point |
Remember |
| Input |
High-level source program |
| Method |
Line-by-line translation and execution |
| Executable |
Separate executable generally not produced |
| Error |
Execution can stop when an error is encountered |
Important Exam Questions
Short Answer Questions
- What is an interpreter?
- How does an interpreter work?
- What is line-by-line translation?
- Write any three characteristics of an interpreter.
- Give examples of languages commonly associated with interpreters.
Long Answer Questions
-
Define an interpreter and explain its working.
-
Explain the characteristics, advantages and limitations of an interpreter.
-
Differentiate between compiler and interpreter.
📝 Handwritten Notes
A short handwritten-style revision sheet for Interpreter
will be provided here.
🧠 Mind Map
Use the mind map for quick revision of interpreter
working and compiler comparison.