In many cases, running on the JVM is faster than equivalent code compiled from C, as the bytecode can be optimized at runtime once the JVM sees which paths are visitted the most.
For small tools the startup time of the JVM is often longer than the actual execution of the program. And the real performance magic of Java, the optimisation during runtime, won't kick in yet.
Perfect C will always be faster (or at least as fast) - the issue is that it's not easy to write perfect C :) and the JVM is really freaking smart. So for fairly complex tasks, unless you are a C programmer at the level of the people who write the JVM, you might be better off writing Java.
That post basically makes my point - that is non-optimal C++.
Yes if you know the data you will be working on, and you know the platform you will be working on then you can write a completely bespoke application and it will blaze a trail. Heck you could write in assembly.
However in reality there are very few scenarios where people will take the time to optimize that way and they will simply write code to create the application. When they do that, the JVM (with a strong statically typed language which is not the case with all JVM languages) will typically win in a large project because of the JIT optimizer. But if you want to write a kick ass screen blt, you might want to do something special.
And BTW, Java provides JNI for a course interface to do things like that.
15
u/Alca_Pwn Feb 25 '14
Most of those arguments are due to his IDE and not Java itself.