Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Modern C++: What You Need to Know

Download

Right click “Save as…”

Slides (view online)
+ My Schedule- My Schedule

This talk will give an update on recent progress and near-future directions for C++, both at Microsoft and across the industry. This is a great introduction to the current state of the language, including a glimpse into the future of general purpose, performance-intensive, power-friendly, powerful native programming.

Follow the Discussion

  • IvanIvan

    Will this have some new material or more like for ppl who dont know modern C++. I ask because I watched all Herbs lectures in past couple of years... (Im your biggest fan :P)

  • Will this only be available 24 - 48 hours afterwards or will it be streamed live? The main schedule doesn't mention it.

  • No streaming? :(

  • No livestream for Modern C++, (talking about IaaS ) :(

  • LD MorettiLD Moretti

    I'm watching the video now and have been programming C++ for 15+ years, and I found this talk useful, if just a reminder on why we use C++.

  • There's also a performance-geeky section in the middle. Hope you enjoy it!

  • LD MorettiLD Moretti

    If you're a C++ regular and wondering if you need to watch this, you need to just for the prefetch stuff at about 40min in!

  • FernandoFernando

    Herb, you could also mention Sum Types in your Types table.
    In C++ we have boost::variant

    https://en.wikipedia.org/wiki/Tagged_union

    Excelent talk!

  • Ajay ShahAjay Shah

    Every major ISV uses 98C++. Adding Concurrent features into C++ is not part of the philosophy of Imperative Architecture. You're wasting your time learning anything other than 97/98! Java is for most. .NET is for experts. C++ is for end-of-your-life. Get a clue!

  • Ajay ShahAjay Shah

    Adding Javascript, OpenCL Scripts, Querying, Markup all into C++ SYNTAX is awkward. Pros/cons not Plus/minus is correct about C++. The next architecture or Foo has only Plus with no minus. Screw-up your life with SSRIs or misusing C++.

  • Ajay ShahAjay Shah

    Lets' add Concurrency Language syntax into SQL! And next D-HTML-X version 6 with a Opera 4. Way to go.

  • Zdravko VelinovZdravko Velinov

    Bad designed code is bad in any language and OOP does not guarantee you anything. Functional programming is not a silver bullet. You might want to drop immutability from time to time to squeeze the last drop of performance out of your hardware.

  • Great talk Herb. Any chance to ask you a question by mail (or different channel), since it is a bit longer and covers some of the aspects you mentioned in the memory related part of your talk?

  • Good talk!

    Nice to see DOD (Data-Oriented Design; demoed & mentioned in the "Data Locality" article by Bob Nystrom) becoming more widespread! :)

    For anyone interested in learning about DOD, I've found "The Latency Elephant" and "Pitfalls of Object Oriented Programming" by Tony Albrecht (also mentioned in the article, together with a pretty interesting book by Richard Fabian) pretty good & motivating:
    - http://seven-degrees-of-freedom.blogspot.com/2009/10/latency-elephant.html
    - http://seven-degrees-of-freedom.blogspot.com/2009/12/pitfalls-of-object-oriented-programming.html
    - (PDF) http://research.scee.net/files/presentations/gcapaustralia09/Pitfalls_of_Object_Oriented_Programming_GCAP_09.pdf

    Mike Acton's presentation from GDC 2014 is quite informative:
    "Code Clinic: How to Write Code the Compiler Can Actually Optimize"
    (PPTX) https://github.com/macton/presentation-archive/raw/master/gdc14_code_clinic.pptx

    "Introduction to Data-Oriented Design" from DICE also gives a nice overview (see also the links at the end):
    http://dice.se/publications/introduction-to-data-oriented-design/

    "A Step Towards Data Orientation" and "Practical Examples in Data Oriented Design" provide a few examples:
    - http://dice.se/publications/a-step-towards-data-orientation/
    - http://gamedevs.org/uploads/practical-examples-in-data-oriented-design.pdf

    More: http://www.asawicki.info/news_1422_data-oriented_design_-_links_and_thoughts.html

    Or, last but most definitely not least, here's _THE_ definitive source: "What every programmer should know about memory" by Ulrich Drepper: http://lwn.net/Articles/259710/
    // If you read just one doc, read this one :)

  • samuwabisamuwabi

    The video buffering takes ages. If you can't host your videos so they are useable why not host them on youtube?

  • HercHerc

    Hello everyone,

    Any know what program they use to make this video? I.E. the speakers' video is on the left with his slides displaying on the right. I'm a teacher and I would like to do something similar. I want to record my lectures with the slides for future viewing.

  • OlivierOlivier

    With respect to Bjarne Stroustrup, I would have written the Python arithmetic mean function this way

    def mean(seq):
    return sum(seq) / len(seq)

    Which is faster and shorter than the manual loop.

  • Maxim IvanovMaxim Ivanov

    Python example for mean wouldn't pass code review either

  • You can do that C++ as well:

    auto mean(const Sequence& seq) {
      return std::accumulate(cbegin(seq), cend(seq), 0.0) / seq.size();
    }

    He probably just did that to illustrate the new for range loop.

  • @Olivier: Thanks, I'll add a slide for next time to show the alternate Python/C++ side-by-side.

    Your Python example:

    defmean(seq):
       return sum(seq) / len(seq)

    C++ example (you could write sum as a one-liner and shorten this up further but I'll stick to only std:: operations):

    auto mean(const Sequence& seq) {
       return accumulate(begin(seq),end(seq),0) / seq.size();
    }

  • OktalistOktalist

    C++ arithmetic mean could be

    return std::accumulate(begin(s), end(s)) / s.size();

  • OktalistOktalist

    Ninja'd by the best

  • Mantosh KumarMantosh Kumar

    Thank you very much Herb for your excellent talk on modern C++ and on efficiency/performance topics.I thoroughly enjoyed as always with your talk(especially the slides of access patterns matters) overall about performance. However I have couple of doubt/query from this talk:

    1.
    While explaining about move semantic you have taken the example of collection/container type and mentioned that it would move the resource/pointer ownership to other object and let original in empty state. This is my understanding about move semantics as well.

    However TC++PL book mention about this we should leave the source object in a valid but unspecified state.

    The above line(unspecified) confuse a bit. I would like to know what else can be a source object (apart from empty) after move semantics gets called on that particular object.Is there any real world example where keeping object in unspecified state make sense rather than empty??.


    2.
    Is it possible to share your source code which you had used while demonstrating the concept Access Patterns matter(slide no:30). I would like to do some experiment on my laptop with your program(It has L1:3MB) and try to find the spikes(in the total CPU cycle taken) when my data size is below the 3MB and when above the 3MB.

    3. I always uses the std::vector as my default choice and this has been demonstrated in your talk as well. I also map/set container where look-up time is really important. I was wondering when using std::list(practical) would be really efficient and beneficial against the std::vector(as even vector beats list in insertion/deletion of node)? Do you have any suggestion on this?

    Mantosh Kumar










  • Zdravko VelinovZdravko Velinov

    Also, don't get fooled by the so called data-driven design. It is a glorified way to optimize loops, such as your typical graphics pipeline that transforms some arbitrary spatial data structure (might be just a flat list) to command buffer packets of some sort. It is far from being a real paradigm.

  • FernandoFernando

    @Olivier,
    Could you please explain the semantics of sum and len in Python?
    You are calling sum and len. Does it mean go through the sequence twice?

  • FernandoFernando

    I answer my own question.
    All the objects with which the Python len function works, keep track of their own length.
    Therefore, the time complexity of len is O(1)

  • GeorgeGeorge

    Are there any plans to go more in depth on doing cross platform mobile dev in c++, using native ui & language for the interface on each platform? I know xamarin is an option to do this but I’d really like to learn more about doing this with a c++ code base. Are there any talks or presentations about this?

  • @George: perhaps these will be useful:

    - http://visualstudiomagazine.com/articles/2013/02/12/future-c-plus-plus.aspx
    - http://nwcpp.org/may-2013.html // note: links to Video & Slides are at the bottom

  • Eric AguiarHeavens​Revenge Know Thyself

    Parallel STL oh yes please... now this type of convergence for C++ is the truly beautiful kind type

  • JerryJerry

    Guys don't hijack the topic into Google vs Microsoft.. Python vs C++/C#.. C++ is the clear winner here. C# follows. Python is an auxiliary player in Windows and Linux world.

    BTW sucks to be you python devs.. trying hard out there! F Google.

  • This was brilliant! A blast!

  • GangaGanga

    I did a very naïve test with C# List<T> and C++ Vector<T> and I was not able to reproduce any performance benefit out of the box form C++ Vector.

    http://stackoverflow.com/questions/22926046/unable-to-reproduce-c-vector-performance-advantages-over-c-sharp-list-perform

  • Oleksandr YefremovOleksandr Yefremov

    Thank you talk.
    On your slide at 16 min you have following sample:
    Matrix operator+(
    const Matrix&,
    const Matrix&);
    m4 = m1 + m2 + m3;

    This code can be improved with following change:
    Matrix operator+(const Matrix& a, const Matrix& b){
    auto res = a;
    res += b;
    return res;
    }
    m4 = m1 + m2 + m3; // matrix get two times copy constructed
    while:
    Matrix operator+(Matrix a, const Matrix& b){
    a += b;
    return a;
    }
    m4 = m1 + m2 + m3; // matrix get copy constructed only once

    Note, I can't write:
    Matrix operator+(Matrix a, const Matrix& b){
    return a += b;
    }
    I must
    Matrix operator+(Matrix a, const Matrix& b){
    a += b;
    return a;
    }
    or
    Matrix operator+(Matrix a, const Matrix& b){
    return std::move(a += b);
    }
    Why?

  • Excellent! I enjoyed it very much. Thank you.

    It is amazing how little things change my perspective in bigger issues.
    * View the prefetch buffer as an infinite cache.
    * "Your intuition is not reliable."

  • It's good to see C++ get more "modern". Getting more modern seems to mean getting closer to C# in ease of use but with better performance. That's all very nice but as a language, despite being "modern", I can't see myself using it unless I need the performance as it still seems so baroque despite all the hand waving.

    Before using C# I had been using C++ for about 10 years, and way before the "modern" period. At the time I loved using STL and various forms of smart pointers, but it came as relief to leave that all behind and go on to C#. Despite basic type inference to enable the "auto" keyword and smart pointers and lambdas, it still seems that C++ just keeps getting more complex overall, despite some simplifications bought on by the new features.

    Having used F# for the past 4 years, I now view C++, C# and similar languages are perpetuating a sort of dark ages in programming that may take decades (if ever) to overcome. While C++ and C# have borrowed bits of functional programming, they simply don't foster true high level approaches to problem solving in ways that OCaml, Haskell, F# and similar languages do.

    Despite the "modern" face lift, compare what's still missing from C++ now with what ML had 40 years ago - immutability by default, algebraic data types, pattern matching, powerful type inference to name some very important features and an elegant intuitive syntax. Modern languages that have derived from ML, like OCaml, F# and Haskell, have ML in their DNA which in practice means they are inherently more capable at tackling complex problems then the Algol derived languages such as C++, C# and Java.

    So yes, it's nice to have C++ add these new features, but unless one needs the speed why would anyone go through the pain of using a language that's so baroque and complicated. The new features may make it a bit more palatable but unless you're an existing C++ user and really need the speed why bother with C++ when there are much better alternatives.

     

  • Why Microsoft is not releasing .NET GC implementation as an open source?

    This action would boost the adaptation of D and Rust. As a result the C++ usage diminishes and more C++ developers will be eager to adopt the next generation of a native language from Microsoft (Native C# or whatever).

  • Great talk as usual! I liked part about memory access patterns. So simple mistake can hurt code performance a lot.

  • Bruno SantosBruno Santos

    Great talk Herb. As a C++ beginner I find your enthusiasm for the language very inspiring, and your talks are always easy to understand and at the same time very deep.

    Thanks.

  • SrinivasaSrinivasa

    Excellent! The quality and efficiency C++ reflects in the talk and presentation!! Looking forward for more sessions on C++ or native technologies. Its really refreshing to view these sessions.

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.