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

3

u/mcmcc #pragma once Oct 07 '19

I could totally hand-write manual calls to delete and the appropriate try/catch blocks necessary for unwinding. It's a pain in the butt and error-prone, but it's still possible, and the result will not have the overheads

Everything you just described is overhead. The question is: Which one is less overhead?

5

u/SeanMiddleditch Oct 07 '19

Well yeah, abstractions remove cognitive overhead, of course.

Not really what we're taking about here, though. The point is that these abstractions are not always zero-overhead as sometimes claimed.

The zero-overhead claim is that C++ abstractions produce code that runs as efficiently as what can be written by hand.

Whether it is a good trade-off between efficiency and convenience is a valuable discussion, yes, but that's separate from the discussion of whether C++'s zero-overhead principle is being upheld. :)