Java is an object-oriented language derived from C++ with strong support for networking, threading, and component-oriented development. Java source code is compiled to a form called bytecode which is platform-independent. The bytecode is stored in .class files which can, potentially, be transferred across a network to machines of different types, and then converted by each machine to its native machine code using a VM (Virtual Machine). The VM may do that either by interpreting the bytecode (classic model) or by compiling and running it method by method (when the VM incorporates a JIT — Just-In-Time compiler).
The key to Java's platform independence is simplicity. It achieves this by discarding some of C++ features and adding some of its own:
Java has no pointers.
Java does not have multiple inheritance. The same effect is achieved by implementing interfaces.
Java has no preprocessor (hence no macros).
Java does not allow global variables.
Java has a singly-rooted hierarchy. (Everything is descended from Object).
There is strong support for exception handling — the compiler checks to make sure exceptions are properly caught using Exception classes.
There is also strong support for multithreading — the Thread class allows the programmer to quickly create and control lightweight processes.
As Java is simpler and stricter than C++ it makes some compromises:
Java is slower than C++. Originally the VM would interpret the code line by line, and it could run as much as twenty times slower. Today most code is run with a JIT compiler such as Hotspot and may approach C++ speeds.
Low-level tasks must be done by interfacing with other languages — native methods.
An application (especially an applet) may be limited in what it can do over a network owing to Java's strong security model. In many ways this is a strength of course
Friday, February 8, 2008
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment