An interpreter is a language translator that translates and executes a high-level program line by line.
An interpreter is a language translator that translates and executes a high-level program line by line.
An interpreter reads one statement, translates it, executes it, and then moves to the next statement.
| 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 |
Compiler = Whole Program | Interpreter = Line by Line
Interpreters are commonly associated with languages and environments such as Python, JavaScript, Ruby and PHP.
| 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 |
Watch an easy explanation of interpreter and its line-by-line execution process.
A short handwritten-style revision sheet for Interpreter is covered in the study notes above.
Use the mind map for quick revision of interpreter working and compiler comparison.