The Need for Speed
By Al Williams
There's an old saying that you can never be too rich or too thin. For computer programs it might be better to say you can't be too fast or too small.
Over the years many have tried to speed up programs using a variety of techniques collectively known as optimization. Even Java is not immune to these attempts. Vendors have improved the Java Virtual Machine (JVM) and provided Just in Time (JIT) compilation.
For most Java programmers, optimization hasn't been a big concern. This is partly because of the inherent problems with optimizing Java. Another reason is that many applets are not time critical anyway. On top of that, the Internet is traditionally slower than your average program. All of that is changing, however. Today's applets are more and more performing the work of traditional desktop applications. More users than ever have high-bandwidth connections, too, so optimization is becoming more critical than ever.
Problems with Optimization
The main reason Java programs are more difficult to optimize than other types of programs is, as often stated, Java's "write once, run everywhere" philosophy.
Java programs don't execute directly on the user's computer. Instead, the computer's JVM executes the byte code. That means the JVM determines, to a large extent, how fast or slow your code will run.
Even on the same operating system you might find different JVMs. Some JVMs interpret code one byte at a time.