Is Java Slow?

There are plenty of developers who believe that “Java is slow”. Much of their beliefs, however, are not based on experience of developing in Java. Rather they are simply repeating what other people have told them, or what they have read somewhere on the Net. The problem is: it’s not really true. Java isn’t slow.

So why the misconception? Well, back when the Java platform was first released ten years ago, it was indeed pretty slow. But times have changed. If you’re interested in understanding some of the reasons why Java performance has increased to the point where it’s suitable for developing most types of application, I recommend checking out Jeff Kesselman’s Wiki page on Java performance.

Jeff’s page is written from the perspective of developing games in Java; so he doesn’t talk about Swing - Java’s GUI framework. There are misconceptions about the performance of this too. Swing is the world’s most popular GUI framework, and it’s almost one of the most flexible and powerful frameworks around. However, the flexibility comes at a price: if you’re not careful about the way you construct your GUI’s, performance can tail off. The main culprits here are events. If you try to have many listeners on a given GUI component (an event source), and you generate change events at high frequency (e.g. tens of times per second), then you can run into performance problems. These can be really severe. I remember having lunch with the CEO of a software company a few years ago, and he told me they had recently been experimenting with Java. However, they had quickly abandoned the evaluation, because when they got to the point of trying to develop a test GUI - just putting a button on the screen - the performance had been truly terrible. I can’t remember what I said, but I do remember deciding that my company wouldn’t be doing business with his. I knew that Java performance was fine (we had been developing performant Java GUIs for years at that time), and that if they couldn’t make it work, that was down to the quality of their developers.

Finally, one area of performance that Java hasn’t yet solved is start-up time. When you start a Java application, there can be a significant lag before the application starts compared to say a C/C++ program (although it should be noted that not all C/C++ software starts rapidly either). Whilst this isn’t an issue for long-lived programs that run on a server, it’s not ideal for client GUI programs, especially small utility programs. The next version of Java (Mustang) aims to improve the start-up time of the platform - how significant this improvement will be, remains to be seen. However, the start-up lag isn’t as bad as it used to be, and it’s not bad enough that you should rule out developing GUI-based software in Java. It’s just something to be aware of.

The bottom line is: Java isn’t slow anymore. In fact, it hasn’t been slow for more than a few years now. Just thought you’d like to know ;-)

Post a Comment

Your email is never published nor shared. Required fields are marked *

*

*