Interpretation

In the previous lesson, we touched upon how characters are represented in a format that computers understand, such as with ASCII for text. Beyond individual characters, programming code written by humans also needs to be translated into a form that a machine can execute. This process is achieved through either interpretation or compilation (or some mix of the two), depending on the programming language.

R utilizes the interpretation approach. In contrast, other programming languages like C++ or Rust employ the compilation method. While yet other languages like Julia or Java use just-in-time compilation, which mixes the two. To get a full list of these, check out the Explore page. Compilation predates interpretation in computing history, so let's start with this one.

A compiled programming language translates source code, like print("Hello World") into a machine-readable format and saves this translated version into a new file, typically known as an executable. This compilation step can be time-consuming. However, once compiled, the program can be run using this executable. Since it contains instructions in a machine-ready format, the program generally runs efficiently.

On the other hand, an interpreted programming language translates the source code on-the-fly every time it's executed. For instance, when we run print("Hello World") in R, the command is parsed, translated to an internal representation or bytecode, and then executed. If we run the same command again, R goes through the translation process once more. While this might seem less efficient, it's beneficial during development as developers can observe incremental changes and obtain immediate feedback.

As a general observation, compiled languages often provide better runtime performance, while interpreted languages are more convenient to develop new programs in.