from : http://reality.sgi.com/shiffman/Java-JIT.html
: Portable Programming - Peter J.L.Wallis
Computer Software has always been dismayingly expensive
to write. In fact it is getting more and more expensive as computer usage
grows and increasingly sophisticated software is needed. At the same time,
hardware costs are falling as newer and more advanced hardwares are built.
So, more different and demanding hardware are available in the market nowadays,
and we need different versions of computer programs (software) specific
to the hardware even more.
Each kind of computer has its own instruction set. While some processors
include the instructions for their predecessors, it's generally true that
a program that runs on one kind of machine (computer)
won't run on another. Add in the services
provided by the operating system, which each system describes in its own
unique way, and you have a compatibility problem.
In general, you can't write and compile a program for one kind of system
and run it on any other without a lot of work. In other words, most programs
are not portable, and this causes problems
for multi-platform users.
JAVA gets around this limitation by inserting its virtual
machine between the application and the real environment (computer
+ operating system). If an application is compiled to Java bytecode and
that bytecode is interpreted the same way in every environment then you
can write a single program which will work on all the different platforms
where JAVA is supported. (That's the theory, anyway. In practice there
are always small incompatibilities lying in wait for the programmer.) Hence,
a probable solution for the portability problems is JAVA.
How is JAVA portable
from : http://tech8.informatik.uni-hamburg.de/Dokumentation/java/doc.alpha3/
Easy. JAVA is an architecture
neutral language. As stated in article1, the
JAVA compiler generates JAVA Virtual Machine codes instead of machine codes
specific to the computer system we are using.
These Virtual Machine codes, or JAVA bytecodes,
are all architecturally neutral; the compiled codes are executable on any
processors and systems, provided of course, that the JAVA Virtual machine
(interpreter) is installed in those systems. So, basically, the compiler
generates bytecode instructions which have nothing to do with a particular
computer architecture. Rather, they are designed to be both easy to interpret
on any machine and easily translated into native code.
Being architecture neutral is a big chunk of being portable, but there's
more to it than that. Unlike C and C++, there are no "implementation dependent"
aspects of the specification. The sizes of the primitive data types are
specified, as is the behavior of arithmetic on them. For example, "int"
always means a signed two's complement 32 bit integer, and "float"
always means a 32-bit IEEE 754 floating point number. Making these choices
is feasible in this day and age because essentially all interesting CPU's
share these characteristics. The libraries that are a part of the system
define portable interfaces.
The best part is that the JAVA system
itself is quite portable. The new compiler is written in JAVA and the runtime
is written in C with a clean portability boundary.
Okay, okay. JAVA is portable. So what? Well, being architecturely-neutral,
Java applications are ideal for a diverse environment like the Internet
(!!). More of this in JAVA and the WWW.
So, in general, JAVA appears to be a dream come true. Portability
of software across all computing platforms with advantage over C++ over
and garbage collection
- mundane sounding until you have to do it manually. Does this mean there
will be more JAVA and fewer C++ applications written in the future? Yes,
to article2 Main Page