Java
will
be faster than
C++
Kirk
Reinholtz
Jet Propulsion Laboratory
California Institute
of
Technology
4800
Oak Grove
Drive
Pasadena, California
91
109-8099
Mailstop
303-310
lurk.reinholtz@acm.org
Abstract
This
paper
shows that it is possible
for
Java to
have better general performance than C++, and
that it is likely that this will actually
occur.
Java
performance
can
exceed
that of
C++
because
dynamic compilation gives the Java compiler
access to runtime information not available to
a
C++
compiler. This
occur because
the
rapidly growing market for embedded systems
will be driven to extend battery life. Since each
CPU
clock cycle
consumes
some
power, battery
life is extended by improving performance, thus
achieving more computation
per
clock cycle.
Keywords
Java,
C;
C++; compiler performance;
compilers; dynamic compilation; comparative
performance of Java and
C++.
Summary
There are numerous compelling reasons to use Java.
It
is relatively easy to learn and use,
so
training and
debugging costs are reduced. It brings numerous
best computing practices to the general
programming community, in the form of its
extensive and standardized class libraries. Finally,
The research described
in
this paper was carried out by the Jet
Propulsion Laboratory, California Institute
of
Technology, under a
contract with the National Aeronautics and Space Administration.
it
enables new architectures by its ability to easily
send code and data over a network.
Unfortunately, contemporary Java environments
provide deficient performance relative to those of
C++. The low performance of the tools is often taken
to imply that Java itself is inherently less efficient
than
C++,
which generally hinders its adoption.
Trade studies of Java vs.
C++
are often of the form
“is the performance hit worth it?”.
Java, by virtue of its ability to compile the program as
it executes, can achieve performance greater than that
of
C++
because the compiler has access to
information that just isn’t available to a traditional
C++ compiler. There is a lot of work between here
and there, but it can be done.
Java performance
will
constantly improve because
there will be serious money to be had by improving
it
past that possible with
C++.
The reason is that
battery life is a serious concern and powerful market
differentiator in the growing embedded market, and
improved performance improves battery life because
it
basically means more bang per CPU cycle. Each
CPU cycle drains the battery a little bit,
so
the less
CPU cycles used for a given task, the longer the
battery lasts.
There is a lot of work being done today to make Java
suitable for embeddedreal-time development. Once
that work is codified,
it
will narrow the semantic gap
between Java and the embeddedreal-time world.
Java
will
join the set of languages routinely used to
develop embedded and real-time systems, and then
performance
will
be the only thing that stands