Herb Sutter: (Not Your Father’s) C++

Sign in to queue

Description

What makes ISO C++11 "feel like a new language"? What things that we know about past C++ do we need to unlearn? Why is C++ designed the way it is – historically, and in C++11? Finally, what is the difference between managed and native languages anyway, and when is each applicable? This talk gives an overview and motivation of modern C++ and why it's clean, safe, and fast – as clean to code in and as type-safe as any modern language, and more than ever the king of "fast."

Tag:

C++

Day:

3

Embed

Download

Download this episode

The Discussion

  • User profile image
    Frank09125

    When is this coming ?

  • User profile image
    Luna

    @Frank: Probably when xmas and haloween fall on the same day! Useless question...

  • User profile image
    Charles

    @Frank09125: Not a useless question at all. The title/abstract is in flight (this means, well, it hasn't landed yet. As soon as it becomes available, it will be posted here).

    All of these sessions will be recorded and made available on demand no later than a week after the event.

    C

  • User profile image
    Luna

    @Charles: Ok then you are overly generous ;). To me such questions waste useful human resources, like yours for one, who instead of doing useful stuff now have to attend to such questions. I mean it is happening just everywhere all the time, but that shouldn't mean us sticking our heads in the sand... Either way, the time when the presentation is done is prominently denoted, Herb Sutter is talking about C++... The Event is in "some" days and not just about Herb Sutter after all. Who cares about the precise topic? Just wait a few days and you'll know. Its like all those creatures who will later ask "when is the video online"? "Where the heck are the slides"? God dammit, I can't hear this stuff anymore...

  • User profile image
    Charles

    @Luna: Fair enough.

    C

  • User profile image
    tomkirbygre​en

    Looking forward to this. It's Herb so you know it'll be cutting edge and based solidly in reality.

  • User profile image
    Luna

    @dot_tom:
    Yes Herb talks are always great. But he always manages to skip one important point. C++ is fast as hell I'll give you that. But even C++11 is no where near the comfort of C#. Syntactic sugar does not cut it. There are pitfalls everywhere and I doubt that all this new candy makes it better, since everything else is still aimed at your own foot. I don't even talk about memory/resource management since C++ is really good at it. But things like object slicing, pointer dangling, and stuff like that really create hard to find and nasty bugs in large code bases...

    Besides that I am not yet convinced that NET languages can't drive at the pace of C++. I blame the JIT compilers! Microsoft had a new one in queue, called "Phoenix". No word about it, sadly, in any recent events. NET does NOT need JIT compilers. Only very few application really need it and those who do can use a little runtime, compiling additional code when required. Reflection and dynamic invocation are no code generation features and can be implemented statically. Same goes for almost any other NET features, except code generation... Serialization also does not require dynamic code generation in theory.

    I admit that C++ has unique language feature to gain that additional bit of performance. But I highly doubt that C# can not run at the same pace most of the time, given a strong static compiler... As long as this question is NOT addressed, not only me but also a whole pile of people just can't be convinced by C++ performance talks. It rather seems like Microsoft is deliberately holding NET performance back. Mono and Java are already ahead performance wise, so there is not much potential in comparing NET and C++ performance...

  • User profile image
    felix9

    @Luna: Microsoft is still working on that AOT compiler for MSIL.
    https://careers.microsoft.com/jobdetails.aspx?jid=76831

  • User profile image
    Luna

    @felix9: Thanks! This is great news! And also means I can somewhat bury my thesis proposal ;) and think about a new topic...

  • User profile image
    asker

    Back to topic: When is this coming? :)

  • User profile image
    Luna

    @asker: Why do you write "back to topic" when you obviously haven't read any of the posts, judging by your question?!

  • User profile image
    tomkirbygre​en

    Awesome. Thank you for posting this - this is the presentation I've been most keen to catch. I'm very interested to hear what Microsoft is doing to help grow the surface area of Standard library over the next few years. Personally I like to see the C++ standards folks (including Microsoft) get into the habit of regularly publishing 'beta extensions' to the Standard library. If they're so tagged then we can treat them as such while still benefiting early and helping provide real world usage experience to shape them before their officially stamped as Standardised.

     

  • User profile image
    C64

    Excellent talk! Thanks for this.

     

  • User profile image
    C64

    @Luna:

    C++ is fast as hell I'll give you that. But even C++11 is no where near the comfort of C#. Syntactic sugar does not cut it. There are pitfalls everywhere and I doubt that all this new candy makes it better, since everything else is still aimed at your own foot. I don't even talk about memory/resource management since C++ is really good at it. But things like object slicing, pointer dangling, and stuff like that really create hard to find and nasty bugs in large code bases...

    If you use convenient classes like STL containers, smart pointers, etc. and modern C++ programming style, it is very difficult to have pointer dangling.

    Lots of problems and bugs with C++ and pointers are for old code bases, when C++ was used "like a better C", with raw pointers everywhere, no smart pointers, etc. But in more recent times the story changed.

  • User profile image
    hsutter

    @C64: The big thing I personally got out of last week's event and chats was that Standard C++ now does have a safe subset, but we need a concrete description -- ideally a mode. It has made me think again about doing a scrub of all standard C++ language and library features and marking some as "unsafe" in some way (possibly that allows overloading, such as for vector::op[] overloads for safe and unsafe instead of the current hack of providing op[] and at() which almost nobody uses), then supporting a switch that enables only safe mode. I believe I know how to do that very efficiently now that we have C++11.

    I'll have to look into this more over the summer. I think saying "use this (possibly standardized) switch/mode and your modern C++ code is type- and memory-safe" would be a big deal and an important missing piece to completely answer and dispel this question. The question "what subset of C++ is that exactly and is it a usable subset" is a legitimate question now, and IMO wants a more concrete answer than we have today. I did look at this about four years ago, but Angel we know more now, and (b) C++11 has already added most of the then-missing pieces now.

  • User profile image
    MartinBa

    , hsutter wrote

    (...) that Standard C++ now does have a safe subset, but we need a concrete description -- ideally a mode. It has made me think again about doing a scrub of all standard C++ language and library features and marking some as "unsafe" in some way (possibly that allows overloading, such as for vector::op[] overloads for safe and unsafe instead of the current hack of providing op[] and at() which almost nobody uses), then supporting a switch that enables only safe mode. (...)

    (...) I think saying "use this (possibly standardized) switch/mode and your modern C++ code is type- and memory-safe" would be a big deal and an important missing piece to completely answer and dispel this question. (...)

    If this mode incurs any performance cost, people won't use it. If this mode breaks when compiling any 3rd party or "legacy" headers, people won't use it. Look at the mess we already have with managing warnings/warning levels and static analysis annotations ...

    Still, I'm very keen to see what the outcome of such an endeavor could be Smiley

  • User profile image
    dcuccia

    , MartinBa wrote

    *snip*

    If this mode incurs any performance cost, people won't use it. If this mode breaks when compiling any 3rd party or "legacy" headers, people won't use it. Look at the mess we already have with managing warnings/warning levels and static analysis annotations ...

    Still, I'm very keen to see what the outcome of such an endeavor could be Smiley

    restrict pure?

  • User profile image
    jamesfolk1

    @Luna:I think to save time would be to answer the question or not answer at all. wasting time would be to give a snide comment.

  • User profile image
    Luna

    @jamesfolk1: no because otherwise people will never learn... In fact they won't anyway but hope dies last!

  • User profile image
    benjamin​Lindley

    , hsutter wrote

    It has made me think again about doing a scrub of all standard C++ language and library features and marking some as "unsafe" in some way (possibly that allows overloading, such as for vector::op[] overloads for safe and unsafe instead of the current hack of providing op[] and at() which almost nobody uses), then supporting a switch that enables only safe mode. I believe I know how to do that very efficiently now that we have C++11.

    What about this idea.  Have a separate namespace within or beside std, call it safestd.  In there have safe substitutes for various functionality in the standard.  Then you could choose between safe and efficient selectively with a typedef or a `using` statement.

  • User profile image
    AceHack

    @hsutter I'm so excited to hear you talking about a possible await language feature for C++.  And now I just read your comments about a possible safe mode, I'm running out of reasons to choose C# over C++ on many types of projects now. Smiley

  • User profile image
    Luna

    >I'm running out of reasons to choose C# over C++ on many types of projects now.

    First, it will take additional 5 years (at least) until this makes it into the standard and only god knows what happened to NET and C# by then... Also the NET class library is a little more extensive =).

    Second, the "safe" mode was my idea :D... I wanted to build it into Clang together with "pure".

  • User profile image
    Luna

    @bejamin: >Then you could choose between safe and efficient selectively with a typedef or a `using` statement.

    Very bad idea. Especially for templates this could be a hazard. But Herb already mentioned the good solution. Have "restrict()" do the work, just as it is for C++.AMP right now.

  • User profile image
    benjamin​Lindley

    @bejamin: >Then you could choose between safe and efficient selectively with a typedef or a `using` statement.

    Very bad idea. Especially for templates this could be a hazard. But Herb already mentioned the good solution. Have "restrict()" do the work, just as it is for C++.AMP right now.

    @Luna: Could you please elaborate on why you believe it would be a hazard?

     

  • User profile image
    Ivan Soto

    What's going on? No more destructors? Automatic garbage collection? Virtualized runtime? What? What? What? Can't wait to find out ...

  • User profile image
    evildictait​or

    Besides that I am not yet convinced that NET languages can't drive at the pace of C++. I blame the JIT compilers!

    It's usually the GC rather than the JIT compilers that cause the slow-down, although even that is pretty small now.

    Microsoft had a new one in queue, called "Phoenix". No word about it, sadly, in any recent events. C++ goes through Phoenix just like your C# does.

    Phoenix is a unification of all of Microsoft's compilers. It's there in VS2011.

    Mono and Java are already ahead performance wise.

    Citation needed.

  • User profile image
    remi blanchette

    Can we get the slides from somewhere?

  • User profile image
    Luna

    > It's usually the GC rather than the JIT compilers that cause the slow-down, although even that is pretty small now.

    No its not. Quite the contrary. GC's can actually yield performance improvements over native code due to cache locality. The problem with most GCs is that they are not controllable, something that screams for a fix... I am not talking about the compiler itself, but the generated code.

    > Phoenix is a unification of all of Microsoft's compilers. It's there in VS2011.

    Phoesnix originally was meant to be something different. That is a unification of optimization and IL code. So that that all languages are compiled into the same rich IL code (even C++) and then analysis tools built on top would work with all languages, especially the optimizer which could now optimize all language at C++ pace and finally also emit native code or IL code for any language. This is definitely not in VS11, not even close. Microsoft seems to be working at a C++ and C# native compiler but that is not was Phoenix was originally about and also is nothing that we will see in VS11...

    > Citation needed.

    Just try it out... The only bottleneck of Java was the GC, which was noticably slower than NET, but maybe it is improved in Java 7.

  • User profile image
    Uwe Dolinsky

    Quote (at around 1 minute and 20 seconds into the talk): "while still retaining 100% backward compatibility".
    That statement is misleading as C++11 is not 100% backward compatible with c++03 or previous versions of C++. For example while standard C++11 compilers won't compile code where auto is used as storage specifier, other new features like reference collapsing or deducing template parameters as types with local linkage change the semantics of some programs. Using this knowledge it is even possible to write programs to detect (purely on the language level) differences between C++11 and earlier versions of C++, see http://stackoverflow.com/questions/6473218/what-differences-if-any-between-c03-and-c0x-can-be-detected-at-run-time

  • User profile image
    zettersten

    +1 if you think Luna is trolling ><

  • User profile image
    Smerdlap

    So are there any studies that show that Java/C# actually give productivity gains over C++? And how much of the gain is simply due to the massive amount of wealth invested in their libraries? It seems Java and C# go out of their way to sabotage the RAII idiom and it seems like a big handicap for the programmer.

    If you are willing to sacrifice the user experience and performance and mobile battery life simply to reduce your labor costs, you must have few customers indeed.

  • User profile image
    Charles

    Can we get the slides from somewhere?

    Click on the slides link under the inline media player Smiley
    C

  • User profile image
    Fernando

    @Luna:
    I propose you a challenge.
    Choose your favorite language (C#, Java...)

    Make a Matrix type (Generic, obviously. In the sense that Generic Programming means -maximal reusability, same performance-).

    Code it now in C++ (C++11, better).

    Next, compare the code and do performance benchmarks.

    Regards.

  • User profile image
    Jonathan

    Everytime I look into C++, I am reminded how bad the tooling support is. For instance, MSFT has Code Canvas for .NET in VS but not in C++ http://blogs.msdn.com/b/kaelr/archive/2012/04/14/exploring-code-canvas.aspx

    I wish C++ devs would get more "love" from Microsoft (yes, you are doing your best but there is definately a big .NET base at MSFT!)

    jon

  • User profile image
    Luna

    @Fernando: No need, since I already know the answer. But the point I was trying to make is that there is no evidence that this gap could not be closed with good static compilers for those languages... But everybody talks as if it was hardwired or these languages were "born" to be slow.

  • User profile image
    freefly

    @Jonathan : I have put an entry in "UserVoice site for Visual C++" saying that the Debugger Canvas should be available for Visual C++ as well. I did that long ago. Nobody seems to be interested except me. Nobody has the time to look at these things and raise voice or let the Visaul C++ team know what you think is a valuable proposition to Visual C++. Everyone are confined to their little world and when a problem hits them, they come out yelling and blame everyone possible.

  • User profile image
    fpelliccioni

    @Luna: Do you know the answer? Which is it?
    I am with you, there is no evidence, ..., but there is no evidence of the opposite case.

    I don't know if everyone is talking as if these languages are destined to be slow, the only thing I know is that C++ was born to be fast (zero-overhead)...

    These other languages have some features (or lack of) in which they can not compete with C++. Some of them have impact on performance.

    - Poor value semantics
    - Poor generic programming support
    - Abuse of runtime instrospection as default practice
    - Limited expressiveness (compared obviously with C++), see... http://www.codeproject.com/Articles/5676/Spart-a-parser-generator-framework-100-C
    - Portability (C#)

    I think that the only current evidence, it is reality, see...
    http://www.lextrait.com/Vincent/implementations.html

    On the other hand,I wouldn't think to code a simple web application in C++, where the main requirement is time-to-market (for now).

    Regards,

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.