What Does Interpreter Mean?
An interpreter is a computer program that is used to directly execute program instructions written using one of the many high-level programming languages.
The interpreter transforms the high-level program into an intermediate language that it then executes, or it could parse the high-level source code and then performs the commands directly, which is done line by line or statement by statement.
Techopedia Explains Interpreter
Humans can only understand high-level languages, which are called source code. Computers, on the other hand, can only understand programs written in binary languages, so either an interpreter or compiler is required.
Programming languages are implemented in two ways: interpretation and compilation. As the name suggests, an interpreter transforms or interprets a high-level programming code into code that can be understood by the machine (machine code) or into an intermediate language that can be easily executed as well.
The interpreter reads each statement of code and then converts or executes it directly. In contrast, an assembler or a compiler converts a high-level source code into native (compiled) code that can be executed directly by the operating system (e.g. by creating a .exe program).
Both compilers and interpreters have their advantages and disadvantages and are not mutually exclusive; this means that they can be used in conjunction as most integrated development environments employ both compilation and translation for some high-level languages.
In most cases, a compiler is preferable since its output runs much faster compared to a line-by-line interpretation. Rather than scanning the whole program and translating it into machine code like a compiler does, the interpreter translates code one statement at a time.
While the time to analyze source code is reduced, especially a particularly large one, execution time for an interpreter is comparatively slower than a compiler. On top of that, since interpretation happens per line or statement, it can be stopped in the middle of execution to allow for either code modification or debugging.
Compilers must generate intermediate object code that requires more memory to be linked, contrarily to interpreters which tend to use memory more efficiently.
Since an interpreter reads and then executes code in a single process, it very useful for scripting and other small programs. As such, it is commonly installed on Web servers, which run a lot of executable scripts. It is also used during the development stage of a program to test small chunks of code one by one rather than having to compile the whole program every time.
Every source statement will be executed line by line during execution, which is particularly appreciated for debugging reasons to immediately recognize errors. Interpreters are also used for educational purposes since they can be used to show students how to program one script at a time.