Compilers and Interpreters

There are two main types of language translators: compilers and translators. Both Compilers and Interpreters serve as a translator between high-level languages and machine languages. For compilers, after translating all of the high-level language into its equivalent in machine language, the code can be loaded into the machine and run itself. Usually, the high-level language is referred to as the source code and the result the object code.

However, compilers can use up a lot of the computer’s resources, as it must be loaded into the RAM at the same time as the source code. As a solution, interpreters were used. With the interpreter, each line of code is executed as it is entered. This helps the computer to free up memory and at the same time, pinpoint the location of the error the moment it occurs. However, the downside is that the interpreter is slower than the compiler and if the interpreter encounters a loop, it must repeat and re-translate the loop body.

As a result, many languages use both a compiler and a translator. An example of such is Visual Basic. During the program development stage, the interpreter is used to immediately determine the source of the error and fix it. After, when the program is fully working and ready to be published, the compiler is used for efficiency and speed.

Process comparison of compilers and interpreters
The compiling process The interpreting process
The compiling process The interpreting process


Compiler Characteristics and Interpreter Characteristics
Compiler Interpreter
Spends a lot of resources and time analyzing and processing the code Relatively little time spent analyzing and processing the code
Result executable is a machine-specific binary code Resulting code is some sort of intermediate code
Computer executes the resulting code Resulting code is interpreted by another program
Program execution is fast Program execution relatively slow
Difficult to determine exact location of the source of error Pinpoints the location of error immediately