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

  Рет қаралды 29,489

CppCon

CppCon

Күн бұрын

Пікірлер: 51
@kacperkrol4394
@kacperkrol4394 11 ай бұрын
Have to admit that Klaus i in my opinion the best lecturer in CppCon! Thanks for speech ;)
@johnwellbelove148
@johnwellbelove148 Жыл бұрын
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).
@WhiteEyeTree
@WhiteEyeTree Жыл бұрын
@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 11 ай бұрын
This is actually addressed @54:25. It was an inside joke to mention rotate
@Quarky_
@Quarky_ Жыл бұрын
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 Жыл бұрын
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 11 ай бұрын
Klaus' conference talk? Like before watching! EDIT: Finished the talk, I wish there was a double like button! :D
@RonanMevel
@RonanMevel Жыл бұрын
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 Жыл бұрын
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
@abhilekhgautam5963
@abhilekhgautam5963 3 ай бұрын
Excellent talk !!
@SimonToth83
@SimonToth83 Жыл бұрын
@44:00 Definitely worth mentioning that the result is now non-deterministic (which can be totally fine).
@hwval-zw4hy
@hwval-zw4hy Жыл бұрын
1. C++ seasoning 2. 105 STL algorithms in less than an hour 3. Algorithm intuition
@oddprhyme
@oddprhyme Жыл бұрын
well prepared talk. good job and thank you!
@spacelem
@spacelem Жыл бұрын
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).
@Roibarkan
@Roibarkan Жыл бұрын
C++ Seasoning, Sean Parent, GoingNative 2013: kzbin.info/www/bejne/p3mZpIaFp5KsoZo
@letsbegin_staytrue
@letsbegin_staytrue Жыл бұрын
Thanks !!
@John-xl5bx
@John-xl5bx Жыл бұрын
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 11 ай бұрын
Unmaintainable for loops for teh win!
@nigelstewart9982
@nigelstewart9982 11 ай бұрын
Nice one Klaus. I was thinking of making a trip to the USA this year, perhaps CppCon 2024 is as good excuse as any?
@multiHappyHacker
@multiHappyHacker Жыл бұрын
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 4 ай бұрын
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
@christer8964
@christer8964 11 ай бұрын
@27:26 Shouldn't pos be pos.begin()?
@coarse_snad
@coarse_snad 10 ай бұрын
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.
@multiHappyHacker
@multiHappyHacker Жыл бұрын
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 Жыл бұрын
The projection can be a lambda function so yes.
@steelpanther88
@steelpanther88 Жыл бұрын
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 ?
@fbjerno1
@fbjerno1 Жыл бұрын
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 11 ай бұрын
C++ containers do not necessarily support random access for indexing, or even know their own size. That's the generality of iterators.
@cranil
@cranil Жыл бұрын
Only problem with the talk is Bart would never be this nice to Lisa 😂
@KX36
@KX36 Жыл бұрын
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.
@ulysses4536
@ulysses4536 Жыл бұрын
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
@sprytnychomik
@sprytnychomik 11 ай бұрын
That int in accumulate doubles situation shows how type-safe C++ really is. Not even a warning [from a compiler].
@The1RandomFool
@The1RandomFool Жыл бұрын
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.
@JansthcirlU
@JansthcirlU Жыл бұрын
The absolute irony of doing a whole talk about single-dimensional ranges and naming the main variable for all of your examples 'table'
@Key_Capz_
@Key_Capz_ Жыл бұрын
well, since you put it that way, it makes more sense.
@sciptick
@sciptick Жыл бұрын
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 Жыл бұрын
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...
@ElPikacupacabra
@ElPikacupacabra Жыл бұрын
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 Жыл бұрын
You overestimate yourself. You are a nobody watching youtube videos.
@HyenaEmpyema
@HyenaEmpyema Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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.
@lidegao
@lidegao Жыл бұрын
love the simpsons
@stefanplusplus917
@stefanplusplus917 Жыл бұрын
the simpsons made this amazing talk 10x better. or maybe they made it amazing in the first place😜
@u28OO
@u28OO Жыл бұрын
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 11 ай бұрын
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 11 ай бұрын
🤡
@n00blamer
@n00blamer 10 ай бұрын
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.
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
Journey Through Postgres, Exploring the Elephant
48:23
Command Prompt, Inc.
Рет қаралды 37
Back to Basics: C++ API Design - Jason Turner - CppCon 2022
1:00:42
Soft Fork  Covenant Dependent Layer 2 Review - TABConf 6
56:21
TABConf (The Atlanta Bitcoin Conference)
Рет қаралды 91
Back to Basics: C++ Concurrency - David Olsen - CppCon 2023
1:00:58
BIP HOUSE / БИП ХАУС #SHORTS
1:00
bip_house
Рет қаралды 3 МЛН
В Европе заставят Apple сделать в айфонах USB Type-C
0:18
Короче, новости
Рет қаралды 1,1 МЛН
Это лютый угар 🤣 | приколы Арсен Симонян
0:14
Арсен Симонян
Рет қаралды 294 М.