Re: Java outperforms C++?

Tech-Archive recommends: Fix windows errors by optimizing your registry



benben wrote:
> I have taken C++'s speed for granted for years, so I was stunned by
> the table of Cost of Common Operations between C++ and Java on page
> 601 of Code Complete 2nd Edition by Steve McConnell. It seems, as
> shown in the table, that Java outperforms C++ in every criteria, if
> not merely matches the latter.
>
> Is that I am reading the table the wrong way? or my previous
> assumption has been so wrong? or the author had the columns reversed?

Read the footnote on the table:

<quote>
....Measurements between C++ and Java are not directly comparable.
</quote>

The reason for the apparent skew in Java's favor is that this is a table of
_relative_ performance, based in i=j as the base operation. In the real
world, that base operation in Java (or C#) is quite a lot slower than the
equivalent base operation in C++, once you factor in JIT time, etc.

While I'm a big fan of Code Complete, I don't think this table is
particularly useful. If you look at the previous table on page 600 you'll
see that Mr., McConnell measured Java os 1.5 times slower than C++ on
average.

-cd


.