By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

What is difference between an Interpreter and a Compiler ?

P: 13
Can any body tell me diff between interpreter and compiler?and which is best and why?with eg
Jun 14 '07 #1
Share this Question
Share on Google+
6 Replies


100+
P: 208
Can any body tell me diff between interpreter and compiler?and which is best and why?with eg

Compilers

- Process each statement into machine code
- The compiler parses each and checks for syntax
- Programs taht are compiled only need to be compiled once (unless changed) and can be run multiple times
- The code also generally runs faster


Interpreter

- Interpreters translate code one line at time
- They execute each line as it's translated
- Basically since it has to interpret the code everytime it runs if you have a large piece of code it'll take a long time.
Jun 14 '07 #2

Expert 10K+
P: 11,448
That is a very old fashioned and not so accurate definition of the two.

A compiler translates one language to another language. Usually the target is
a lower level language than the source language. Consider a sequence of
machine code instructions to be a language too for the purpose.

An interpreter evaluates or executes statements expressed in a language;
interpreters are complementary to compilers. The definition above makes a cpu
an interpreter (in silicon?).

kind regards,

Jos
Jun 14 '07 #3

100+
P: 208
That is a very old fashioned and not so accurate definition of the two.

A compiler translates one language to another language. Usually the target is
a lower level language than the source language. Consider a sequence of
machine code instructions to be a language too for the purpose.

An interpreter evaluates or executes statements expressed in a language;
interpreters are complementary to compilers. The definition above makes a cpu
an interpreter (in silicon?).

kind regards,

Jos
Sorry just going off of what my Prof told me a while ago.
Jun 14 '07 #4

Expert 10K+
P: 11,448
Sorry just going off of what my Prof told me a while ago.
Then your Prof is quite old fashioned and not very accurate ;-)

kind regards,

Jos
Jun 14 '07 #5

100+
P: 208
Then your Prof is quite old fashioned and not very accurate ;-)

kind regards,

Jos
No arguments there :P
Jun 14 '07 #6

P: 13
Compiler:-compiler]
A program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. Thus, a compiler differs from an interpreter, which analyzes and executes each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter.

Interpreter
A program that executes instructions written in a high-level language. There are two ways to run programs written in a high-level language. The most common is to compile the program; the other method is to pass the program through an interpreter.

An interpreter translates high-level instructions into an intermediate form, which it then executes. In contrast, a compiler translates high-level instructions directly into machine language. Compiled programs generally run faster than interpreted programs. The advantage of an interpreter, however, is that it does not need to go through the compilation stage during which machine instructions are generated. This process can be time-consuming if the program is long. The interpreter, on the other hand, can immediately execute high-level programs. For this reason, interpreters are sometimes used during the development of a program, when a programmer wants to add small sections at a time and test them quickly. In addition, interpreters are often used in education because they allow students to program interactively.
Jun 15 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.