To use a scripting language, we need to be able to execute new code on the fly. However, unlike a compiler, there's also another way to convert code into something that can be understood by a machine that is called an interpreter. Interpreters do not produce a program themselves, and rather stay around for the execution of a program. This program will either:
- Execute the source code directly
- Translate the source code into some other efficient intermediate representation (code) and then immediately execute it
- Explicitly execute stored precompiled code made by a compiler that is part of the interpreter system
The interpreter translates one line at a time, as opposed to the compiler doing it all at once.
Visually, it looks a bit like the following:
As you can see here, the Interpreter takes in the Source Code and any Input that has been received, and will then Output what is expected of it.