What is the difference between a compiler and an interpreter?

A compiler is the one who reads higher level language computer code and converts it into the native machine code or either p-code.
Or in other words we can say that "compiler" converts the program which we understand into the language which machine understands.(e.g., assembly language or machine code).

Interpreter is the computer program which reads the interpreted code such as lisp etc and executes that program , interpreter can translate source code and it immediately execute it also it can execute pre-compiled code in which case the compiler may be part of interpreter.

Interpreter is seen as very slow compared to compilers.
Lets look at the reasons why interpreter is slow.
Interpreter needs to analyze each statement in the program each time it is getting executed and then perform action required the analysis which interpreter do is normally known as Interpretive overhead. In other case compiler allows program to run with fixed and focused context which normally provided by compiler resulting in time saving.

Interpreter also maps the identifiers to storage locations , so variable access is little bit slow in case of interpreter.
This mapping is done in compilers at compile time.

Often we see interpreted code is being used for simple applications which will be most probably used once or twice or in case of prototyping. On the other hand compiled code is better for serious applications.
Share on Google Plus

About Pranav

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment


Post a Comment