The interpreter is a program that carries out source code translation line by line, it translates High-level code into machine code line by line, the interpreter is a line-by-line translator. The interpreter is procedural and sequential as it carries out the translation line by line and will highlight the error on per line basis.
Interpreter code execution time is higher, due to line-by-line translation debugging is much faster than compiler-based debugging.
High level -> line by line translation -> executable at run time
(The interpreter will interpret the code line by line).
Space complexity in the case of the interpreter is lower as the interpreter will not need high memory space as it is carrying out line-to-line translation and execution.
High-level source code will be passed through the interpreter and machine code will be generated at run time and will be executed line by line, if an error occurs the interpreter will show the error and will stop execution till the error is fixed.
The interpreter will execute the code at run time and will not generate an executable, In the case of the compiler the executable is generated which is portable. In the case of interpreters the output will be generated on the fly and code execution will stop as soon as the error is encountered.
Compiled code is more portable than interpreted code.
Compiler vs interpreter
Compiler: The high-level code which consists of objects, functions, classes, libraries, dependencies, etc needs to be translated into machine code/executable, the executable is rendered in the case of compiler-based source code translations. High level language will be compiled to executables which can be directly executed by the CPU.
Interpreter: When the run-time source code translation is done via interpreter the CODE will be translated and output will be generated on a real-time basis and line by line basis.
C++ and C java are compiler-based high-level languages where the high-level source code is compiled into machine code which will be executed by the CPU.
NOTE: assembler is also used to translate the assembly code to machine code, assembler for X86 and ARM architecture are different, assembler is designed based on the CPU architecture, and the learning curve of coding in assembly is way higher than any high-level programming language.
Diagrams
The article above is rendered by integrating outputs of 1 HUMAN AGENT & 3 AI AGENTS, an amalgamation of HGI and AI to serve technology education globally.