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?
Correlation does not prove causality.
Roger F. Gay
Joined: Feb 16, 2007
OK, I'm totally striking out on this question. I posted in another forum and it was struck for being too vague. "Odd thing that," I thought. In the past, I've seen performance measures, based on benchmark tests for a wide range of computer languages. I thought everyone would immediately understand what I was looking for.
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?
I'd say it's rare that the performance of the language makes all the difference. C apps can run slow or fast, just as Java apps can run slow or fast. Java is fast enough these days that it can be considered for implementing just about any algorithm. So I'd say the choice of language is driven much more by other considerations than by raw single-CPU speed.
Comparing programming languages for performance isn't really a valid comparison. It's a little bit like comparing the speed of cars based on their color.
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 .
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
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.