An interpreter is a program that executes instructions written in a high-level language. Interpreters enable other programs to run on a computer or server. They process program code at run time, checking the code for errors line by line.
INTERPRETER VERSUS COMPILER
An interpreter translates high-level instructions into an intermediate form, which it then executes. In contrast, a compiler translates high-level instructions directly into machine language. Compiled programs generally run faster than interpreted programs. Compilers see all errors upon compilation, which must all be resolved before the program can run. Since the errors have all been fixed by runtime, the program will run more quickly.
Interpreted programs typically run more slowly than compiled programs, because interpreters translate code one section at a time. An interpreter requires a discovered error to be fixed before the program can continue running.
The advantage of an interpreter, however, is that it does not need to go through the compilation stage during which machine instructions are generated. The compilation process can be time-consuming if the program is long. An interpreter, on the other hand, can immediately execute high-level programs.
Interpreters are sometimes used during the development of a program, when a programmer wants to add small sections at a time and test them quickly. Interpreters are also often used in education because they allow students to program interactively.
Both interpreters and compilers are available for most high-level languages. However, BASIC and LISP are especially designed to be executed by an interpreter. In addition, page description languages, such as PostScript, use an interpreter. Every PostScript printer, for example, has a built-in interpreter that executes PostScript instructions.
Dynamic and static typing
Dynamic and static typing have to do with how data types in a program are handled at compilation time. Dynamically typed programs don’t require data types to be checked for accuracy until the program runs; statically typed programs require type checking at compilation. There is no completely direct connection between typing and using an interpreter or compiler. Interpreters can translate both dynamically and statically typed code, and compilers can also compile both static and dynamic programs.