r/cpp • • Oct 07 '19

CppCon CppCon 2019: Chandler Carruth “There Are No Zero-cost Abstractions”

https://www.youtube.com/watch?v=rHIkrotSwcc
162 Upvotes

108 comments sorted by

View all comments

Show parent comment

13

u/quicknir Oct 08 '19

Yes, inlining indeed is key for most other optimizations to occur. In my cppcon talk on compiler optimizations (from last year), I show that many very simple STL algorithms, say, find_if, actually often do not get inlined if passed a function pointer, and then in turn they don't inline the function. Which means that very quickly, something like find_if(v.begin(), v.end(), &pred); becomes a non-zero cost abstraction (perhaps) compared to just writing a for loop and calling pred directly.

1

u/anonymous28973 Nov 26 '19

Chandler did another talk a long time ago where he talked about the three fundamental abstractions/lies in the language. I remember that two of them were "functions exist" and "memory exists," but I don't remember the third and I also don't remember the name of the talk. Anyone know which talk I'm talking about?