-
Hi Sai,
A compiler first takes in the entire program, checks for errors, compiles it and then executes it. Whereas, an interpreter does this line by line, so it takes one line, checks it for errors and then executes it.
Eg of Compiler - Java
Eg of Interpreter - PHP
Hope this clarifies things.
PS - Oh, and sorry for such a late reply 😁 😁
Are you sure? This action cannot be undone.
-
Sunu
Member •
Jan 17, 2008
sai krishna
Hi CEans
As the title suggests can any one breifly explain me the diff. b\n compiler and interpreter
thanks inadvance.
They are both similar as they achieve similar purposes, but inherently different as to how they achieve that purpose. Compiled code takes programs (source) written in some kind of programming language, and then ultimately translates it into object code or machine language. Compiled code does the work much more efficiently, because it produces a complete machine language program, which can then be executed. The interpreter translates instructions one at a time, and then executes those instructions immediately. The compiler is itself a computer program written usually in some implementation language.
Are you sure? This action cannot be undone.
-
interpretor translate the program line by line and compiler translate the entire program interpretor requires less memory and compiler requires more memory
definition of compiler:
Compiler is a program that translates a computer program written on one computer language to another computer language. A "compiler" is primarily used for programs that translate source code from a high level language to a lower level language (e.g., assembly language or machine language). A program that translates from a low level language to a higher level one is a decompiler. A compiler for a relatively simple language written by one person might be a single, monolithic, piece of software. When the source language is large and complex, and high quality output is required the design may be split into a number of relatively independent phases, or passes. Having separate phases means development can be parceled up into small parts and given to different people. It also becomes much easier to replace a single phase by an improved one, or to insert new phases later.
Interpreter is a program that translates an instruction into a machine language and executes it before proceeding to the next instruction..... A high-level programming language translator that translates and runs the program at the same time. It translates one program statement into machine language, executes it, and then proceeds to the next statement. This differs from regular executable programs that are presented to the computer as binary-coded instructions. Interpreted programs remain in the source language the programmer wrote in, which is human readable text. Interpreted programs run slower than their compiler counterparts. Whereas the compiler translates the entire program before it is run, interpreters translate a line at a time while the program is being run. However, it is very convenient to write an interpreted program, since a single line of code can be tested interactively.
Are you sure? This action cannot be undone.
-
Hey Java is both compiled as well as interpreted.The compiler first compiles the source code and gives a .class file .This is then executed by JVM which is the interpreter.
Now, the compiler is a program which takes our whole source code at once and then converts it into machine code or a code closer to machine code in representation.On the other hand the interpreter takes the code line by line and executes it line by line.
The compiler follows the physical sequence and interpreter follows the logical one.
Features like loops are better compiled but those like switch result better execution if interpreted.
Are you sure? This action cannot be undone.
-
can someone illustrate advantages/disadvantages of interpreter over compiler? i mean which one would be preferrable in C++
Are you sure? This action cannot be undone.
-
Compiler and interpretter are both translaters used for converting the source program to computer readable form.
Major difference between compiler and interpretter is that compiler converts the high level language program (source code) to machine readable form as a whole (like C, C++ and Java program -there we write the entire program and then compile and the errors will be shown like 25 errors, 16 errors etc...) while an interpretter converts the HLL to ML line by line (like VB - there we write a statement like if (condition) and if we omit the 'then' statement and press enter - we cant move to second line since the interpretter will show an error and after typing 'then' only we can move to the next line.
Anzil Kasim
#-Link-Snipped-#
Are you sure? This action cannot be undone.
-
kidakaka gave the most precise answer to the question. U can always check wikipedia for more information.
theoretically, in most cases, its the compiler that is better. it checks the entire source code for errors and if error free will execute it. Interpreter does a line check, executes it, then the next line check and so on.
so its better to get notified of errors in beginning itself rather than in between(as in interpreter).
Are you sure? This action cannot be undone.
-
ttyX
Isn't Java supposed to be both compiled & interpreted?
yes,like ashutosh said Java is both compiled and interpreted. Java was designed to be easy to use by coders and they wanted the advantages of both the compilers and interpreters . So they got both into one;-)
In java , the source code is 1st compiled into *.class file by java compiler (javac) and then this *.class file is interpreted and executed by Java Virtual Machine (JVM) as output
Are you sure? This action cannot be undone.
-
compiler
1.compiler can take whole program to complie at a time and execute it.
2.compiler take less time to execute because it takes a whole prog. in a one time.
3.with the help of the compiler one time compile and without modification multitime.
4.compiler runs on compile code.
5.in a compiler there are several steps occur.1.lexical errors 2.syntax errors 3. symmentic errors. and than generate the intermediate code.
6.in a compiler optimize the code.
7.in a compiler reallocation required so it takes more memory.
8.whenevee complex structure complier is used.
9.for example: c,C#,java
interpreter
1.interpreter take line by line,detect errors and than execute it.
2.interpreter takes more time because of line by line execution.
execute.if you modify then again compile than execute.
3.in interpreter everything required for interpret.
4.interpreter runs on source code.
5.in a interpreter that is not generate the ic only three steps occur.
6.in ainterpreter no optimization code.
7.interpreter takes entire program in main memory so no allcation required.
8.whwnever command is used interpreter is used.
9.for example:basic
Are you sure? This action cannot be undone.
-
A compiler converts the entire program into executable code before running, when running the program only the executable version of the code is running.
An interpreter converts the code during run time, it converts the code 1 line at a time at the time that it is running.
_________________
<link removed>
Are you sure? This action cannot be undone.
-
In simple words, compiler is better than interpreter in terms of Performance and Timing. 😀
Are you sure? This action cannot be undone.
-
This topic is pretty much covered, however as others have rightly said an interpreter reads the code line by line then executes it..I should add that only if it gets to that line will it be executed. For example there could be an if function with a syntax error in but if conditions are/aren't met then part of the if function won't run, i.e won't be intepreted
Are you sure? This action cannot be undone.