Interesting. There was a really good talk at the last CPPCon by Chandler Carruth about how there is really no such thing as a zero-cost abstraction. The main point being, while you might be able to optimize against a runtime performance cost for abstractions, the cost will almost always be shifted to compile time, or to the cognitive burden on the developer.
It really makes me think there must be something like the first law of thermodynamics for logical complexity.
Re:The Decade of Swift
by steveklabnik on Tuesday December 31, 2019 @06:21PM
(#21925492)
Yeah, I haven’t watched the talk, but as you’d expect, Chandler has his head on straight. This is a common misconception: zero cost refers to runtime only. There’s always cost. Some people have started saying “zero overhead” instead to make it more clear, but it takes a while to change entrenched terminology.
Of course, Rust won’t start taking that path, but if I were to start a new language today, that’s what it would look like.