Compiler:
The name “compiler” is primarily used for programs that translate source code from a high-level programming language to a lower level language. A compiler is likely to perform many or all of the following operations: lexical analysis, preprocessing, parsing, semantic analysis, code generation, and code optimization.
Interpreter:
Interpreter is a computer program that executes, or performs, instructions written in a computer programming language. The term interpreter may refer to a program that executes source code that has already been translated to some intermediate form, or it may refer to the program that performs both the translation and execution
Compiled Languages Vs Interpreted Languages
The programming languages are generally classified as Compiled Languages (e.g. C, Pascal, CPP) and interpreted Languages (Python, Perl, Shell script). There is nothing specific about a language, which restricts it to being a “Compiled Language” or an “Interpreted Language”. For example both “Compilers” and “Interpreters” are available for PERL. Generally the classification is made based on most popular implementations.
Hybrid Languages:
There are some languages which are both Compiled and Interpreted. The source code is compiled to generate an intermediate code, which can be later run on different platforms using Interpreters. Java is an example of such intermediate language. Java source code is first compiled to give “Java Byte Code”. The JAVA byte code can be run on any platform using “Java Virtual Machines” (interpreter for JAVA).
Performance:
(a) Interpreter translates (does inline compilation) the code before executing it. Hence executing a source by interpreter (which includes both translation and execution) is slower than executing a compiler generated binary code (compiler actually generates object files which are later used by linker to generate binary executables). Interpreter does fresh compilation of the code, each time the code is executed.
(b) Run time memory requirements for a code being executed by interpreter is more as compared to memory requirements for executing a binary code. This is because, “interpreter program” is also running at the same time, which will have its own memory requirements.
(c) Interpreted languages are platform independent. The program can be run on any platform without any changes (provided that there is interpreter support on the platform). This is the greatest advantage of “Interpreted Languages”. Java, has gained immense popularity on mobile platforms, because the same code (Byte code) can be run on any machine (with JVM support available). Compiled languages require a new compilation (which generates machine specific code) for each platform.
Thursday, September 13, 2007
Subscribe to:
Posts (Atom)