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

Sdílet
Vložit
  • čas přidán 28. 05. 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/
    *-----*

Komentáře • 115

  • @schleppel12
    @schleppel12 Před 5 lety +311

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

    • @DarrinCullop
      @DarrinCullop Před 4 lety +12

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

  • @mrlithium69
    @mrlithium69 Před 5 lety +154

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

  • @Yupppi
    @Yupppi Před 6 měsíci +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!

  • @andrewf6725
    @andrewf6725 Před 5 lety +166

    Amazing presentation. Absolutely recommended for every STL beginners!

  • @mayankdutta2832
    @mayankdutta2832 Před 4 lety +14

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

  • @NomoregoodnamesD8
    @NomoregoodnamesD8 Před 5 lety +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.

  • @luisfsalazarb
    @luisfsalazarb Před 5 lety +76

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

  • @mindasb
    @mindasb Před 5 lety +61

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

  • @paulchoudhury2573
    @paulchoudhury2573 Před rokem +5

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

  • @srcmake
    @srcmake Před 5 lety +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.

  • @deepcoding...2520
    @deepcoding...2520 Před 4 lety +4

    Amazing presentation and glance of STL algorithms

  • @KangoAbhiram
    @KangoAbhiram Před 5 lety +3

    Excellent presentation. Concise and very informative.

  • @shrektan6460
    @shrektan6460 Před 4 lety +5

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

  • @fgfanta
    @fgfanta Před 5 měsíci +2

    Can't like this video enough.

  • @Karsteski
    @Karsteski Před rokem +1

    I love how much effort went into this. Great talk

  • @bubblesort8760
    @bubblesort8760 Před 11 měsíci

    That map was phenomenal !. Remarkable presentation!

  • @jvsnyc
    @jvsnyc Před 3 lety +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 Před 3 lety +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.

  • @nikitademodov3446
    @nikitademodov3446 Před 3 lety +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.

  • @grahambest3809
    @grahambest3809 Před 4 lety +2

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

  • @madpad759
    @madpad759 Před 5 lety

    Really great presentation

  • @bigphatballllz
    @bigphatballllz Před 5 lety +6

    One of the best talks of all time on cppcon.

  • @zhangzhang2851
    @zhangzhang2851 Před rokem +1

    clear presentation, recommended for me in the 2017

  • @nichevo
    @nichevo Před 4 lety +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 Před 2 lety +4

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

    • @gordazo0
      @gordazo0 Před 6 měsíci

      is partitioned until partition point xd

  • @mattt2684
    @mattt2684 Před 5 lety +4

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

  • @cafelashowerezweb
    @cafelashowerezweb Před 4 lety

    Thank you for the great explanation,
    really helpful

  • @akaDL
    @akaDL Před rokem +1

    Great content. Coming from learncpp!

  • @1aggin_5amurai
    @1aggin_5amurai Před 3 lety +3

    Great presentation! Thanks!

  • @ughadunk
    @ughadunk Před 8 měsíci

    This is pure gold!

  • @bnd8371
    @bnd8371 Před 5 lety

    great presentation

  • @shaovoon
    @shaovoon Před 5 lety +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?

  • @Betadel
    @Betadel Před 5 lety +24

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

    • @darkee03
      @darkee03 Před 5 lety +15

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

  • @no2boblennon
    @no2boblennon Před 4 lety +6

    And now I want the map!

  • @TruthNerds
    @TruthNerds Před 5 lety +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.)

  • @kirubakaransujanaranjan2877

    Thank you for the talk

  • @shitshow_1
    @shitshow_1 Před rokem

    Thanks for the Amazing presentation !

  • @ivanp_personal
    @ivanp_personal Před rokem +1

    Great talk!

  • @tomhollins9266
    @tomhollins9266 Před 4 lety

    Superb. Kudos.

  • @MindGameArcade
    @MindGameArcade Před 2 lety +2

    Great talk

  • @scotthamilton228
    @scotthamilton228 Před 4 lety +7

    24:44 francais spotted, excellente vidéos

  • @sargeus
    @sargeus Před 5 lety

    Thank you very match!

  • @lupinedreamexpress
    @lupinedreamexpress Před 5 lety +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 Před 5 lety

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

  • @guykeren9666
    @guykeren9666 Před 3 lety

    Great video, thanks

    • @CppCon
      @CppCon  Před 3 lety

      Glad you liked it!

  • @logancheatum8397
    @logancheatum8397 Před rokem +1

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

  • @maryguty1705
    @maryguty1705 Před 7 měsíci

    are there other videos on rest of the stl library ?

  • @computervisiondev
    @computervisiondev Před 2 lety +1

    Are the posters no longer available? D:

  • @cicciobombo7496
    @cicciobombo7496 Před 5 lety +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

  • @bwatspro
    @bwatspro Před 5 lety +2

    that was really amazing

  • @LukenSkyne
    @LukenSkyne Před 4 lety +6

    Used only for std::sort until now.

    • @brainplot
      @brainplot Před 4 lety +2

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

  • @zhaoli2984
    @zhaoli2984 Před 5 lety +2

    The talk is awesome.

  • @raymondlu9232
    @raymondlu9232 Před 5 lety +1

    Good job! I want that map, haha~

    • @-taz-
      @-taz- Před 5 lety

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

  • @ABaumstumpf
    @ABaumstumpf Před 4 lety

    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.

  • @YourCRTube
    @YourCRTube Před 5 lety +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.

  • @arunpal3792
    @arunpal3792 Před 5 lety +2

    I need that video which start at 7.55 😍

  • @Lazlowi
    @Lazlowi Před 4 lety +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?"

  • @childhood1888
    @childhood1888 Před 2 lety

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

  • @Svitlana.Lubenska
    @Svitlana.Lubenska Před 4 lety +1

    Reminded me a C++ map by Alena ;)

  • @NewInfinityRecursion
    @NewInfinityRecursion Před 5 lety +1

    WOW

  • @debugx1
    @debugx1 Před 5 lety +1

    greate talk, thanks a lot

  • @jakubhorak636
    @jakubhorak636 Před 5 lety +8

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

  • @jh-lp7cg
    @jh-lp7cg Před 4 lety +1

    I want this map.

  • @muradghazzawi5088
    @muradghazzawi5088 Před 5 lety

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

    • @thx947
      @thx947 Před 5 lety

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

  • @venkateswarans1012
    @venkateswarans1012 Před 4 lety +3

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

    • @TheYaBoyKevin
      @TheYaBoyKevin Před 4 lety

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

    • @zuradzindzibadze8733
      @zuradzindzibadze8733 Před 4 lety +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 Před 4 lety

      @@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 Před 4 lety

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

  • @PawanKumar-jh4bj
    @PawanKumar-jh4bj Před 5 lety

    Now, this is what i am looking for.

  • @kennethj.5683
    @kennethj.5683 Před 5 lety +4

    13:20

  • @JohnJTraston
    @JohnJTraston Před 3 lety

    It's also for_every and for_any

  • @larrytroxler7017
    @larrytroxler7017 Před 2 lety

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

  • @mehershrishtinigam5449

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

  • @PixelPulse168
    @PixelPulse168 Před 5 lety +2

    where can I get this map

  • @gggrow
    @gggrow Před 4 lety +1

    What accent is that?

  • @childhood1888
    @childhood1888 Před 2 lety

    24:44 C plüs plüs

  • @ViktorEngelmann
    @ViktorEngelmann Před 5 lety +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 Před 5 lety +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 Před 5 lety

      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 Před 5 lety +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 Před 4 lety +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.

  • @piotrlezanski5156
    @piotrlezanski5156 Před 2 měsíci

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

  • @tanujnagpal572
    @tanujnagpal572 Před 4 lety +14

    1.25x do yourself a favour

  • @GeorgeTsiros
    @GeorgeTsiros Před 5 lety +1

    i managed 15 minutes.

  • @tosemusername
    @tosemusername Před 5 lety +12

    Jonathan is overly charismatic lol

  • @__hannibaal__
    @__hannibaal__ Před rokem

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

  • @pedromiguelareias
    @pedromiguelareias Před 7 měsíci

    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 Před 2 lety

    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 Před 5 lety +2

    105 ways to make your code run even slower

    • @KilgoreTroutAsf
      @KilgoreTroutAsf Před 5 lety

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

  • @szirsp
    @szirsp Před 2 lety +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