[Beowulf] C vs C++ challenge
ctibirna at giref.ulaval.ca
Wed Jan 28 09:49:10 EST 2004
Le Mercredi 28 Janvier 2004 00:14, Robert G. Brown a écrit:
> As in maybe it's just me, but when I look at Jakob's code I have no idea
> how it works. What are these routines? What do they do? Where's the
> logic? Oh, I can read the comments and see the keywords and sort of
> guess that all sorts of dark magic is being done; I just have no idea
> how it does it, any more than I would if one took Jakob's code or my
> code or anybody's code for the same task and wrapped it up in a single
And here I argue that this is where C++'s strength becomes evident. STL is
_standard_ (hence its name). Thus, for a C++ programmer, Jakob's code is
comprehensible in one 15second long glimpse and this programmer can
immediately use (trust?) the code. With the equivalent C code from the posted
link, I personally have the problem that I need at least 15 minutes to read
and understand it, and even then, I can't be sure I identified all gotchas
and thus I can use it without major crashes and problems. I argue that the
biggest problem with C up until glib and gsl (thus very recently) was exactly
the lack of high level routines collected in a ubiquous library.
> A lot of the kids learning programming now don't learn "how can one sort
> a list"; they learn how to call a routine named "sort", and extensions
> thereof (at least until they are a relatively upper level class). This
> works just marvey, of course, as long as the entity they need to sort
> and the sort criterion can be fed to the subroutine successfully in a
> form that it can work with...
And once again C++ fills the expectation here, IMO. Paraphrasing you: "This
works just marvey... with C++ exactly because any... entity they need to sort
and the sort criterion can be fed to the subroutine successfully and the
subroutine will happily work with". This, of course, thanks to C++'s
templates. And the result is even highly readable and quite compact usually
(and this is the reason I am ready to cope with performance penalties,
because I can put out code 10-20 times faster than in C -- OK, this is a
subjective measure -- and that code will only run 2-3 times slower -- citing
another poster "that's what clusters are for" ;-).
> But I will, just maybe, give C++
> another try some day in the future when I have time and have found a
> really good book on it.
Lippman's "C++ Primer".
Thanks for listening.
Cristian Tibirna (1-418-) 656-2131 / 4340
Université Laval - Québec, CAN ... http://www.giref.ulaval.ca/~ctibirna
Professionnel de recherche GIREF ... ctibirna at giref.ulaval.ca
Étudiant PhD Génie Chimique ... tibirna at gch.ulaval.ca
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
More information about the Beowulf