On Mar 20, 7:10 am, Razii <fdgl...@hotmails.com> wrote:
> This topic was on these newsgroups 7 years ago
> http://groups.google.com/group/comp....5ebf877e25b287
> I said then: "How about reading the whole Bible, sorting by lines, and
> writing the sorted book to a file?"
> Who remember that from 7 years ago, one of the longest thread on this
> newsgroup
> The text file used for the bible is
> hereftp://ftp.cs.princeton.edu/pub/cs126/markov/textfiles/bible.txt
> Back to see if anything has changed
> (downloaded whatever is latest version from sun.java.com)
> Time for reading, sorting, writing: 359 ms (Java)
> Time for reading, sorting, writing: 375 ms (Java)
> Time for reading, sorting, writing: 375 ms (Java)
> Visual C++ express and command I used was cl IOSort.cpp /O2
> Time for reading, sorting, writing: 375 ms (c++)
> Time for reading, sorting, writing: 390 ms (c++)
> Time for reading, sorting, writing: 359 ms (c++)
> The question still is (7 years later), where is great speed advantage
> you guys were claiming for c++?
Who ever claimed a speed advantage for C++? I've said it more
than once, I can write a benchmark in which C++ will beat Java
hands down. Or vice versa. It happens that C++ will beat Java
in the type of code I'm working on now, but the real reason I
use C++ is because my applications have to be robust, and it's
easier to develop correct code with C++ than with Java.
For those who want to prove C++ faster, just do something with
large arrays of user defined types having value semantics. For
those who want to prove Java faster, use large arrays of basic
types, or where you can swap the pointers, rather than the
values. Like this particular example

---I'm really surprised
that Java didn't do a lot better.
For those who are concerned with performance in your actual
work, of course, write a benchmark which simulates your actual
work (I don't know of too many people just sorting lines in a
single large text corpus), and benchmark it, on the machine
you'll actually be running on. (The quality of Java---and
C++---implementations varies a lot.) In theory, Java has the
advantage in array accesses (because of the lack of aliasing);
C++ when it comes to handling user defined value types (no
allocation is even cheaper than garbage collected allocation).
In practice, however, it will depend on the implementation.
--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34