[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] c++ & mem
>>>>> "Al" == Alex Hudson <home [at] alexhudson.com> writes:
Al> Old code, yes, efficient code? I don't think I necessarily
Al> agree with that. Efficient, maybe, if the coder is a C coder
Al> who doesn't do so much C++. C++ overall is generally much
Al> nicer to streamline than C code.
By "efficient code" I meant things like unrolling loops by hand
(Duff's device -- a compiler can _never_ get that right because
compilers don't read hardware data sheets), short-circuiting the
virtual function call mechanism when you know which type you're going
to have, defining multiple hand-tweaked versions of linked lists
rather than deriving from a single "class link { link *next; union {
void *object; anything_small_enough_to_fit_in_a_void*'s_storage
thing;};}" (or better using something from a standard class library)
and such-like. No-nos in well-styled C++. Some of these can be
handled efficiently with C++ features (eg, the class link can often
avoid a level of indirection with a template), but that may or may not
increase clarity.)
Al> No, I disagree completely. If you're planning on programming
Al> in C++, you need to test the compiler *with* C++, not C - that
Al> means the libraries, etc.
You need to reread chapter one of K&R again, I see.
Case in point: the original poster did not need to use libstdc++ to
run into problems. And the kind of problems he had are typically
harder to solve by email than actual language issues; eg, no DOS
person would ever have figured out the actual problem since DOS always
includes . in %PATH.
OTOH, if he'd written the program using iostreams, a lot of the advice
would have focused on getting that library working, right?
--
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Institute of Policy and Planning Sciences Tel/fax: +81 (298) 53-5091
_________________ _________________ _________________ _________________
What are those straight lines for? "XEmacs rules."
---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word
"unsubscribe" in the body of the message.
GNU the choice of a complete generation.