From: "M. Edward (Ed) Borasky" Date: 2006-11-21T07:39:49+09:00 Subject: Re: Ruby vs Java vs c++ Charles D Hixson wrote: > Roseanne Zhang wrote: >> Everybody here or somewhere else take that for granted: Java is >> slower than C++, but actually that is not true. >> >> I thought so too. However, my computational heavy practice proved, to >> certain extent, otherwise. >> >> Interesting enough, I was a very experienced C++ programmer, and >> learning Java in 2000. I got an very heavy algorithm job. I write the >> same code in Java and C++. When the algorithm was relatively simple, >> my C++ code was about twice faster than Java c++/Java = 610/1085. >> However, when my algorithm became extremely heavy iteration, the >> result was c++/Java = 26000/12000. Java was more than twice faster >> than C++. >> >> I asked several Java experts include Jason Hunter, Daniel Brookshier >> about the question, why? The answers are the same, JIT!!!! >> > Your answer is processor cache relative. It also depends on how well > the C++ optimizer works. OTOH, D (Digital Mars D) also turns in times > faster than C++...probably for similar reasons. And it's a compiled > language. Theoretically, with a good optimizer, this should be > impossible...so I suspect the C optimizer. The process of profiling/optimizing C++ is an iterative one, and most folks have neither the patience nor the need for it. There's an excellent (AMD-64/Intel x86-64 based) reference work on the subject at http://www.agner.org/optimize/. But for the most common number crunching tasks, dense matrix operations and Fast Fourier Transforms, I doubt seriously if anybody's JIT can beat Atlas and FFTW. Tie them, perhaps, but not beat them. -- M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P) http://borasky-research.blogspot.com/ If God had meant for carrots to be eaten cooked, He would have given rabbits fire.