17

I'm a practicing C++ programmer (on Unix and gcc 3.x) for the past 6-7 years. I've read Scott Meyer's Effective C++, More Effective C++ and Effective STL cover-to-cover and have lived and practiced his suggestions/techniques along with Boost. I would like to move on to the more advanced aspects of C++ - something along the lines of 'Modern C++ Design' by Andrei Alexandrescu. However, before starting to read this, I am wondering if I should spend time reading Herb Sutter's Exceptional C++ books as well. How would you compare the Effective C++ series with Sutter's books?

Thanks a lot in advance for your response.

Serge
  • 7,706
  • 5
  • 40
  • 46
posharma
  • 179
  • 1
  • 3

7 Answers7

16

Read as much as you can - differing perspectives are always valuable.

James
  • 8,512
  • 1
  • 26
  • 28
10

Yes, absolutely. Herb Sutter covers a lot of very important, but generally poorly understood areas of the language and provides lots of useful guidance for writing more robust code.

While it's true that much of the material originated on the gotw site, it is expanded and better organized in the books. If you can answer all of the problems correctly then you find that you are very rarely faced with code that you don't understand why it behaves like it does. You may also find yourself heading off many potential problems that you spot in code before they become real issues.

I got a lot more out of the Exceptional C++ books than I did out of Effective C++, but this is going to be a very personal thing.

CB Bailey
  • 755,051
  • 104
  • 632
  • 656
  • I also got more out of the "exceptional" series than the "effective" series. Meyer targets programmers new to C++ to avoid common traps, whereas Sutter targets experienced C++ developers to get them up to the "next level". In my experience, very few C++ developers have been able to write high-quality library-level software, and Sutter's topics help to bridge that gap. – Tom Nov 05 '09 at 13:31
8

Frankly, Herb Sutter yanks a lot in the exception safety ever since the introduction of the idea in one of the journals of the pre-2000 age. The fact he used it a lot on replication and transactional systems makes sense, and unless you are a huge follower and interested in only the software of such 'safety' kind you will be bored to death. Meyers is far more practical and engaging.

Besides, if you want to move on, there are other books in the series, notably from the legends and not the writers for the sake of writing. Look up the bits from Nicolai Josuttis (C++ Templates: The Complete Guide), Aleksey Gurtovoy (C++ Template Metaprogramming) and more recently 'Daddy 2' Stepanov. In my opinion, they are more influential, knowledgable, practical and shaping than anything DDJ or exception safety induced writeups...

And of course, if you ever need to go back to basics (and there is always a reason to), one of the best possible books on the subject is by the daddy himself: The C++ Programming Language (most underestimated and skimmed over book out there).

Ehtesh Choudhury
  • 7,452
  • 5
  • 42
  • 48
