Re: Java speed: Reality versus theory?

Matthias Kaeppler wrote:
> Hi,
> I just saw this thread popping up asking about speed comparison between
> Java and Delphi. I'd have a slightly different question:
> How come so many people claim Java to be so fast, even write papers
> about how great JIT and the Java runtime in general is compared to other
> languages, but still, each and every Java application I have /ever/ used
> is either slow or so /unbearably/ slow that you can't even work with it
> without ripping your hair out (I don't want to call names, but there are
> quite some very popular development tools written in Java which run
> awfully slow on my 3GHz machine)?
> All those language and tech comparisons are nice and good (for example I
> have read a paper which claimed that heap allocation in Java would be
> way faster than in C++, because it would only take 10 machine
> instructions for the Java virtual machine, but up to 100 in C++), but if
> you leave out the theory, Java doesn't seem to even come close to the
> speed of say, a well written C++ program.
> How come? I think one reason is that Java almost encourages sloppy
> programming. Creating unnecessary temporaries or locals because "the GC
> takes care of it anyway" seems to be common practice in Java; in C++ you
> think /twice/ before allocating anything, especially on the heap.
> Any other ideas? I really think it's an interesting situation: One party
> claiming (even proving) Java to be fast, while actual real-world
> applications show that it's clearly not.

I think the main reasons are:-

* The GUI libraries AWT and Swing are not very fast.(and not really
intended to be)
* Startup is slow because of the overhead of starting up the virtual
* Java programmers often write very OO code and attempt to generalise

I'm sure others know much more about it though. If anyone who has
experience of these things knows otherwise listen to them not me.