What are Interpreters?
In an earlier article, we looked at compilers and how they convert programs written in higher level programming languages to object level code, which can be executed easily. Now let us look at interpreters. Interpreters are programs that take source code written by a user and execute it line by line. It doesn’t convert the entire program to object level code like compilers first. Interpreters can be designed to work in multiple ways: execute line by line, compile code and execute or translate to an intermediate level code and execute. Interpreters or compilers are an important step in Programming. Examples of interpreted languages are Python, Matlab, Ruby etc. Examples of compiled languages are C, C++, JAVA etc.
Interpreters are good to use, when we need to debug a program as the execution stops whenever an error is encountered. This makes them useful as debugging and training tools. But the time it takes to run a program is higher compared to compilers. Even though compilers convert source code to object code first before executing, they run faster than interpreters as they optimize the code. With interpreters, the code can be easily transferred between machines as it is the source code written in higher level language. Every time the program is run, it has to be interpreted again line by line on the new machine. There are many types of interpreters such as bytecode interpreter, threaded interpreter, hybrid interpreter, self interpreter etc.