Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am planning on purchasing this book to learn more about C++ programming with regards to fast code. However, the book was published in 1999 and I am worried most of it may be irrelevant now due to optimizations that compilers perform.

Could anyone please advise?



Found this book too, albeit also rather old:


share|improve this question

closed as off-topic by gnat, Bart van Ingen Schenau, Kilian Foth, GlenH7, MichaelT Nov 13 at 16:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, Bart van Ingen Schenau, Kilian Foth, GlenH7, MichaelT
If this question can be reworded to fit the rules in the help center, please edit the question.

Instead of efficient c++ why not follow the Effective C++ series? –  Job May 14 '12 at 16:53
Does Meyers' Effective series cover performance? –  user997112 May 14 '12 at 21:23
Maybe not as directly, but Meyers is very concerned about performance (as you'll know if you've seen his talks about cache effects) and his tips almost always lead to clearer, more maintainable and faster code. –  Jonathan Wakely May 20 '12 at 5:13

5 Answers 5

The book touches on subjects like temporaries, constructors/destructors, the overhead of virtual functions, benefits and pitfalls of inlining, memory pooling, caching, CPU cache effects, registers etc.

Many of those techniques are still valid - even if the language and compilers will be providing a lot more help now than in 1999, and the hardware you are running it on is different.

It helps to know what has changed since then, but I'd still recommend reading the book if you don't know where to start, simply because I do not know of anything more recent that covers these kinds of topics specifically.

share|improve this answer
There doesn't appear to be anything more recent- although Meyers is supposed to be releasing a non-C++-specific book called "Fastware". Im not sure how much of his current "Effective" series books is devoted to performance.... –  Roger May 14 '12 at 14:35
You may find this helpful: en.wikibooks.org/wiki/Optimizing_C%2B%2B –  quant_dev May 14 '12 at 15:34
Thank you quant_dev –  Roger May 17 '12 at 9:21

I think it's not necessarily irrelevant just because it's old. For example, C++ lets you put a constructor invocation anywhere an expression can occur. That means the compiler isn't allowed to move your constructor invocations to make the runtime code more efficient, because there are rules about what is guaranteed to have happened between sequence points in a C++ program. OK, it's just one example, and the rule is simple (lazy instantiation means not running a constructor until you need to), but it means there are compiler-independent techniques to improve code efficiency.

share|improve this answer
As you touched upon, I agree that the key is to avoid the compiler and /or platform specific techniques as those are the techniques that become irrelevant with time. –  GlenH7 May 14 '12 at 13:32
Ironic that you should mention constructor invocations, because that's exactly where RVO and NRVO come in and the compiler can ellide them. –  DeadMG May 14 '12 at 13:32
RVO is a very limited subset of the situations in which objects are created, though. –  user4051 May 14 '12 at 14:33
@GrahamLee: Not necessarily. I would say more relevantly that rvalue references and wide-spread expression templates absolutely do dominate the temporaries optimization scene, though. –  DeadMG May 14 '12 at 17:15

More relevantly, there are simply new techniques and new language features- especially rvalue references, and compiler optimizations are much stronger than they used to be with features like cross-TU inlining, RVO, and NRVO. I would look for a newer book.

share|improve this answer
The book actually has a chapter on RVO, but it doesn't cover rvalue references obviously. –  Joris Timmermans May 14 '12 at 13:41
@MadKeithV: AFAIK, common compilers only began introducing RVO and NRVO post-2000. –  DeadMG May 14 '12 at 14:13
@DeadMG would you be so kind as to recommend something more recent? –  Roger May 14 '12 at 14:19

No, the book is not irrelevant at all. It's somewhat old school in places, but a lot of coding companies are that way too. Further, most of what it teaches will always be a part of C++.

That said, I personally think that Sutter's books are better. They don't cover the same material though, so if what's in Meyers's books is new to you...get both.

share|improve this answer
I think you misread -- Meyers wrote Effective C++, but he's asking about Efficient C++. –  Jerry Coffin May 14 '12 at 16:02
@Jerry. I did mention Meyer's books in a comment above. Maybe Crazy Eddie refers to that? –  Roger May 14 '12 at 16:31
@Crazy Eddie, so Sutter's books cover performance then? Would you be able to suggest which Sutter books in particular? Thanks –  Roger May 14 '12 at 16:31
@Roger: Maybe. Sutter's books undoubtedly mention efficiency in passing, but are devoted primarily to other issues (especially exception safety). –  Jerry Coffin May 14 '12 at 16:53

The compiler tries to optimize what it can, but you have to optimize what you can, and the book should help you with that (somewhat).

If you are going to write significantly large programs, it is very easy to put in slowness, without meaning to, that the compiler could never undo.

My favorite example is here. It consists of a realistically large program that was optimized. It was made faster by 50%. But that did not mean it could not be further optimized. The second attempt knocked out a healthy percent of what was left. But that still wasn't the end. This was done six times, and guess what the overall speedup ratio was?

730 times.

Toward the end, the optimizations being done were, out of the original program's time, so small as to be insignificant. But after a series of other problems were removed, small problems become larger, percentage-wise, so they become worth removing. The individual speedup ratio that you get with each optimization may not be too surprising, but they multiply together like compound interest.

That's how you can really optimize code. By all means, use the book, but don't limit yourself to what it says.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.