Difference between Interpreter and Compiler

Key Difference: Interpreters translate high level programming instructions into intermediate codes and then execute the resulting codes. Compilers translate high level programming language codes into the object codes. Interpreters execute code line by line, whereas compilers execute the resulting files.

Interpreter and Compiler play a very important role in execution of programs in a computer language. Many people tend to think that both of them are similar to each other. However, they both differ in various contexts.

We can only communicate with computers in their language. Computers only understand the binary language of 0’s and 1’s. However, most of the programs are written in high languages and thus, needs to be translated in the binary form. Interpreter and compiler are both programs which translate the language of programs into computer understandable machine language. You might think that both are serving the same purpose then how they both are different to each other.

The biggest difference between the two is that a compiler directly changes the source code into the machine language, whereas an interpreter produces a middle code and then executes this code in order to form a machine understandable code. Interpreters and compilers have same task of translating the source code into the machine code, but they differ in the means of achieving this translation. Compliers possess diagnostic capabilities and thus, while compiling a high level program they can prompt  appropriate error messages. In the case of an interpreter, object code is not stored and thus, cannot be reused.

A compiler produces an object code before creating an executable file for the same. The compiled program is directly executed using the object code. On the other hand, an interpreter executes the source code by reading one line at a time. During the time of execution, the native code is performed line by line. Both compilers and interpreters are written in high level programming languages. For example, a java interpreter can be written in Java, Pascal, etc. Both have their own set of advantages and disadvantages. Both the approaches can be mixed to attain a hybrid approach. For example, in LISP language, development is done in a LISP interpreted environment. The resulting modules are then well tested and can be compiled by the LISP compiler. The differences are listed below in the table:-

 

Compiler

Interpreter

Definition

High level instruction into machine language

High level instruction into an intermediate code

Execution

Entire program at one time

Line by line

Speed

Fast

Slow

Cost

Low-cost

Less

Memory Usage

More

Usually large amount of money

Unauthorized Modification

Difficult (To understand the flow of program is a complex task)

Easy (To understand the flow of program is a simple task)

Debugging

Difficult

Easy

Execution of resulting code

By Computer Hardware

By Another program

Example

 C compiler

BASIC

Running Computer

Any

Interpreter installed

Images Courtesy: cs.uaf.edu

Most Searched in Arts and Humanities Most Searched in Environment
Most Searched in Home and Garden Most Searched Non-Alcoholic Drinks
HTML5 vs PHP
Web Hosting vs Web Publishing
Hyundai i20 vs Maruti Suzuki Swift
Nokia Lumia 925 vs iPhone 5

Add new comment

Plain text

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.