A Journey Into Non-Virtual Polymorphism in C++ - Rudyard Merriam - CppCon 2023

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2024

ความคิดเห็น • 44

  • @wojciechbartczak3109
    @wojciechbartczak3109 10 หลายเดือนก่อน +17

    I love this talk, it is true gem. Old school, straight to the implementation. No BS 😀Loaded with knowledge and experience. Extra thing added, it considers embedded or more restricted environments. Loop unrolling through std::apply() is wild!

  • @hsarasan
    @hsarasan 8 หลายเดือนก่อน +1

    Beautiful presentation. Such great examples

  • @ChrisCarlos64
    @ChrisCarlos64 10 หลายเดือนก่อน +6

    I found some if this very insightful and helpful. I hadn't used std::any, std::variant, or any of the tools with them, but learning this has opened my eyes to trying them out later so I can remember them and hopefully keep in mind when and where to use them when applicable.

  • @Radioguy00
    @Radioguy00 10 หลายเดือนก่อน +3

    Well done presentation. Examples are simple and clear

  • @stanbarvinsky1011
    @stanbarvinsky1011 10 หลายเดือนก่อน +5

    I've been using std::variant for some time and found it extremely useful (as a type safe union or using it in a visitor). Along with optional this is best feature in C++17 IMO. I also implemented a number of classes similar to what std::any does but with some additional features and type constrains, but I am yet to find a use case for std::any itself.

    • @makaedg
      @makaedg 10 หลายเดือนก่อน +1

      Agree, C++17 gave us so much elements from functional programming. I also really like to use fold expressions. C++ is awesome

    • @mfc1190
      @mfc1190 10 หลายเดือนก่อน

      I haven’t used std::variant before, but I use std::optional sometimes when it’s appropriate, I’d like to check this out!

  • @commander7023
    @commander7023 10 หลายเดือนก่อน

    This is a great talk by him. Concise and solid communication

  • @multiHappyHacker
    @multiHappyHacker 10 หลายเดือนก่อน +1

    Pretty good talk so far, I have played with a lot of these things in my personal projects already. I guess std::function would qualify as runtime polymorphism though, the templates are the static (compile time) version.

  • @pawello87
    @pawello87 8 หลายเดือนก่อน

    'Deducing this' with CRTP is sooo neat!

  • @samuelsrikar2870
    @samuelsrikar2870 10 หลายเดือนก่อน +1

    Amazing talk. Loved it :D

  • @eric-seastrand
    @eric-seastrand 10 หลายเดือนก่อน +1

    Hi Rud! I remember you from a meet-up group years ago. Glad to see you’re doing well. Cheers!

  • @jackgame8841
    @jackgame8841 หลายเดือนก่อน

    i hope this person write book, i am really love his writing in medium.

  • @chrysalide_aero
    @chrysalide_aero 10 หลายเดือนก่อน +2

    If there's a library with this style for embedded i'd love get a look at it. Looks awesome and clean.
    Regards
    Jean-François

    • @johnwellbelove148
      @johnwellbelove148 10 หลายเดือนก่อน

      My OSS library may be useful to you. It has many STL features, but uses no dynamically allocated memory. I've been maintaining it since 2014.
      Search 'Embedded Template Library'

  • @niteshkumarsukumaran
    @niteshkumarsukumaran 10 หลายเดือนก่อน

    Really good talk! Love to try these :)

  • @StupidusMaximusTheFirst
    @StupidusMaximusTheFirst หลายเดือนก่อน

    CRTP is a cool abstraction, I prefer the Polymorphic Object Oriented Predicate, or POOP. It's easier to POOP than follow CRTP abstractions.

  • @stephenjames2951
    @stephenjames2951 10 หลายเดือนก่อน +2

    Like his every man style. Credibility from the trenches.

    • @MartinCordova
      @MartinCordova 10 หลายเดือนก่อน

      What a good way to express it

    • @RudMerriam
      @RudMerriam 9 หลายเดือนก่อน +1

      Thanks! I didn't realize it, but that is exactly how I wanted it to sound. "Shucks, I'm just another developer talking about m' code."

  • @WeiLun-j5g
    @WeiLun-j5g 10 หลายเดือนก่อน

    Nice talk. I just want to provide a little correction: the CTAD line is needed prior to C++17, not C++20.( 21:26 )

  • @marcoradovancovici1312
    @marcoradovancovici1312 10 หลายเดือนก่อน

    Cool stuff!

  • @junaid1464
    @junaid1464 9 หลายเดือนก่อน

    I'm way younger, but turbo c++ was my first editor

  • @roynevo367
    @roynevo367 9 วันที่ผ่านมา

    "I don't care for that, but that's the way C++ works"...
    Should definitely be a meme

  • @lombeelo8780
    @lombeelo8780 10 หลายเดือนก่อน

    Nice one. Sad to see no comments here.

  • @KartikayKaul
    @KartikayKaul 7 หลายเดือนก่อน

    We were taught cpp in 11th and 12th grade in turbo cpp. XD i recognise this screenshot very well.

  • @zxul2340
    @zxul2340 5 หลายเดือนก่อน

    Think you can use std::ref instead of pointers also in the vector

  • @raymitchell9736
    @raymitchell9736 10 หลายเดือนก่อน

    This is something I run into quite a lot, so I need to see if this will work for me. I too do embedded systems and the compilers are not as up to date as we'd like, Arduino is, if I recall correctly, C++ 14 and I need to do something like this for a hobby project so it's more than a good example in my case. And I ran into all kinds of weirdness, it seems that if you're having to force the language to abstract an interface, that perhaps that language isn't yet expressive enough to handle it, I would like dynamic polymorphic dispatch... that's true Object Oriented.

    • @johnwellbelove148
      @johnwellbelove148 10 หลายเดือนก่อน

      My OSS library may be useful to you. It has many STL features, but uses no dynamically allocated memory. I've been maintaining it since 2014.
      Search 'Embedded Template Library'

  • @drescherjm
    @drescherjm 10 หลายเดือนก่อน

    1:45 I spent thousands of hours using that IDE.

  • @protasov-by
    @protasov-by 10 หลายเดือนก่อน

    Same things I thought about last week 😂

  • @randfur
    @randfur 10 หลายเดือนก่อน

    35:50 for code.

  • @CartoType
    @CartoType 9 หลายเดือนก่อน

    Interesting but I can’t see the reason for not using virtual functions.

    • @randomname-cc9hc
      @randomname-cc9hc 6 หลายเดือนก่อน

      Virtual functions require virtual table, which increases size of every single object of given class. Also, calls of such functions are slower, because instead of straightforward functon call we need to look up into vtable and only then call suitable implementation. This is negligible for most cases, but for embedded systems or other constrained enviroments such solution can significantly improve perfomance of program

    • @RudMerriam
      @RudMerriam 3 หลายเดือนก่อน

      @@randomname-cc9hc The techniques that use templates create code for each version which is much larger than that needed for virtual functions.

  • @imrank340
    @imrank340 10 หลายเดือนก่อน

    This old-Timer saying something about C++ programming but I cant figure out where IS start and where is an End? Bit hard to understand.

  • @josefpharma4714
    @josefpharma4714 10 หลายเดือนก่อน +2

    From a C++ experimental perspective: Nice.
    From real coding perspective: Too complex for nearly nothing.
    😀

    • @toolazytobeoriginal4587
      @toolazytobeoriginal4587 10 หลายเดือนก่อน +1

      Wait so is it too complex for basically any project or is it simple enough for basically anything?

    • @makaedg
      @makaedg 10 หลายเดือนก่อน +2

      I used CRTP in the production code this week.

    • @andrewf8366
      @andrewf8366 10 หลายเดือนก่อน +4

      There are plenty of times that this kind of polymorphism is massively simpler than alternatives.

    • @StanleyPinchak
      @StanleyPinchak 10 หลายเดือนก่อน

      Deducing This is going to be a game changer for currying and mixins.
      I use std::variant + overload in my own production code and I am excited to see the static polymorphism capabilities of C++23 reduce both boilerplate and cognitive load. This will lead to much greater acceptance of these tools in community.

    • @josefpharma4714
      @josefpharma4714 10 หลายเดือนก่อน

      @@toolazytobeoriginal4587 I would not use it in real projects.
      IMHO: Code should be optimized for easy reading.
      Many years ago when I went through the C++ Standard (2003) I liked coding C++ on its boundaries and find the most clever (I thought at this time) solutions.
      But this is not easy to read - you could say it’s a skill issue, but you need to assume typically skilled c++ developers.
      And most of them are not even familiar with e.g. template specialization - specially in embedded.