CompuServe Messages

#SAS dumps Amiga

    29-Jan-95 11:04:28
Sb: #45264-#SAS dumps Amiga
Fm: Doug Walker 71165,2274
To: Black Belt Systems 76004,1771
I agree with Ben that C++ does offer a lot of hidden cost, and at first I didn't really like the language because of that. After getting used to it, there are features of C++ that don't invoke much, if any, extra cost at run-time and yet do improve the programming environment when compared to C. If you restrict yourself to a subset of the C++ features, you can write very efficient C++ code. I avoid passing or returning classes by value, for example, so I sidestep the whole issue of created and destroyed temporaries. I do use the concept of member functions and even virtual member functions; these don't add much overhead compared to well-written C code, but are easier to deal with. I use function overloading and default parameters, but again these features don't cost anything at run-time. I use templates very carefully to ensure that I don't end up with 50 gazillion automatically generated template functions. I don't use iostreams. I do use new/delete. Anyway, the point is that the C++ language doesn't make it impossible to write high-performance code like some other OO languages do (with their run-time class binding, etc.) but some of its features do exact a run-time cost – and we must be aware of what each language feature is actually DOING underneath, or we risk writing really slow code. –Doug