Difference between Interpreted & Compiled Languages

Most of the computer languages you will come into contact with are either interpreted or compiled. The important difference between these two paradigms is how a program is executed. For an interpreted language, like Scheme, a program is executed (the Interpreter) which then executes the user program written in the interpreted language by translating them on the fly into whatever language the computer can understand natively.

Whenever you write a program, you use some kind of editor/programming environment to write the code for the program that will do what you want it to do.

In case of complied languages, a system program (the Complier) is started which translates the program that is written in a high level programming language (examples of high level programming languages are C, C++, Pascal, Java, Fortran) into a language that the computer understands. This translation process is named the compilation. During compilation, compiler prompts the user for any errors. Once compiled, program can be executed repeatedly without the need for re-compiling. An advantage of compiled code is that it can be taken to any machine with the same CPU for execution and it doesn’t require compiling again. Examples of compiled languages are C, Perl, CGI.

In the case of interpretation (when computer program is Interpreted), the translation happens when the user program is executed; thus it must be retranslated each time it is run. When the program runs, a program known as an interpreter reads each line and converts it to machine code at that time, and then executes it. Essentially, it gets compiled every time it is run. This process is also known as “compilation on the fly”.

An interpreter sits in between the machine itself and your program. When you run the program you are really running the interpreter, which reads, through your code one line at a time, firing translated, interpreted statements at the computer in its mother tongue. Example of interpreted languages are JavaScript, VBScript, HTML.

 

Comparison of Interpreted & compiled languages

 

Compiled Languages have been preferred over Interpreted Scripting Languages for performance reasons, because in the later case an additional Program, the interpreter, has to be running to translate commands in the text file on the fly.

Compiled code always has the potential to be faster than interpreted code. Ultimately, all interpreted code needs to be converted to machine level instructions at some point and this amounts to compiling at the time of execution.  Another reason why compiled code is preferred over interpreted code is that compiled code has already been translated into machine code and error detection is an inherent part of compilation process and so once compiled, it’s error free. In contrast, with interpretation error checking happens at the time of execution.

 

Interpretation is desireable however in a client server environment and in particular in case od Web-based systems when a program needs to execute on the client.