rama-jka toti
  • 1,404
  • 10
  • 16
  • 1
    You mean Josuttis (not Jousttis) - spelling the name correctly makes it easier to find the relevant book with Google... – Jesper Nov 05 '09 at 08:51
  • 3
    You appear to be a little negative towards the benefits of the Exception C++ books and I'd have to disagree. Expectional C++ has far more more that just exception safety and exception safety is far more important than many people appreciate, even for code that doesn't generate many of its own exceptions or directly catch exceptions. Although I don't have the books to hand important topics that are well covered include: object lifetimes, use of iterators, container selection, memory management techniques, benefits and disadvantages of copy-on-write, overload resolution, use of templates. – CB Bailey Nov 05 '09 at 08:58
  • The interrupt rate on my PC is challenged hence affects the keyboarrd. I'd have to disagree and agree to disagree with you. Exceptional C++ is typical of DDJ write ups and I seriously criticise that style and focus any time I come across it. While it does have other content, the coverage of iterators/lifetimes/and containers, templates, memmanagement is nothing 'exceptional', it's a given/normal. Anyway,and regarding 'exception safety',just review 1st and 2nd book in your shop and read the first incoherent examples of something that will bomb out any time you cross to another tech 'boundary' – rama-jka toti Nov 05 '09 at 10:18
  • (the interrupt rate is so bad that Windows is the one doing mispelling lol, with all the CLR software running on it.. tragic. ) – rama-jka toti Nov 05 '09 at 10:24
  • 1
    Perhaps you could explain what your criticisms of the style and focus are, I am interested in your point of view. I found the style engaging and the topics addressed appropriate and relevant. I'm not sure I understood your last sentence at all. Which shop and where should I look for incoherent examples to compare against? – CB Bailey Nov 05 '09 at 11:01
  • Even if you aren't interested in writing transactional software, the "Exceptional" series is excellent for anyone who wants to understand the design and rationale of their local `libstdc++` implementation. Empty base class optimization, separate base for exception-safety without catch blocks, and many other somewhat-obscure topics are necessary for complete understanding of even `std::vector`. – Tom Nov 05 '09 at 13:28
  • to cut it short, the most glaring example is in crossing Java or CLR or any other runtime boundary, as well as thread pools, managed pools, callback mechanisms, OS code with native filters (forget the mapping, it won't work), and plenty more.. It reaches such an extent and becomes a proprietary solution and mechanism only available to same library writer, and mixing is a huge no no. Moreover, async workflow, intensive and async, net or I/O work and similar show exceptions as well as exception safety becomes an expense and useless/misused method; and so on.Both Google and POSIX dig this.. – rama-jka toti Nov 05 '09 at 15:21
  • 1
    There is no time to solve puzzles that tie me in into something that will simply face huge issues and especially with mixing of libraries, code and so on. That's the style and its awful.If you want 'safety', ACID, undo logs and similar I'd honestly recommend something else and done well rather than relying on one specific compiler and technique. I'm not against tx-style of programming at all, just a fact you can waste so much time with strong exception safety and the gain is really what? Lock-in into an unreversable mechanism or tech or assumption hardware doesn't change for better.. – rama-jka toti Nov 05 '09 at 15:29
  • In my experience, writing code even with the *idea* of transactional programming results in code that is easier to read, with fewer defects and side-effects. It's easy to remove exceptions from the mix and still have that quality, so I call BS on the argument about lock-in. And... how does exception handling have *anything* to do with hardware at all? – Tom Nov 06 '09 at 03:54
  • that's fine.. again tx-style can be good, not against it. As to your question, none at all.. until you hit a hard one :) Good luck, and all the best assuming it's all going to work. – rama-jka toti Nov 07 '09 at 08:49
5

Read The Definitive C++ Book Guide and List. "Exceptional C++" is on the list.

Community
  • 1
  • 1
Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212
4

I like the C++ Coding Standard book because it's just that, a coding standard.

Effective C++ introduces important ideas, and was my first read too. C++ Coding Standards however is shaped like a coding standard, which any person programming should have. There are a number of other coding standards available, Sutter's one has the advantage of being concise and well explained (only 100 items very neatly classified).

I would take the time, if I were you, to read the C++ Coding Standards and the Guru of the Week entries before moving on to meta-template programming.

Meta-template programming is interesting. I loved Modern C++ Programming and its approaches. However it is less used in practice I think, strengthen the basics as much as you can, then you can always play around with 'new' ideas.

Matthieu M.
  • 287,565
  • 48
  • 449
  • 722
  • "C++ Coding Standards" is not really a "true" coding standard. It's very much an excellent guide to how you should approach programming in order to be a professional programmer. A rule like "Pimpl Judicously" is more about educating developers on good practice rather than catching bugs in your code. If your company uses this as their in house standard then only a percentage of the rules will actually affect your day to day code. – Richard Corden Nov 05 '09 at 10:43
  • I asked H.Sutter if one could know only one of his books (Exceptional, More Exceptional, Coding Standards) cover to cover which would it be. His answer: Coding Standards. – RobertL Nov 05 '09 at 14:35
4

I would absolutely recommend the Exceptional C++ books if you're looking to move into more advanced C++. My sense from reading both series is that the Effective C++ books tell you how to write code that doesn't completely suck, and the Exceptional C++ books tell you how to write code that's rock-solid and bulletproof. I was less taken with Modern C++ Design; if you want to get into serious template metaprogramming it's pretty much the definitive work, but I found it a little... out there for my taste, particularly where he builds this gloriously complicated template structure that'll bring tears to your eyes with its sheer beauty, and then mentions "Oh yeah, this doesn't actually work on any compiler that's currently available".

ceo
  • 1,138
  • 1
  • 8
  • 16
1

I found both books interesting and useful. There are lot of common topics and you might already know them, but certainly it will help.

Unicorn
  • 2,382
  • 6
  • 29
  • 42