Prerequisite – Assembler, Compiler and Interpreter
All high level languages need to be converted to machine code so that the computer can understand the program after taking the required inputs.
The software by which the conversion of the high level instructions is performed line-by-line to machine level language, other than compiler and assembler, is known as INTERPRETER. If an error is found on any line, the execution stops till it is corrected. This process of correcting errors is easier as it gives line-by-line error but the program takes more time to execute successfully. Interpreters were first used in 1952 to ease programming within the limitations of computers at the time.
It translates source code into some efficient intermediate representation and immediately execute this.
Source programs are compiled ahead of time and stored as machine independent code, which is then linked at run-time and executed by an interpreter. An Interpreter is generally used in micro computer. It helps the programmer to find out the errors and to correct them before control moves to the next statement.
Interpreter system performs the actions described by the high level program. For interpreted programs, the source code is needed to run the program every time. Interpreted programs run slower than the compiled programs.
Self-Interpreter is a programming language interpreter which is written in a language which can interpret itself.
For Example- BASIC interpreter written in BASIC. They are related to self-hosting compilers. Some languages have an elegant and self-interpreter such as Lisp and Prolog.
Need of an Interpreter :
The first and vital need of an interpreter is to translate source code from high-level language to machine language. However, for this purpose Compiler is also there to satisfy this condition.
The compiler is a very powerful tool for developing programs in high-level language. However, there are several demerits associated with the compiler. If the source code is huge in size, then it might take hours to compile the source code, which will significantly increase the compilation duration. Here, Interpreter plays its role. They can cut this huge compilation duration. They are designed to translate single instruction at a time and execute them immediately.
Advantage and Disadvantage of Interpreter :
- Advantage of interpreter is that it is executed line by line which helps users to find errors easily.
- Disadvantage of interpreter is that it takes more time to execute successfully than compiler.
Applications of Interpreters :
- Each operator executed in a command language is usually an invocation of a complex routine, such as an editor or compiler so they are frequently used to command languages and glue languages.
- Virtualization is often used when the intended architecture is unavailable.
- Self-modifying code can be easily implemented in an interpreted language.
- Emulator for running Computer software written for obsolete and unavailable hardware on more modern equipment.
Some examples of programming languages that use interpreters are Phyton, Ruby, Perl, PHP and Matlab.
Top Interpreters according to the computer languages –
- Phyton- CPhyton, PyPy, Stackless Phyton, IronPhyton
- Ruby- YARV, Ruby MRI (CRuby)
- JAVA- HotSpot, OpenJ9, JRockIt
- Kotlin- JariKo
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Introduction of Assembler
- Introduction to YACC
- Introduction To Compilers
- Introduction of Compiler Design
- Introduction of Lexical Analysis
- Parsing | Set 1 (Introduction, Ambiguity and Parsers)
- Introduction to Syntax Analysis in Compiler Design
- Introduction of Object Code in Compiler Design
- Difference between Linker and Loader
- Viable Prefix in Bottom-up Parsing
- How to Create a Programming Language using Python?
- Difference between Recursive Predictive Descent Parser and Non-Recursive Predictive Descent Parser
- Loop Optimization Techniques | Set 2
- Difference between GCC and G++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.