The Java Development Environment
One of the key feature of Java is portability. The computer program written in Java language can run of any supported hardware and operating system platform. Simply we can write the source code once and run it anywhere in any kind of OS. Source code in Java are compiled into an intermediate, platform independent code known as byte code. Bytecode is a set of instructions analogous to machine code but intended to be interpreted by the Java Virtual Machine (JVM) written for the host hardware. Unlike compiler which is indeed a very complex programme, a Bytecode interpreter is a much simpler programme, just like JVM. This makes it easy to write a Bytecode interpreter for a new computing platform. Despite the great benefits of compiling into Bytecode, the primary concern is the overhead of interpretation that interpreted programmes that run slower than programmes compiled into native executable code. In fact, this was the primary challenge faced by Java in its early days of introduction in the market. This gap has been lessened by a number of optimisation techniques introduced in the more recent JVM implementations.
(a) Just-in-Time (JIT) Technique One of the techniques known as Just-in-Time (JIT), uses caching technique to improve the start and execution interpreted code, at the cost of extra compilation overhead during execution. Hot-spots parts of the Bytecode that executed frequently are recompiled into faster machine code in order to improve the execution of the hot-spot areas.
(b) Ahead-of-Time (AOT) Technique Occasionally, Ahead-of-Time (AOT) compilation is implemented to achieve maximum performance at the expense of portability. The Java code is compiled directly into native object code like a more traditional compiler. The output of these compiled programmes can only be run on a single architecture.
More sophisticated JVM may use dynamic recompilation, in which the JVM analyses the behaviour of the running programme and selectively recompiles and optimises critical parts of the programme. JIT compilation and dynamic recompilation allow Java programmes to approach the speed of native code without losing portability.
The execution of Java code under the managed environment of JVM also gives the facility to implement automatic memory management. Automatic memory management or popularly known as automatic garbage collection frees programmer from the burden of having to perform the tedious process of manual memory management. The programmer simply determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use.
(a) Just-in-Time (JIT) Technique One of the techniques known as Just-in-Time (JIT), uses caching technique to improve the start and execution interpreted code, at the cost of extra compilation overhead during execution. Hot-spots parts of the Bytecode that executed frequently are recompiled into faster machine code in order to improve the execution of the hot-spot areas.
(b) Ahead-of-Time (AOT) Technique Occasionally, Ahead-of-Time (AOT) compilation is implemented to achieve maximum performance at the expense of portability. The Java code is compiled directly into native object code like a more traditional compiler. The output of these compiled programmes can only be run on a single architecture.
More sophisticated JVM may use dynamic recompilation, in which the JVM analyses the behaviour of the running programme and selectively recompiles and optimises critical parts of the programme. JIT compilation and dynamic recompilation allow Java programmes to approach the speed of native code without losing portability.
The execution of Java code under the managed environment of JVM also gives the facility to implement automatic memory management. Automatic memory management or popularly known as automatic garbage collection frees programmer from the burden of having to perform the tedious process of manual memory management. The programmer simply determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use.
Comments
Post a Comment