148

From what I saw in this post I decided to start reading the book Effective C++.

But now that there are many new features because of C++11 and that a few of the good practices changed, I'm not sure whether or not it is actually a good idea. Has the advent of C++11 deprecated any of the advice contained in Effective C++? If so, which topics should I avoid?

Community
  • 1
  • 1
German Capuano
  • 5,183
  • 6
  • 23
  • 35
  • 4
    The author made some comments in an article http://scottmeyers.blogspot.co.uk/2013/01/effective-c11-background.html and others on the site, basically yes, but there is more to consider. – jcoder Jul 25 '13 at 19:26
  • 2
    Just have a look at the table of contents: http://www.pearson.ch/1471/9780321334879/Effective-C-55-Specific-Ways-to-Improve.aspx. Many items are still valid, some can be improved with r-value references and other new things, but overall it should be still effective. – Zeta Jul 25 '13 at 19:26
  • 1
    This question IS a poor fit for SO. (1) The content asked about isn't in the question, it's in an off-site resource (and not even linked). (2) Either addressing each recommendation in the book is a separate answer, in which case this is a list question, requiring too many answers, or else a single answer should discuss the entire book, in which case this question is too broad. That said, asking the identical question about any single recommendation would be great. – Ben Voigt Jun 27 '14 at 20:03
  • 2
    (1) I'm making a reference to a book mentioned in one of the most popular questions in SO. (2) That's an ok complaint, but you can be broad with almost any question. or you can be as narrow as you please. I think that the answers were quite good and way more narrow than most questions in SO, so I don't think a detailed list is necessary. OFF TOPIC: guess who has a question that starts with "Can anyone beat the performance of my integer to std::string code, linked below?" – German Capuano Aug 19 '14 at 01:22

3 Answers3

105

This what Scott Meyers himself had to say about it on his own blog

Which may lead you to wonder whether the information and advice in this pre-C++0x edition of Effective C++ remains relevant. I'm pleased to report that it does. Surprisingly so, in fact. Having spent nearly two years steeped in the details of C++0x, I expected to groan a bit as I reviewed this book's table of contents with C++0x in mind. Surely some Items would be inappropriate. But the advice I found proved sound. Should C++0x developers prefer consts, enums, and inlines to #defines (Item 2)? They should. Should they prevent exceptions from leaving destructors (Item 8)? Certainly. Should they use objects to manage resources? Declare data members private? Consider alternatives to virtual functions? Factor parameter-independent code out of templates? (Items 13, 22, 35, and 44.) Yes, yes, yes, yes! My goal has always been for Effective C++'s table of contents to summarize the advice in the book, and that summary remains just as applicable to C++0x development as to “traditional” C++ development. C++0x is a bigger language, and in some ways it's a different one, but the core techniques for making effective use of “old” C++ are core for the effective use of C++0x, too.

This doesn't mean that this Effective C++ is a perfect match for C++0x. The book doesn't discuss features new to C++0x, so Items about making effective use of those features are missing. A C++0xified Effective C++ would certainly have Items devoted to move operations, to uniform initialization, and to lambda expressions, and it'd probably have an entire chapter on making effective use of the concurrency API. Such a book would also contain different examples, e.g., ones making use of auto variables, range-based for loops, in-class default initializers, as well as the occasional variadic template. To the extent that this book falls short in its support for C++0x, the errors are those of omission, not commission.

UPDATE: the new title Effective Modern C++ has been for sale since November 2014 from O'Reilly and Amazon (and many others that you can google for).

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
48

Yes, definitely still worth reading. There is a new book that Scott is working on: Effective C++11, which concentrates on C++11 only code. The Effective C++ is still very relevant, and is not superseded by the new book. Buy it, read it, enjoy :)

Kyle_the_hacker
  • 1,394
  • 1
  • 11
  • 27
cdmh
  • 3,294
  • 2
  • 26
  • 41
  • 2
    I see the books building on each other, so Effective C++ is the vital foundation. If you only read one of the two, it should be Effective C++. Effective Modern C++ is far more esoteric (and to be honest the majority of C++ is far from 'modern' anyway). – Andy Krouwel Jan 19 '15 at 13:09
21

One, the book is still of course valid for C++03.

Two, Meyers is writing or has written, depending on when you are reading this sentence, Effective C++11.

Three, speaking in generality, the points of this book will still be valid. C++ still favors speed over safety, and many issues in Effective C++ revolve around this.

The only kind of point I would expect to be invalid are ones that say "Don't do this, do this instead." "Dont' do this" will still be valid. But C++ will have solved some problems. In particular, any recommendations to use boost are likely deprecated, as C++11 has included many of the features Meyers specifically refers the reader to Boost for.

djechlin
  • 59,258
  • 35
  • 162
  • 290