W1082 Interpretation vs Compilation

From Coder Merlin

Interpretation vs. Compilation[edit]

Some languages provide a REPL environment. REPL stands for Read-Evaluate-Print-Loop. This means that a program reads input, evaluates this input and performs any indicated operations, and then prints the output before looping back to read the input again. You're already familiar with one such environment, Bash. Languages which support this type of environment are known as interpreted languages.

A REPL environment does not require access to all of the source code before beginning to evaluate the input. An analogy would be translating from English to Spanish where each sentence is read to a translator in English and then the corresponding sentence in Spanish is received before moving on to the next sentence.

An alternative approach is ECRD. ECRD stands for Edit-Compile-Run-Debug. This type of approach requires that the entire source be in a compiled form before any of the code is executed (run). After the code is run changes may be made to the source to fix errors (debug) and then the entire process begins again. An analogy would be translating from English to Spanish where the entire source document is sent to a translator and then the entire translated document is received. Languages which support this type of environment are known as compiled languages.

Each approach has strengths and weaknesses. In general, speed of development is faster when using an interpreted language because immediate feedback is received by the developer. However, there is a higher overhead because each line must be interpreted each time it is executed. The source code of a compiled language is compiled into very efficient code that can be executed an arbitrary number of times. Thus, the overhead for translation (compilation) is incurred only once. Note that some languages support both interpretation and compilation.

References[edit]