REVIEW - Optimizing C++


Title:

Optimizing C++

Author:

Steve Heller

ISBN:

Publisher:

Prentice Hall (1999)

Pages:

416pp

Reviewer:

Francis Glassborow

Reviewed:

April 1999

Rating:

★★☆☆☆


Despite quite liking the author's Whose Afraid of C++ I have long harboured a suspicion that he is not a C++ programmer. This book confirms that suspicion despite the C++ in the title. For example on page 356 the author starts a version of main that covers three and a half pages (and there is a single comment - one of the author's optimisations seems to be to save time by not providing any). The function starts by declaring 26 variables, most are not initialised and 24 of them are for built-in types (or pointers to such). He defines at least another 14 variables during the rest of the program. He makes unnecessary assumptions about the size of an int (if it cannot store 884736 as a value, one of his loops goes into undefined behaviour).

All that is bad but the biggest indicator is that the only C++ specifics in his code are an ifstream instance, an ofstream instance, four uses of new and one use of delete and a scattering of uses of fstream member functions. He isn't even consistent. Sometimes he uses memset() and sometimes he iterates through an array of int setting each to zero. He does this in a loop that iterates 884736 times and he is writing about optimisation. Granted that the gain may be small but why did he do it that way in side a time critical section and used memset() elsewhere. We will never know. Perhaps a good optimising compiler identifiers what is happening and sets memory anyway.

The other problem that I have is the very concept that underlies the book. Too many programmers waste inordinate amounts of time hand optimising. To give the author credit, he does advise you to think before starting to work. If you run your tax program once a year, halving it execution time is unlikely to ever repay the programming effort involved in making the change.

However the most expensive resources in most programming projects are the human ones and the coding style that permeates this book does nothing to optimise use of that resource. In truth I think your time could be put to better advantage than in reading this book.

By the way, the author seems to think this is his third edition of this book. I think he means that it is derived from an earlier book that was itself derived from a book in C. In my opinion this is still a book in C with a light sprinkling of C++ (he even uses some smart pointers, but he forgets toprovide a destructor for class that owns dynamic resources.) In conclusion, there are a few interesting ideas scattered through this book but not enough to repay time spent studying it.


Book cover image courtesy of Open Library.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.