Reference Book:
Compilers: Principles, Techniques and Tools
Language Processors are tools that process a program written in one language to generate output from a given set of inputs. Compilers and interpreters are popular examples of language processors.
Compiler is a program that takes another program written in some language (known as source language), and translates it into its equivalent program in another language (target language). The output of a compiler is either the translated program, or a list of errors occurred during compilation.
Interpreter executes the program directly line by line, while detailing the errors. As a result, program execution is slower, but error diagnostics is much better than a compiler.
Is Java compiled or interpreted?
Java is a unique case - a Java program undergoes a two-step compilation process as follows:
Step 1 : First the program is compiled into bytecode by the Java compiler.
Step 2 : The bytecode is then either compiled into the target code (native to the hardware) by JIT (Just in Time) compilation, or interpreted directly by the JVM (Java Virtual Machine). Some CPUs even have the ability to execute the programs in bytecode. The provision of bytecodes allow for some cross-platform execution as a program compiled on one machine (the bytecode) can easily be interpreted on another machine).
Saturday, 20 February 2016