Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Performance tests show Java as fast as C++

Java has endured criticism for its laggard performance (relative to C++) since its birth, but the performance gap is closing

  • Print
  • Feedback

Page 7 of 7

The exceptions to this rule are those Java APIs with no native equivalent on the target platform. For example, since the Macintosh does not have any native thread support, it is quite painful to use the Java thread API on a Macintosh.

Real-world example (ASR)

This example is an animation engine created by animation and multimedia guru Jay Bartot. The performance of the Java version in Sun's applet viewer is equal to that of the native Win32 program written using the Win32 SDK.

This example does raise two important points.

First, Java performance is only as good as the JVM. On Windows NT, this program does not perform well under Internet Explorer 4.0 or Netscape Communicator. The animations are stilted and jumpy. When run in these browsers under Windows 95, however, the performance comes close that of the native application.

The performance difference of these browsers represents the browser developers' desire to optimize performance on Windows 95 rather than the embattled Windows NT. Due to the differences in the architectures, it's difficult, if not impossible, to make a complex program like a browser perform well on both operating systems.

Second, Sun's JDK for Win32 is a reference standard that other browsers and JVMs should strive to meet.

Competent preparation prevents poor performance

There seems to be no end to the number of industry spokespersons who will deride Java for poor performance. The same phenomenon occurred when analysts derided the ascension of second-generation languages, then structured programming, and now object-oriented programming. Although each new innovation allows larger, more robust programs, each technology demands a new discipline. Since Java is an object-oriented language, most resistance to its acceptance comes from those who don't understand the advantages of a new paradigm.

This analysis has shown that, in theory and practice, there is rarely any significant performance difference between native C++ and Java applications. And when there is a difference, the Java programmer reaps benefits the C++ programmer does not.

Java provides three such advantages over native C++ programming that will greatly reduce the development time of and enhance the performance of large-scale applications:

About the author

Carmine Mangione is a senior software developer for Netbot Incorporated in Seattle, WA.
  • The reduction of executable and resource size
  • The availability of consistent, robust libraries on most platforms
  • The use of garbage collection to eliminate resource leaks


  • Print
  • Feedback

Resources
  • "CompilersPrinciples, Techniques, and Tools" by Alfred Aho, Ravi Sethi, and Jeffrey Ullman, 1986, Addison-Wesley Publishing Co. http://www.clbooks.com/sqlnut/SP/search/gtsumt?source=javaworld&isbn=0201100886
  • "Crafting a Compiler," Fischer, Charles N., LeBlanc, Richard J. Jr., Benjamin Cummings Press, 1988 http://www.clbooks.com/sqlnut/SP/search/gtsumt?source=javaworld&isbn=0805332014
  • Give us your opinion on the difference in performance between Java and C++. Take our latest reader poll. http://nigeria.wpi.com/cgi-bin/gwpoll/gwpoll/ballot.html