Surely, there are some credible and reasonably sets of test results out there, somewhere? Sun (Oracle) must have run tests on Java. And whoever is responsible for improvements in C/C++ must be making measurements. Does anyone know where I can find them?
So, it looks like I may be so out of touch on this topic that I'm not connecting with modern culture.
Rather than ask where are they? Let me ask about your experience with them - whatever you have. It doesn't matter if you have a little or a lot. Just give me a hint. Do you do your own? Do companies not care about such measurements on the basics of languages and just test for final system results? Has everyone stopped caring?
Anything. I'm just hangin' out here.
How fast a program runs is in principle not determined by the language it is written in, but rather by the quality of the compiler or runtime environment for that language. There are some aspects of programming languages that can have an impact on how easy or hard it is to make an efficient compiler or runtime environment. For example, it's harder to make dynamically typed languages run fast, because the language requires that runtime checks are done that wouldn't be necessary for a statically typed language. But on the other hand many tricks and sophisticated optimizations have been invented to solve such problems.
So, choosing one programming language over another because you think it is faster is like choosing a red car instead of a blue car because you think that red cars are faster.
Long ago Java had a stigma of being slow, but the optimizations in the JVM, especially the JIT compiler, are now so sophisticated that it is really not slow at all anymore; it can even do some dynamic optimizations that make it in principle produce more efficient native code than what could be done with an ahead-of-time compiler (such as a normal C or C++ compiler).
Jesper de Jong wrote:Long ago Java had a stigma of being slow, but the optimizations in the JVM, especially the JIT compiler, are now so sophisticated that it is really not slow at all anymore; it can even do some dynamic optimizations that make it in principle produce more efficient native code than what could be done with an ahead-of-time compiler (such as a normal C or C++ compiler).
I mentioned being a Java fan as part of the question - hinting subtly that I know it's fast now. (I even, very happily, use string case variables in Java 7 for switch case.) I do sometimes have some time sensitive components in applications - you know, the kind you don't just do once but do 100s of millions of times over and over again. Especially in real-time systems it matters. But you're right about the other thing too. I suppose I should do my own custom performance checks at least on something representing the critical repetitious part of the algorithm rather than relying on somebody else's benchmarks.
BTW: I've just built a server that requires lots of cryptic stuff for security when making a connection and a bit more with each message. On localhost, the entire echo process test (what we all do first when we build servers) seems instantaneous. Java is fast. (Even says good things about the speed of Firefox and Chrome.)
Roger F. Gay wrote:I mentioned being a Java fan as part of the question - hinting subtly that I know it's fast now.
But do you realize just how fast? I've created a Stopwatch class that allows me to get average timings over multiple invocations, and have been quite amazed at the stuff that comes in consistently under 5ns - including things with method calls - and that's on a 4 year-old workhorse Dell.
My reckoning is that Java compilers are getting so smart that you simply can't rely on the fact that what you coded (eg, a method call) is what's actually getting run.
That said, there are some things that are beyond the scope of the language, just one of which is the ability to make use of CAS (compare and swap) operations. Many of the new 'Atomic' and 'Lock' classes do exactly that, but under the hood there's some native (I suspect C or C++) code behind it...Oh, and BTW, they are blisteringly fast .
I haven't been working with cell phones and am not sure it's an apples to apples comparison; but he seems to be saying that Java is really slow compared to C# and C++.
BTW: I didn't come up with this one myself (just to cause trouble or anything). It was posted in response to a performance question on researchgate.net. Maybe I'm being suspicious here, but it seems short-sighted not to have a general set of performance measures to counter biased and misinformation that we know will come from Apple and Microsoft advocates. I'm just sayin' .... while wondering what the market is for programs that generate a large number of primes in a particular way; somehow making comparison between C++ and an alpha version of a Google toolset of some kind an important consideration.