![]() |
|
Conformity to the purity of the conceptual model of a language is sufficient for superficially minded programmers, but the genuine programming aesthetic demands code that is both attractive and efficient. Efficient C++, by Dov Bulka and David Mayhew, is about achieving the second--efficiency--without sacrificing the first, if possible.
If
std::string s1, s2, s3, s4;
// ...
s1 = s1 + s2 + s3 + s4;
is object poetry, yet this assignment must yield place in C++ to the more prosaic
std::string s1, s2, s3, s4;
// ...
s1 += s2;
s1 += s3;
s1 += s4;
to avoid unnecessary temporary objects. Some of these cycle devourers the optimizer can handle; others arise from the specification of the language itself. The compiler cannot, in the example above, discard the constructor semantics of the temporaries called for in the expression, merely in the name of optimization.
Each decade programmers seem to spend less time at the machine instruction level. It seems nowadays in the workplace as if many programmers find it intellectually and emotionally challenging to accommodate their idealistic view of programming models with practical considerations such as the machine efficiency of a given language construct.
In Efficient C++, Bulka and Mayhew have a clear sighting along the trajectory from C++ to object expressions to C to assembly code to machine execution. They not only know the semantics of the language prescribed by the C++ standard; they share with us their insight into what the code generated by the standard compiler will actually do at run time across a wide range of target architectures.
When you find yourself confronting the issues covered in this book, you'll be programming at a level where you will have to solve these issues your own way for your particular circumstances, despite the authors' frequent, apt code examples. The Zen of Efficient C++ is bound up with the timelessness of the proverb that to discover the question is to find the answer.
Efficient C++ is a good way to develop a sense of what the compiler is doing with your code, while simultaneously becoming aware of the limitations of abstract programming models such as the one presented by C++.
-- Jack Woehr
| Readability |
|
| Originality |
|
| Organization |
|
| Accuracy |
|
| Consistency |
|
| Depth |
|
| Timeliness |
|
| Editing |
|
| Design |
|
| Overall Value |
|
Explanation of ERCB rating scale: No stars = unacceptable, 1 Star = marginal, 2 Stars = average, 3 Stars = above average, 4 Stars = exceptional.