Herb Sutter: C++ Questions and Answers

Play Herb Sutter: C++ Questions and Answers
Sign in to queue


Herb's last appearance on C9 was a relatively short chat with me about C++0x. You wanted more questions asked and some of you thought I was just too soft on Herb. Well, Herb decided that the best way to get the questions you want asked is, well, to have you ask them. Most of the highest user-rated questions were asked and Herb answers with his usual precision. So, without further ado, it's C++ question and answer time with the great Herb Sutter, powered by you.

Questions (click the question link for Herb's answer):

Tim Pinkawa: Which non-C++ language do you find to be the most inspiring today? Are there any features in that language that you'd like to see in future C++ incarnations?

Matthias Merkers: So do you think that lacking toolsupport for C++ will be a major problem since there are new better-prepared system-programming languages available?

ZenJu: What is the strategy to deal with C++ language and standard library design flaws in the long run? Are you afraid "bad design decisions" may accumulate over time, thereby making it more and more harder for newbies to learn the language? Herb also briefly discusses noexcept... (two for one!)

Cory: Concepts — why did they fail and what work is being done to bring something like them back?

Cory/jalf: Polymorphic lambdas - why did they fail and what work is being done to bring something like them back?

Ben craig: There seemed to be some controversy over noexcept on destructors. Your books describe your reasoning on why destructors should never throw. What does the opposition consider to be a valid use of throwing destructors?

Anteru: Modules - Are they really coming, and if so, when do you expect the first implementation?

os: Could you discuss briefly the module support that didn't make it into C++0x please? How can this work with templated code that has a lot of functionality in headers?

David: why the long time in C++ standardization work? Will the next standard take as long?

Atle Iversen: I'm not sure how much you're allowed to tell us, but I would *love* to hear some details about MS Windows and/or MS Office; how much C vs. C++, which parts of C++ do they use etc (Google has released an "official" C++ coding standard, but I would love to see something similar from the MS Windows and MS Office teams...) 

Cory: Filesystem — something like boost::filesystem is desperately needed.

Cory: Threading — thread pools, fine-grained task model, thead-safe containers.

Charles: Why not add an async/await language-level pattern to C++ just like in C# vNext?

Ari: Can you please comment on the influence of the boost community on the development of the new features of the c++ language. It seems that a lot of new C++0x features/additions have been adopted due to the wide use/acceptance of the feature/s as part of the boost library.

Alfonse: Uniform initialization (the use of {} to call constructors when the type being constructed can be deduced) has the potential to radically reduce the quantity of typing necessary to create C++ types. It's the kind of thing, like lambdas, that will change how people write C++ code. What is the Visual Studio team's priority for implementing this feature, along with initializer lists?

petke: What is on the top of your post C++0x wishlist?

Thanks for all your great questions and thanks to Herb for taking time out of his insanely busy schedule to sit down and answer as many of the highly user-rated questions as possible. Great stuff! We should do this again.  For all the folks who asked about specific VC vNext implementations, please try to make it to BUILD as there will be a significant C++ presence at the developer affair in Anaheim (Sept 13-16, 2011). If you can't attend the event in person, then you will be able to watch all of the session online, as usual, after the event right here on Channel 9.







Right click to download this episode

The Discussion

  • User profile image

    Regarding cpp prine. Why dont you make compiler compile depending on the file extansion... just please dont make it cppp :D
    So for .cpp compiler does this, for .cppprime compiler does that. Ofc just having a new language would be simpler, but breaking the compatibility would be baaad.

  • User profile image
    Great interview. Regarding the MS C++ coding standards - I can see that generating a new formatting war in various circles. But, I would still read it! Regarding the time frame for the standardization, the result is nice, but such lengths have caused a perception of a dying or obsolete language. That perception, along with MS emphasis on .NET has lead to many 'leaving' c++ or feeling the need to migrate their code at great expense to .NET/WPF with very little to gain except that new hires are more able to come aboard because they see us 'keeping up' with the latest technology. Too bad this 'c++ renaissance' has to take place. Ideally no renaissance should have to be necessary if the language and framework updating and focus is timely.
  • User profile image

    Thanks, for that Herb and Charles.

    Remaining questions:

    Herb, what do you actually do at Microsoft? Do you work with the compiler team? C++ usage across the organization? With the parallel processing team? All of the above?

    What sort of work/studying have you done in the past that prepared you for your job now?

  • User profile image

    I'm Cory.  Thanks for answering most of my questions, Herb.  I asked all of them in the reference of C++ standardization, not in terms of Microsoft's tools, so I'm glad you picked up on that.  Sorry if there was any confusion with my short statement-questions Wink

    Happy to hear that concepts and polymorphic functions are still on the plate.  Thanks for all your hard work -- looking forward to playing with it when compilers catch up.

  • User profile image

    @PhrostByte: Herb answered all of your questions that were highly rated. Good job, Cory!


  • User profile image
    OS guest

    Thank you for a great talk! I am glad my modules/templates question made it in :)

    So, the proposed module would allow people to expose basically "C with classes" code, which is far from what can be done in complete modern C++. You briefly mentioned template instantiation - is there something I can read about that idea? I am just trying to understand - how could you ever expose something like standard containers from a module (or instantiate it beforehand)? That code is parameterized to the the concrete type and then machine code (or some intermediate representation) is emitted. In either case, I think the compiler will need source code, or you else you are talking about some kind of separately and completely compiled "generic" that lives in a lib and gets dynamically linked (ie not part of this compilation).

    Does this make sense or am off?


  • User profile image

    Now I found http://herbsutter.com/ and http://www.gotw.ca/

    Thanks Herb!

  • User profile image

    There is at least a candidate for a portable systems language that is type and memory safe and comes quite close to C/C++ performance Wink
    ATS http://www.ats-lang.org/ 
    Maybe an Expert to Expert episode with Erik and Herb?


  • User profile image

    Always love hearing Herb's (and STL's) insights into the standardisation process and the design planning behind C++.

    I'll also add a vote for an Erik/Herb E2E, even though I can probably guess the plot (Erik says C++ is trying to be more like Haskell, Herb agrees but is defensive about the implied charge of plagiarism, Erik gives contrived examples, Herb gives other examples, Erik backs down and they all lived happily ever after. Better than Hollywood!)

  • User profile image

    I am facing a big problem downloading the video. The download starts up fine, but then slowly the speed goes to zero. I have to stop and resume the download to get it to start again :(.

  • User profile image

    @zooba: You do realize that this has already happened, right? Not sure we need to put them together again unless the conversation is different from the magic that already happened...



  • User profile image

    @Charles: Hah, you're right. How could I forget that. *goes to see whether my prediction was a suppressed memory*

  • User profile image
    Agnel C J Kurian

    Could we please have transcripts for these discussions? 600MB for each is a bit too much.

  • User profile image
    Disgusted of Tunbridge Wells

    I was looking forward to reading Herb's answers to the questions on this page. The instruction to do so says "click the question link for Herb's answer". However, clicking any of the questions simply navigates to the top of the page and no answer is revealed.

    I'm using Firefox 5.0, one of the most popular (and standard-adherent) browsers around.

    I know Microsoft have a history of ignoring web standards but, for heaven's sake, this is one of the simplest tasks to code on a web page. Please fix it so that I may read Herb's responses.

  • User profile image

    @Disgusted of Tunbridge Wells: This isn't actually as simple as you may be thinking. Those links are designed to make the video player jump forward to a specific point in time, they have nothing to do with any known web standard. So... if you can play the video on the page, then the links should work. We do test in FireFox 5.0 and I've seen no issues. We also support HTML 5, but since FireFox doesn't support h264 video (which is what we have already encoded and available) that isn't an option for you.

  • User profile image

    I'm using Firefox 5.0, one of the most popular (and standard-adherent) browsers around.

    Your precious FX5 does not adhere to the H.264 standard.

  • User profile image

    @OS guest:Code and data (like std::cout) in libraries are fully instantiated.

  • User profile image
    Dave Abrahams

    I have to take exception to the explanation of why we don't have polymorphic lambdas. It wasn't a consistency problem or because the committee was too scared of implicit templates. It was because nobody knew how to get them to work inside concepts-constrained templates (because the lambdas would be unconstrained). At the time, concepts were an approved part of the standard. Once concepts were taken out, it was too late to reintroduce polymorphic lambdas, but even if it weren't, I doubt anyone who hopes for a future standard with concepts would have pushed to reintroduce them.

    [I think I have a solution for the problem of interoperating between constrained and unconstrained templates now, but at the time it was an unsolved problem.]

  • User profile image
    Dave Abrahams

    Modules and shared libraries are not really related as far as I can tell. Pete Becker was working on shared libraries, but that's a separate issue from modules. The point of (Daveed's) modules design is obsoleting the #include model, which makes it so difficult for us to do so many things well in c++.

    Also, I'm confident that making modules work with templates can be far easier than implementing export, which was "designed" in a hurry with no implementation experience and don't have the same information-hiding capability.

  • User profile image
    Irene Hynes

    Howdy Mate,

    Grazie! Grazie! Grazie! Your blog is indeed quite interesting around Herb Sutter: C++ Questions and Answers I agree with you on lot of points!

    A subset of a natural language contains these sentences:
    1) Triangle ABC.
    2) Line Segment AB.
    3) Angle A.
    In this set, <a href="https://asha24.com/blog/c-interview-questions-and-answers/"> names of triangles </a> are formed by putting three letters together,
    all drawn from the alphabet {A,B,C,D,E}. Line segment names are defined by
    putting two letters together from the previous alphabet. And angle names are
    (suprise!) given by any letter in that alphabet.

    Great effort, I wish I saw it earlier. Would have saved my day :)

    Thank you,
    Irene Hynes

Add Your 2 Cents