Why It’s Getting Better

In early 1997, Java’s performance lagged C/C++ by a factor of 10 to 20, depending on the application. Now, at least some runtime environments are running Java as fast as they run C. InfoWorld has verified a report by Cats Software in Palo Alto that Java was only 4% to 10% slower than Microsoft’s Visual C++ in a differential equation package.

Before we go into the reasons for the improvements, note that the current performance is quite acceptable for many applications. Java first became popular on the client side, in a web browser, manipulating GUI components. Java does this just fine: it may take 100 milliseconds rather than 10 milliseconds to change the GUI in response to a click or keystroke, but since both are faster than ordinary human perception, the time difference doesn’t matter. Furthermore, as CPUs continue to increase exponentially in power, not only GUI operations, but all common computing operations will have performance rates that are indistinguishable, in human terms, from that of native code. Also, certain fundamental operations like arithmetic and string manipulation are implemented directly in the VM rather than in the Java class libraries that ship with the VM. Since the VM is usually written in C and optimized for a specific platform, these operations are already in native C.

Here are some reasons that Java execution speed will approach that of native code. First of all, Java compilers are continuously improving with respect to the bytecode ...

Get Web Performance Tuning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.