Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was falling for that rhetoric. then I actually tried to do some high performance computing in Java. After a lot of optimizing (and going to non-idiomatic code), it was only x4 slower than the C code it was replacing. The initial "straightforward, idiomatic" code was x10-x50 slower, and taking x5 more memory (which caused it to be totally unusable, as the C code used 1GB of memory, and the machine only had 2).

The computation was really quite simple, but it had to be done a bajillion times. I suspect part of the reason that it was so slow is that the JIT was not inlining something it obviously should have. However, I was unable to find any tools that would help me figure out if that was the case or what the JIT was actually achieving (consulting with Java experts I know didn't give any insight or link to such tools).

If you're telling yourself that "java is good for hi-performance computing", you aren't really concerned with speed or memory.




It really depends on what you're doing. The quirks of the JVM mean there are a lot of hidden things you can do wrong and tank your performance.. JNI calls that you don't realize you're making, or suboptimal use of objects and creating GC debt. Some of the Java math libraries are randomly slow for certain inputs, as well.


That just puts an emphasis on what I said. If there are a lot of hidden things that can go wrong, then in any non-trivial application some of them do, and Java performance is on the average, horrible.

The bigger problem is that there's no reasonable way of figuring out what the problem might be.

And for the record, said code was a tight loop, created no objects, had the same kind of workload of a sort algorithm; The two nontrivial things about it was that it was accessing multiple simple vectors using the same index (non-idiomatic java), and that one of those vectors was a memory mapped buffer (non-idiomatic java, but essential because of the overuse of memory).




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: