Compiler Vs Interpreter: Difference between Compiler and Interpreter

By | July 10, 2014

Compiler Vs Interpreter


1. Compiler takes the source program written in higher level
language and translate whole program into a machine language.
2. A compiler program reads through the entire high-level
language source program, and in two or more passes through it, translate it all
to relocatable machine code programs (object module). Linker links these
relocatable object modules. The output file from the linker is then located to
get absolute address. Finally located program is loaded into memory. Once the
located program is loaded in memory, the entire program can be run without any
further translation. Therefore, it will run much faster than it would if
executed by an interpreter.
3. C and C++ programs are executed in this way.
4. The major disadvantage of the compiler approach is that
when an error is found, it usually must be corrected in the source program and
the entire compile-load sequence repeated.
Compiler Vs Interpreter: Difference between Compiler and Interpreter


1. At a time, an interpreter executes one statement of the
higher level language.
2. The interpreter reads a high level language statement of
the source program, translates the statement into machine code and, if it
doesn’t need information from another instruction, executes the code for that
statement immediately. It then reads the next high level language source
statement, translate it, and executes it.
3. BASIC programs are often executed in this way.
4. The advantage of using interpreter is that if an error is
found, you can just correct the source program and immediately rerun it.

5. The major disadvantage of interpreter approach is that an
interpreted program runs 5 to 25 times slower than the same program will run
after being compiled. The reason is that with an interpreter each statement
must be translated to machine code every time the program is run.
Compiler Vs Interpreter: Difference between Compiler and Interpreter
Lets understand about compiler vs interpreter from below video.

Leave a Reply

Your email address will not be published. Required fields are marked *