CppCon 2018: Jonathan Boccara “105 STL Algorithms in Less Than an Hour”

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 มิ.ย. 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2018
    -
    We are all aware that we should know the STL algorithms. Including them in our designs allows us to make our code more expressive and more robust. And sometimes, in a spectacular way.
    But do you know your STL algorithms?
    In this presentation, you’ll see the 105 algorithms that the STL currently has, including those added in C++11 and C++17. But more than just a listing, the point of this presentation is to highlight the different groups of algorithms, the patterns they form in the STL, and how the algorithms relate together. And all this in an entertaining way.
    This kind of big picture is the best way I know to actually remember them all, and constitute a toolbox chock-full of ways to make our code more expressive and more robust.
    -
    Jonathan Boccara, Murex
    Jonathan Boccara is a Principal Engineering Lead at Murex where he works on large codebases in C++.
    His primary focus is searching how to make code more expressive. He has dedicated his blog, Fluent C++, to writing expressive code in C++.
    He also gives internal trainings on C++ every day, in the short format called "Dailies".
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

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

  • @schleppel12
    @schleppel12 5 ปีที่แล้ว +314

    Haha. That world map. As nerdy as it gets.
    Loving it.

    • @DarrinCullop
      @DarrinCullop 4 ปีที่แล้ว +12

      What's amazing is that they work on things besides std::map !

  • @mrlithium69
    @mrlithium69 5 ปีที่แล้ว +154

    Very clever. Not only will I remember the algorithms but I will remember the map too now :) Thanks for the good talk!

  • @andrewf6725
    @andrewf6725 5 ปีที่แล้ว +165

    Amazing presentation. Absolutely recommended for every STL beginners!

    • @greatbullet7372
      @greatbullet7372 5 ปีที่แล้ว +4

      i am an STL beginner and i can confirm that.

  • @mindasb
    @mindasb 5 ปีที่แล้ว +61

    As a teacher of programming, I'm absolutely amazed and inspired about / by this map. A great educational tool.

  • @luisfsalazarb
    @luisfsalazarb 5 ปีที่แล้ว +76

    Clear, concise and entertained. Having been through all std algorithms at least once is absolutely educative.
    I will remember your talk. Thanks man.

    • @milanstevic8424
      @milanstevic8424 4 ปีที่แล้ว +2

      "std" I see what you did there

  • @Yupppi
    @Yupppi 7 หลายเดือนก่อน +4

    Conor Hoekstra mentioned this talk in his algorithm talks and I'll admit this is a wonderful presentation. Just the way to present the idea and the vehicles to carry the presentation are so nice that you can't help but want to just dabble a tiny bit into algorithms, just to get a piece of the presentation's atmosphere. Very nice presentation!

  • @mayankdutta2832
    @mayankdutta2832 4 ปีที่แล้ว +14

    OMG , It's not just a video , It's a movie. I never enjoyed that much before !!

  • @NomoregoodnamesD8
    @NomoregoodnamesD8 5 ปีที่แล้ว +17

    24:00 if you can write your algorithm as a call to reduce, then you have made an nonsequential parallel algorithm. If you want to introduce yourself to multithreaded programming, this is the best place to start, as it is the fundamental algorithm for highly parallel code.

  • @srcmake
    @srcmake 5 ปีที่แล้ว +27

    Nice presentation. I was looking for a tutorial on the STL, and you did it very succinctly and well.
    I'll be sure to check your blog out. Thanks.

  • @nikitademodov3446
    @nikitademodov3446 3 ปีที่แล้ว +2

    As someone who just started learning C++ and took a yt-course which only covered the syntax, this was very helpful and I'm excited to use it in my projects.

  • @paulchoudhury2573
    @paulchoudhury2573 2 ปีที่แล้ว +5

    Outstanding and I've learned quite a bit over the years by regularly visiting his web-site!

  • @shrektan6460
    @shrektan6460 4 ปีที่แล้ว +5

    I need to reread your slides. Great and innovative explanation!

  • @deepcoding...2520
    @deepcoding...2520 4 ปีที่แล้ว +4

    Amazing presentation and glance of STL algorithms

  • @shaovoon
    @shaovoon 5 ปีที่แล้ว +8

    Thanks, Jonathan for the good talk, that was the most productive hour in my C++ learning history! 105 STL Algos in less an hour! Is your world map from a mindmap?

  • @KangoAbhiram
    @KangoAbhiram 5 ปีที่แล้ว +3

    Excellent presentation. Concise and very informative.

  • @bubblesort8760
    @bubblesort8760 ปีที่แล้ว

    That map was phenomenal !. Remarkable presentation!

  • @Karsteski
    @Karsteski ปีที่แล้ว +1

    I love how much effort went into this. Great talk

  • @grahambest3809
    @grahambest3809 4 ปีที่แล้ว +2

    Awesome talk. Johnathon Boccara explains it beautifully! Acquired a few new tools :-)

  • @jvsnyc
    @jvsnyc 3 ปีที่แล้ว +6

    I somehow left lower_bound and upper_bound out of my notes, thought we might have missed it, so re-watched. Technically, the whole thing doesn't need to necessarily be fully sorted for a lower_bound call to work, as long as everything < val comes before the first element equal to val, and upper bound should be good as long as everything there onwards is > val. They both give correct answers for all val if the whole range is fully sorted, by far the neatest case.

    • @constantijndekker8343
      @constantijndekker8343 3 ปีที่แล้ว +1

      Actually, I believe the entire functuon is redundant because you can use partition_point with the right predicate, which as you describe only demands that the range is partitioned with respect to this predicate.

  • @mattt2684
    @mattt2684 5 ปีที่แล้ว +4

    ...and I thought my day wouldn't get any better!
    Amazing talk!

  • @bigphatballllz
    @bigphatballllz 5 ปีที่แล้ว +6

    One of the best talks of all time on cppcon.

  • @TruthNerds
    @TruthNerds 5 ปีที่แล้ว +7

    Very informative talk. Here are the obligatory flies in the ointment:
    30:29 adjacent_find does not take a value and it does not return the first position where there are two adjacent occurrences of the value. Instead, adjacent_find returns the first position where ANY two adjacent and equal values appear. (You can use the overload with binary predicate to perform the operation described, but that's, I reckon, not a common use case, and requires extra typing at least.)
    31:40 This is misleading, *all* of lower_bound, upper_bound, equal_range and binary_search do a binary search (the complexity guarantees practically mandate that). binary_search is just the only algorithm to carry the binary search in its name. (If you are extra pedantic, equal_range actually does two binary searches, one of which may be limited in scope.)

  • @cafelashowerezweb
    @cafelashowerezweb 4 ปีที่แล้ว

    Thank you for the great explanation,
    really helpful

  • @zhangzhang2851
    @zhangzhang2851 ปีที่แล้ว +1

    clear presentation, recommended for me in the 2017

  • @nichevo
    @nichevo 4 ปีที่แล้ว +9

    Great talk! Few notes:
    22:51 There is no such thing as is_partitioned_until in STL
    51:51 C++17+: uninitialized_move, destroy, uninitialized_default_construct, uninitialized_default_construct

    • @Evan490BC
      @Evan490BC 2 ปีที่แล้ว +4

      "There is no such thing as is_partitioned_until in STL" ... yet!

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

      is partitioned until partition point xd

  • @madpad759
    @madpad759 5 ปีที่แล้ว

    Really great presentation

  • @Betadel
    @Betadel 5 ปีที่แล้ว +24

    Great talk! Any plans of updating it for C++20 (with ranges and other new algorithms)?

    • @darkee03
      @darkee03 5 ปีที่แล้ว +15

      dude, not even c++17 is fully supported by major compiler vendors...

  • @lupinedreamexpress
    @lupinedreamexpress 5 ปีที่แล้ว +3

    Interesting video. I will definitely be saving the slides and pdf offline for reference. *Edit: After reviewing the github link shared in the video description, Jonathan's talk is not among the presentations shown in CppCon2018 in the list in their README ~Wonders if they found him relevant enough for inclusion~ *

    • @thx947
      @thx947 5 ปีที่แล้ว

      I found one. 2018.cppconf.ru/talks/day-1/track-a/3.pdf

  • @cicciobombo7496
    @cicciobombo7496 5 ปีที่แล้ว +3

    Lovely talk, really good english and you look better on camera rather than google images
    The map is AWESOME
    9/10 talk, would listen again

    • @zuradzindzibadze8733
      @zuradzindzibadze8733 4 ปีที่แล้ว

      Sry for the late reply... Please give me your 10/10 talk ;)

  • @akaDL
    @akaDL ปีที่แล้ว +1

    Great content. Coming from learncpp!

  • @fgfanta
    @fgfanta 6 หลายเดือนก่อน +2

    Can't like this video enough.

  • @1aggin_5amurai
    @1aggin_5amurai 3 ปีที่แล้ว +3

    Great presentation! Thanks!

    • @CppCon
      @CppCon  3 ปีที่แล้ว

      Very welcome!

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

    This is pure gold!

  • @shitshow_1
    @shitshow_1 ปีที่แล้ว

    Thanks for the Amazing presentation !

    • @CppCon
      @CppCon  ปีที่แล้ว

      Thank you too!

  • @no2boblennon
    @no2boblennon 4 ปีที่แล้ว +6

    And now I want the map!

  • @bnd8371
    @bnd8371 5 ปีที่แล้ว

    great presentation

  • @kirubakaransujanaranjan2877
    @kirubakaransujanaranjan2877 4 ปีที่แล้ว

    Thank you for the talk

  • @sargeus
    @sargeus 5 ปีที่แล้ว

    Thank you very match!

  • @tomhollins9266
    @tomhollins9266 4 ปีที่แล้ว

    Superb. Kudos.

  • @scotthamilton228
    @scotthamilton228 4 ปีที่แล้ว +7

    24:44 francais spotted, excellente vidéos

  • @ivanp_personal
    @ivanp_personal ปีที่แล้ว +1

    Great talk!

  • @guykeren9666
    @guykeren9666 3 ปีที่แล้ว

    Great video, thanks

    • @CppCon
      @CppCon  3 ปีที่แล้ว

      Glad you liked it!

  • @MindGameArcade
    @MindGameArcade 2 ปีที่แล้ว +2

    Great talk

  • @ABaumstumpf
    @ABaumstumpf 4 ปีที่แล้ว

    I should have watched that video a year ago.
    wouldn't have solved my problems cause the requirements were just so strange but it might have made some of my constructs a little easier to read.
    remove-erase: In some situations you just want to remove the elements but not erase them. Does not happen often, but can be quit useful for example if you need a static memory footprint.
    Would be good if there was a "pure" erase too.

  • @arunpal3792
    @arunpal3792 5 ปีที่แล้ว +2

    I need that video which start at 7.55 😍

  • @YourCRTube
    @YourCRTube 5 ปีที่แล้ว +8

    It would have been helpful to see the signatures of the functions. Also it would have been nice to mention lower_bound can be used if one wants binary search that finds an item. More (any) uses would have been great even if this makes the talk 105 minutes long.

  • @Svitlana.Lubenska
    @Svitlana.Lubenska 4 ปีที่แล้ว +1

    Reminded me a C++ map by Alena ;)

  • @raymondlu9232
    @raymondlu9232 5 ปีที่แล้ว +1

    Good job! I want that map, haha~

    • @-taz-
      @-taz- 5 ปีที่แล้ว

      Yeah, this map needs to be in a museum, er, store. EDIT: As someone else pointed out: www.fluentcpp.com/getTheMap/

  • @zhaoli2984
    @zhaoli2984 5 ปีที่แล้ว +2

    The talk is awesome.

  • @bwatspro
    @bwatspro 5 ปีที่แล้ว +2

    that was really amazing

  • @LukenSkyne
    @LukenSkyne 4 ปีที่แล้ว +6

    Used only for std::sort until now.

    • @brainplot
      @brainplot 4 ปีที่แล้ว +2

      Once you start using other algorithms you really can't go back. is still something I miss when writing other languages besides C++.

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

    are there other videos on rest of the stl library ?

  • @computervisiondev
    @computervisiondev 3 ปีที่แล้ว +1

    Are the posters no longer available? D:

  • @Lazlowi
    @Lazlowi 4 ปีที่แล้ว +3

    Am I working with too many abbreviations if my first thought at IOTA - quite a funny name was that it is "increment over the array - why is that funny?"

  • @debugx1
    @debugx1 5 ปีที่แล้ว +1

    greate talk, thanks a lot

  • @logancheatum8397
    @logancheatum8397 ปีที่แล้ว +1

    When the man pulled out the map of algorithms I knew I was on some nerd shit

  • @childhood1888
    @childhood1888 2 ปีที่แล้ว

    Why didn't the committee overload functions like fill instead of writing new ones with _n like fill_n?

  • @jakubhorak636
    @jakubhorak636 5 ปีที่แล้ว +8

    Hmmm... he said that set_symetric_difference is the longest name, but I think uninitialized_default_construct_n is longer :D

  • @PawanKumar-jh4bj
    @PawanKumar-jh4bj 5 ปีที่แล้ว

    Now, this is what i am looking for.

  • @muradghazzawi5088
    @muradghazzawi5088 5 ปีที่แล้ว

    amazing presentation , where can i find the presentation slides ? i didn't found them in the link that's in the description

    • @thx947
      @thx947 5 ปีที่แล้ว

      I found one. 2018.cppconf.ru/talks/day-1/track-a/3.pdf

  • @JohnJTraston
    @JohnJTraston 3 ปีที่แล้ว

    It's also for_every and for_any

  • @jh-lp7cg
    @jh-lp7cg 4 ปีที่แล้ว +1

    I want this map.

  • @NewInfinityRecursion
    @NewInfinityRecursion 5 ปีที่แล้ว +1

    WOW

  • @venkateswarans1012
    @venkateswarans1012 4 ปีที่แล้ว +3

    Still my interviewer ask me to write binary search tree using doubly linked list with raw pointer😣.

    • @TheYaBoyKevin
      @TheYaBoyKevin 4 ปีที่แล้ว

      Did they want you to build a BST using the values from the doubly linked list?

    • @zuradzindzibadze8733
      @zuradzindzibadze8733 4 ปีที่แล้ว +5

      if you have no idea how code works most likely when need arise you wouldn't realise which algorithm is the most appropriate.
      That's why big tech companies are so obsessed with Algorithms and tricky problems. If you pass them, it's most likely that you will solve any future problem with high efficiency.

    • @brainplot
      @brainplot 4 ปีที่แล้ว

      @@zuradzindzibadze8733 Even if you don't properly "pass" them, seeing how you go about solving a hard problem can outline your problem-solving skills.

  • @YourTVUnplugged
    @YourTVUnplugged 5 ปีที่แล้ว

    C++ FTW!!!!!! :D

  • @kennethj.5683
    @kennethj.5683 5 ปีที่แล้ว +4

    13:20

  • @larrytroxler7017
    @larrytroxler7017 2 ปีที่แล้ว

    Once he said "use case", I split the scene soon after.

  • @mehershrishtinigam5449
    @mehershrishtinigam5449 2 ปีที่แล้ว

    i didnt get the each joke at 13:24 :(

  • @PixelPulse168
    @PixelPulse168 5 ปีที่แล้ว +2

    where can I get this map

    • @smellytaint
      @smellytaint 5 ปีที่แล้ว +4

      www.fluentcpp.com/getTheMap/

    • @seidenada526
      @seidenada526 5 ปีที่แล้ว +2

      56:44

  • @ViktorEngelmann
    @ViktorEngelmann 5 ปีที่แล้ว +1

    I wish there were "functional" equivalents for them all. Like list, vector, etc. should have a common base-class "container" (or so) that has a begin() and end() method. And then there should be inline for_each(container& c, f) etc. which does nothing other than call the other for_each(c.begin(), c.end(), f). The absence of these forces you to first construct the container and then pass it to the algorithm. Kevlin Henney calls such code "object-assembler" because of the "first X then Y" way of thinking. I would just prefer to do that in a nested way in one single expression, which I would consider a more "functional" way of doing it. In particular, it would allow you to compose the algorithms!

    • @NomoregoodnamesD8
      @NomoregoodnamesD8 5 ปีที่แล้ว +4

      The reason you have to pass iterators to algorithms is that it promises that the algorithm will not modify the underlying container (save for giving a back_inserter to transform, generate, etc). This strong promise means that you are guaranteed that none of your other iterators will be invalidated after the algorithm ends.

    • @NomoregoodnamesD8
      @NomoregoodnamesD8 5 ปีที่แล้ว

      Also, this would put more requirements on the container using the algorithm. You have to supply an overload for std::begin and std::end OR have a container.begin and container.end. By only requiring an iterator, you can pass raw pointers to algorithms, and provided they meet the criteria, they will function just as well as a vector.

    • @GasperAzman
      @GasperAzman 5 ปีที่แล้ว +2

      Ranges will get you that sugar, in C++20, and much, much more. You also don't need a common base-class to write generic code - they have a common Concept - Container! It is easy to implement the `for_each` you want above :), or should I say the N versions of it, since you have quite a large design space for a functional for_each :)

    • @joestevenson5568
      @joestevenson5568 4 ปีที่แล้ว +1

      But thats what for each does already? It works on anything with iterators ie any container you can dream up. Plus const_iterators exist, giving you the ability to trust algorithms to not have side effects on your data, which is about as "functional" as you practically often want to be.

  • @gggrow
    @gggrow 4 ปีที่แล้ว +1

    What accent is that?

  • @childhood1888
    @childhood1888 2 ปีที่แล้ว

    24:44 C plüs plüs

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

    Well, to be honest, this presentation is useful but that's just reading a cpp STL docs...

  • @GeorgeTsiros
    @GeorgeTsiros 5 ปีที่แล้ว +1

    i managed 15 minutes.

  • @tosemusername
    @tosemusername 5 ปีที่แล้ว +12

    Jonathan is overly charismatic lol

  • @tanujnagpal572
    @tanujnagpal572 4 ปีที่แล้ว +14

    1.25x do yourself a favour

  • @__hannibaal__
    @__hannibaal__ ปีที่แล้ว

    All these Algorithms deal with Sorting and Looking for,
    Programmer need to dig in mathematics to change these situations.

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

    It's great, and std algorithms are probably the best designed part of the C++ universe. Why do we need std::move, really? To create something in a function and then move it to a container? Or to "move it" out? It's a bit convoluted and unnecessary.

  • @sacredgeometry
    @sacredgeometry 2 ปีที่แล้ว

    3:08 The perfect example of someone taking some horribly written code and turning into exponentially worse code albeit more terse code (the terseness isn't a good thing here, it just makes it worse)

  • @KilgoreTroutAsf
    @KilgoreTroutAsf 5 ปีที่แล้ว +2

    105 ways to make your code run even slower

    • @KilgoreTroutAsf
      @KilgoreTroutAsf 5 ปีที่แล้ว

      @@Lunaticracy I feel sorry for the users of the code.

  • @szirsp
    @szirsp 2 ปีที่แล้ว +1

    4:20 "When we write for loops"... UB... And NO! Literally NOT everything can happen, only what is allowed by the law of physics can happen.
    But now I know not to trust anything you say. Well done. You lost my trust in the first 5 minutes. ;)
    "With the STL algorithms this doesn't happen they said"...
    int arr[3] = { 1,2,3 }; int sum;
    sum = accumulate(arr, arr+5, 0); /// Oh, NO, how could the STL algorithm fail us
    sum = 0; for (auto v : arr) sum += v; /// meanwhile the for loop is just fine
    sum = accumulate(begin(arr), end(arr), 0); /// to be fair we can make it safe with the STL, but did you notice how it is longer than the for loop? ... even without the std::
    sum = std::accumulate(std::begin(arr), std::end(arr), 0); /// now it's "beautiful"!
    sum = 0; for (auto const& v : arr) sum += v; /// the for loop is still shorter even with const ref...
    "STL algorithms are used by" ... BS number ...
    and for loops are used orders of magnitude more...
    Just remember: for loops run the world