its very simple really.
an interpreter reads and executes a program, or more correctly, a script, line by line, one command after the other. Good old BASIC is an example of this, and its modern counterparts, like Visual Basic, Perl or Java Script. This kind of program language is also called Script Language.
A compiler reads the whole program, or, as it is correctly called, the source code, and produces from it an entirely new program, that can be executed. Pascal, C, and C++ are examples for this kind of language.
so much for the general difference. what are the mutual advantages?
a script is of course much quicker to write, and can easily be altered at any time, which makes it much more flexible. on the downside you need to have the interpreter program installed on the computer where you want to execute the program. however, modern operating systems come with a variety of popular interpreters already available. Also the execution speed is slower than with compiled programs, but again, modern computers have enough raw power to handle most scripts smoothly.
in effect this means that the disadvantages of scripting become less and less and its popularity among programmers grows accordingly.
the problem with compiler languages is of course the need to compile the source code into the executable program before you can run it. this is not reversible, so if you want to change anything, you have to change the source code, and compile it all over again. which can take some time. the advantage of this concept are speed and usability. since the compiler, as opposed to the interpreter knows the whole program before it even starts to work, it can govern the computers resources more effectively, thus increasing the executing speed. also you can run the program directly from the operating system, without having to bother with installing any additional software.
it is also a good way to protect your program from plagiation, because while not impossible, it is very difficult to re-engineer a compiled executable.
i hope that answers your question so far.
2006-12-14 21:42:16
·
answer #1
·
answered by wolschou 6
·
0⤊
0⤋
A compiler is a computer program (or set of programs) that translates text written in a computer language (the source language) into another computer language (the target language). The original sequence is usually called the source code and the output called object code. Commonly the output has a form suitable for processing by other programs (e.g., a linker), but it may be a human readable text file.
The most common reason for wanting to translate source code is to create an executable program. The name "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 program that translates between high-level languages is usually called a language translator, source to source translator, or language converter. A language rewriter is usually a program that translates the form of expressions without a change of language.
A compiler is likely to perform many or all of the following operations: lexing, preprocessing, parsing, semantic analysis, code optimizations, and code generation.
An interpreter is a type of translating program which converts high level language into machine code. It translates one statement of high level language into machine code, then executes the resulting machine code, then translates the next instruction of high level language, executes it, and so on. It never translates the whole program of high level language at one time.
During interpretation, the HLL (high level language) program remains in the source form itself (or in some intermediate form), and the actions implied by it are performed by the interpreter.
The advantage of interpretation is that it eliminates the overhead of program translation.
It takes longer to run a program under an interpreter than to run the compiled code but it can take less time to interpret it than the total time required to compile and run it. This is especially important when prototyping and testing code when an edit-interpret-debug cycle can often be much shorter than an edit-compile-run-debug cycle.
Interpreting code is slower than running the compiled code because the interpreter must analyze each statement in the program each time it is executed and then perform the desired action whereas the compiled code just performs the action. This run-time analysis is known as "interpretive overhead". Access to variables is also slower in an interpreter because the mapping of identifiers to storage locations must be done repeatedly at run-time rather than at compile time.
There are various compromises between the development speed when using an interpreter and the execution speed when using a compiler. Some systems (e.g., some LISPs) allow interpreted and compiled code to call each other and to share variables. This means that once a routine has been tested and debugged under the interpreter it can be compiled and thus benefit from faster execution while other routines are being developed. Many interpreters do not execute the source code as it stands but convert it into some more compact internal form. For example, some BASIC interpreters replace keywords with single byte tokens which can be used to find the instruction in a jump table. An interpreter might well use the same lexical analyzer and parser as the compiler and then interpret the resulting abstract syntax tree.
2006-12-14 21:51:14
·
answer #2
·
answered by Anonymous
·
0⤊
0⤋
A compiler breaks down high level code into machine language and generates a binary to be executed. An interpreter interprets code or can also break into down to a level between high level and machine language then another program will be used to execute the code. Compilers: Borland products, Mingw interpreters: java, .Net products where they creates byte code to be interpreted by another program or virtual machine
2016-05-24 19:20:34
·
answer #3
·
answered by Anonymous
·
0⤊
0⤋