When choosing a pro­gram­ming language, two things in par­tic­u­lar need to be taken into con­sid­er­a­tion: the language needs to provide all the necessary building blocks for the planned software project, and pro­gram­ming and im­ple­ment­ing the project should be as simple as possible. Being easy to read and having simple code are essential to ensuring the latter because these char­ac­ter­is­tics make it easier to get started with and learn a pro­gram­ming language, as well as to use it on a daily basis.

In order for the in­struc­tions of a written program to then be un­der­stood by a computer or processor, the source code of modern pro­gram­ming languages must first be converted into a machine-readable form. This is done with either a compiler or an in­ter­preter depending on the pro­gram­ming language. What exactly do these two tools do? And how do they differ from one another?

What is an in­ter­preter?

An in­ter­preter is a computer program which processes the source code of a software project during its runtime (i.e. while it is running) and acts as an interface between the project and the processor. In­ter­preters always handle code line by line so that the in­di­vid­ual in­struc­tions of each line are read, analyzed and converted for the processor one after another. This also applies to recurring in­struc­tions which are executed each time they occur. In­ter­preters use their own internal libraries to process software code: once a line of source code has been converted into the cor­re­spond­ing machine-readable in­struc­tions, it is sent directly to the processor.

The con­ver­sion process is not complete until all the code has been in­ter­pret­ed. It will only stop early if an error has occurred during the pro­cess­ing. This makes debugging much easier since the line of code con­tain­ing the bug is im­me­di­ate­ly iden­ti­fied when the error occurs.

Note

Some of the most popular pro­gram­ming languages which primarily rely on an in­ter­preter when con­vert­ing source code into machine code include BASIC, Perl, Python, Ruby and PHP. These are often referred to as “in­ter­pret­ed languages”.

What is a compiler?

A compiler is a computer program which converts the source code of a software project in its entirety into machine code before it is run. Only then is the project run by the processor which means it has all the in­struc­tions available to it in machine code right from the start. The processor thus has all the necessary parts ready to run the given software, process input and generate output. In many cases, there is a crucial in­ter­me­di­ate step which takes place during the compiling process: before being converted into machine code, most compilers will often first convert it into an in­ter­me­di­ate code (i.e. “object code”) which is often com­pat­i­ble with various platforms and can also be used by an in­ter­preter.

When gen­er­at­ing the code, compilers determine the order in which in­struc­tions are sent to the processor. If the in­struc­tions are not dependent on one another, the processor can even execute the in­struc­tions si­mul­ta­ne­ous­ly.

Note

Included among the pure compiled languages, you will find the in­flu­en­tial languages C, C++ and Pascal.

Compilers vs. in­ter­preters: overview of the dif­fer­ences in a table

Both compilers and in­ter­preters are used to convert written software code into a machine-readable ex­e­cutable format. Computer proces­sors require this converted code in order to run programs in languages such as C, C++, PHP, Python and Ruby which makes these two tools essential for using desktop computers, laptops and smart­phones. The brief de­scrip­tions given above have already shown that there are important dif­fer­ences between compilers and in­ter­preters which must be taken into con­sid­er­a­tion, par­tic­u­lar­ly when choosing the right pro­gram­ming language for new software. The following table sum­ma­rizes the most important points when comparing compilers and in­ter­preters:

In­ter­preter Compiler
When is the source code is converted? when the software is running before the software is run
Con­ver­sion procedure line by line always the full code
Code error no­ti­fi­ca­tion after each line collected after it is fully compiled
Con­ver­sion speed high low
Con­ver­sion ef­fi­cien­cy low high
Amount of de­vel­op­ment work low high
Common languages PHP, Perl, Python, Ruby, BASIC C, C++, Pascal

By con­sid­er­ing the dif­fer­ences between compilers and in­ter­preters, you can see their re­spec­tive strengths and weak­ness­es when it comes to con­vert­ing source code. Programs with in­ter­preters can be run im­me­di­ate­ly and can thus be started much more quickly. De­vel­op­ment is also much easier than if a compiler were used because the debugging process (i.e. cor­rect­ing errors) is performed with the con­ver­sion line by line. Software using a compiler must first convert all the code before debugging can happen and before the ap­pli­ca­tion can be started. However, once the program is running, the compiler is no longer needed, while an in­ter­preter will continue to use computing power.

Advantage Dis­ad­van­tage
In­ter­preter simpler de­vel­op­ment process (specif­i­cal­ly in terms of debugging) in­ef­fi­cient con­ver­sion process and slow execution speed
Compiler Sends the complete ready-to-use ex­e­cutable machine code to the processor any changes made to the code (e.g. debugging, software ex­ten­sions etc.) will require it to be converted again

A hybrid solution combining compilers and in­ter­preters: the just-in-time compiler

There is another model available called the just-in-time compiler which addresses the weak­ness­es of each con­ver­sion solution. This special type of compiler, which is sometimes called a compreter (a port­man­teau of compiler and interpreter) does not function like normal compilers. It converts the source code during its execution just like in­ter­preters. This results in a sim­pli­fied de­vel­op­ment process in addition to the high execution speed (thanks to the compiler).

Java is one of the best-known examples of a language which relies on just-in-time com­pi­la­tion: As a part of the Java Runtime En­vi­ron­ment (JRE), a JIT compiler improves the per­for­mance of Java ap­pli­ca­tions by con­vert­ing pre­vi­ous­ly generated bytecode into machine code at runtime.

Go to Main Menu