Back to Basics: (Range) Algorithms in C++ - Klaus Iglberger - CppCon 2023

  Рет қаралды 28,787

CppCon

CppCon

Күн бұрын

Пікірлер: 51
@kacperkrol4394
@kacperkrol4394 10 ай бұрын
Have to admit that Klaus i in my opinion the best lecturer in CppCon! Thanks for speech ;)
@johnwellbelove148
@johnwellbelove148 11 ай бұрын
I remember many years ago (when I was getting to grips with C++) coming across the algorithms. I applied them to our codebase and the reduction in the amount of code, and improvement in readability was astounding at the time. And what's more, no reduction in performance (the application was for real-time image analysis).
@Quarky_
@Quarky_ 11 ай бұрын
Great talk! I'm halfway through, the examples are simple to follow, gives practical steps, compares different standards, and the icing on the cake is referencing previous talks for more details! Maybe someone can update the video description with links to these "further watching" talks?
@dimodimi
@dimodimi 11 ай бұрын
itCppCon20 - My Least Favorite Anti-Pattern (Conor Hoekstra) kzbin.info/www/bejne/eZurmH9reraXmbs CppCon 2019: Conor Hoekstra “Algorithm Intuition (part 1 of 2)” kzbin.info/www/bejne/poaon4JsiNt0g9E CppCon 2019: Conor Hoekstra, “Algorithm Intuition (part 2 of 2)” kzbin.info/www/bejne/qXbZiqCYaMp-qdk CppCon 2016: Ben Deane "std::accumulate: Exploring an Algorithmic Empire" kzbin.info/www/bejne/eGfXqKKwg7WIpaM CppCon 2018: Jonathan Boccara “105 STL Algorithms in Less Than an Hour” kzbin.info/www/bejne/aKDPpHqca698obc C++ Seasoning was already posted in the comments
@nicolabombace2004
@nicolabombace2004 10 ай бұрын
Klaus' conference talk? Like before watching! EDIT: Finished the talk, I wish there was a double like button! :D
@abhilekhgautam5963
@abhilekhgautam5963 2 ай бұрын
Excellent talk !!
@WhiteEyeTree
@WhiteEyeTree 10 ай бұрын
@27:12 Instead of using rotate you could just partition for the negation of what you want in the end, everything that is not what you want in the end gets put in front of it. It also maintain the relative order. Just a thought.
@nicolabombace2004
@nicolabombace2004 10 ай бұрын
This is actually addressed @54:25. It was an inside joke to mention rotate
@RonanMevel
@RonanMevel 11 ай бұрын
Great talk, thank you !I've always ket in my mind the talk from Sean Parent you've mentionned and his advise : Know your STL !
@VoidloniXaarii
@VoidloniXaarii 11 ай бұрын
Thank you for this both great and entertaining even at times amusing talk! So much to learn... Makes great teachers of deep knowledge rather priceless... Thank you
@hwval-zw4hy
@hwval-zw4hy 11 ай бұрын
1. C++ seasoning 2. 105 STL algorithms in less than an hour 3. Algorithm intuition
@oddprhyme
@oddprhyme 11 ай бұрын
well prepared talk. good job and thank you!
@spacelem
@spacelem 10 ай бұрын
As a mathematical modeller, most of my code looks like while (t < T) { /* lots of complex code with many layers of loops */ } Trying to remove the main loop feels like a gargantuan task, however I do like to use algorithms wherever it makes life easier (which probably isn't the main loop).
@nigelstewart9982
@nigelstewart9982 10 ай бұрын
Nice one Klaus. I was thinking of making a trip to the USA this year, perhaps CppCon 2024 is as good excuse as any?
@John-xl5bx
@John-xl5bx 11 ай бұрын
On one hand this is great - there is a more elegant way to do these things. On the other hand, we now have yet one more substantially different way to do basic things. Even "using the STL algorithm" now includes several alternate approaches. This worsens the C++ code readability nightmare. The technical debt compounds....
@StanleyPinchak
@StanleyPinchak 10 ай бұрын
Unmaintainable for loops for teh win!
@SimonToth83
@SimonToth83 11 ай бұрын
@44:00 Definitely worth mentioning that the result is now non-deterministic (which can be totally fine).
@multiHappyHacker
@multiHappyHacker 11 ай бұрын
I suspect that using an operator overload to make Person less-than-comparable would be making your code depend on the algorithm code instead of the other way around.
@discotecc
@discotecc 3 ай бұрын
At first, overloading < doesn't seem like a bad idea as you can do this without touching the class you're establishing an order for but then you're out of luck if you're wanting your collection of objects to have more than one distinct/meaningful ordering to it
@steelpanther88
@steelpanther88 10 ай бұрын
This is quite nice this ranges stuff... Well, at least we can do our own projects with c++ 20. The joys of working with legacy code😔 Btw is this ranges included in g++ 12.3.0 ?
@multiHappyHacker
@multiHappyHacker 11 ай бұрын
Also, is it possible to use the projection-based form of min_element when you have a struct composed of 3 more structs? (and the element you are looking for is a sub-element of one of those inner structs)
@randfur
@randfur 10 ай бұрын
The projection can be a lambda function so yes.
@fbjerno1
@fbjerno1 11 ай бұрын
I think in practice the time it takes to read the raw code in many of these examples is shorter than the time it takes to look up the algorithm function on cppreference. Using indexing and size() instead of begin()/end() would in my opinion be way clearer, especially for people who program in languages other than C++.
@nigelstewart9982
@nigelstewart9982 10 ай бұрын
C++ containers do not necessarily support random access for indexing, or even know their own size. That's the generality of iterators.
@Roibarkan
@Roibarkan 11 ай бұрын
C++ Seasoning, Sean Parent, GoingNative 2013: kzbin.info/www/bejne/p3mZpIaFp5KsoZo
@letsbegin_staytrue
@letsbegin_staytrue 11 ай бұрын
Thanks !!
@cranil
@cranil 10 ай бұрын
Only problem with the talk is Bart would never be this nice to Lisa 😂
@ulysses4536
@ulysses4536 11 ай бұрын
Yeah, one should really learn to appreciate the STL. And the fact that it's free. I love ranges, even though many useful things are only added in v23. It's still a very helpful thing in 20 as you present
@christer8964
@christer8964 9 ай бұрын
@27:26 Shouldn't pos be pos.begin()?
@coarse_snad
@coarse_snad 9 ай бұрын
I think it's because 'pos' is an iterator. The '.begin()' method on containers is used to get the start iterator from them, but 'pos' is already an iterator here.
@KX36
@KX36 11 ай бұрын
what if the bart simpsons i know only use C arrays, raw loops and pointer arithmetic and cast every pointer to a void* because they religiously believe it performs better but they refuse to piss off and get C jobs.
@sprytnychomik
@sprytnychomik 9 ай бұрын
That int in accumulate doubles situation shows how type-safe C++ really is. Not even a warning [from a compiler].
@The1RandomFool
@The1RandomFool 10 ай бұрын
Isn't a successful exit of the program supposed to require returning 0? It seems odd to me that someone would make a macro named EXIT_SUCCESS just for 0. At least in Fish, it will print the exit code of the program to the terminal if the exit code is not 0.
@Key_Capz_
@Key_Capz_ 11 ай бұрын
well, since you put it that way, it makes more sense.
@JansthcirlU
@JansthcirlU 10 ай бұрын
The absolute irony of doing a whole talk about single-dimensional ranges and naming the main variable for all of your examples 'table'
@stefanplusplus917
@stefanplusplus917 11 ай бұрын
the simpsons made this amazing talk 10x better. or maybe they made it amazing in the first place😜
@sciptick
@sciptick 11 ай бұрын
Listing "Containers" as primary to the STL is extremely weird. The most essential part of the STL was always the iterators. After that, the algorithms. The containers were meant mainly as examples. Stepanov's expectation was that people would routinely make up their own containers; it was quite a surprise that the initial containers proved adequate for so much development, and have been added to so very slowly. His hope was that the list of algorithms would be added to by many, continually. That hope was disappointed. The whole library was meant as a way to make important algorithm implementations universally usable, and thus amortize work on optimizing testing, and proving them over widespread use. Fun fact, priority_queue got in only because Stepanov thought the committee would cut the library down, so priority_queue and for_each were "sacrificial", added to save stack, queue, and accumulate from being cut. He was astonished when the committee took it all as-is. It is why priority_queue needed so much repair, after.
@HyenaEmpyema
@HyenaEmpyema 11 ай бұрын
people writing their own containers instead of getting things done is extremely weird. You really think we're supposed to re-invent map and vector? lol okay...
@lidegao
@lidegao 11 ай бұрын
love the simpsons
@ElPikacupacabra
@ElPikacupacabra 11 ай бұрын
I'm gonna to keep it real with you chief. I prefer to do for loops. 😐 I would rather memorize a few useful algorithms than C++ syntax and a grab-bag of function names. If I know the algorithms, I will be able to use them forever, in any programming language.
@ukissrulez
@ukissrulez 11 ай бұрын
You overestimate yourself. You are a nobody watching youtube videos.
@HyenaEmpyema
@HyenaEmpyema 11 ай бұрын
that's fine, and without knowing it you're wasting your own time writing and re-writing algorithms that have already been written, optimized and debugged. If you prefer to sit in the warm kiddie pool that is safe, familiar, and full of urine, that's always your choice. But there's way more out there for people who have ambition.
@colinjohnson5515
@colinjohnson5515 10 ай бұрын
The other thing I’ve noticed as a cpp newb is how many helper funcs are C++20 which is a letdown after searching for std lib tools in languages like C#, Go, JS and Python.
@alirezanikpay
@alirezanikpay 10 ай бұрын
Sure, you should know the algorithms, but you should use the proper library in your language to use them. It's like I should know how to cut a tree with axe, but I prefer chainsaw if it's available.
@not_ever
@not_ever 10 ай бұрын
I’m gonna keep it real with you. I don’t want to work with you or any code you’ve worked on. I prefer code to be readable and not contain bugs. I don’t want to reason through your, or anyone else’s, hand rolled version of an stl algorithm I already know or can recognise at a glance and look up on cpp reference. Yes you should know how algorithms work under the hood and be able to implement them if necessary but writing idiomatic code is important in all programming languages and C++ is not an exception to this rule.
@u28OO
@u28OO 10 ай бұрын
C++ SUCKS!!! It's slow as hell!! I always have to go back to C functions for a 4x performance boost!1;1!!1
@nigelstewart9982
@nigelstewart9982 10 ай бұрын
You may have overlooked the fact that the compiled for loop compiled to the same assembly as the C++ algorithm. No way that is a 4x performance boost.
@StanleyPinchak
@StanleyPinchak 10 ай бұрын
🤡
@n00blamer
@n00blamer 9 ай бұрын
Obvious bait, but fuck it, I am a troll too: copy paste your C code into cpp file and compile it with a C++ compiler. PWN3D.
Back to Basics: C++ Concurrency - David Olsen - CppCon 2023
1:00:58
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 13 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 12 МЛН
Why Didn't He Get the Job? Let's Find Out! // Code Review
27:25
The Cherno
Рет қаралды 148 М.
Implementing Ranges and Views in C++ - Roi Barkan - C++Now 2024
1:35:51
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 6 МЛН