3 ms·
Which cost is clearly defined: runtime cost. Yes, there are other sorts of tradeoffs that have costs too, but that's not what the saying is about. This is why
by steveklabnik 3y ago
Which cost is clearly defined: runtime cost. Yes, there are other sorts of tradeoffs that have costs too, but that's not what the saying is about.
This is why some folks have been trying to switch to "zero-overhead abstraction," in the hopes that it is more clear.
- Rochus 3y agoMany costs are sufficiently tangible, if people care. "zero-cost abstractions" is a myth that some people first attributed to C++, and now apparently also other language communities are infected. Nobody seems to care that the original wording is "zero-overhead", as you correctly state, which is something completely different than "zero-cost". EDIT: The "zero-overhead rule" was already part of the first edition of "The Design and Evolution of C++" by Stroustrup in 1994. A somewhat more concise formulation can be found in the current edition of "The C++ programming language" (2013): "If programmers can hand-write reasonable code to simulate a language feature or a fundamental abstraction and provide even slightly better performance, someone will do so, and many will imitate. Therefore, a language feature and a fundamental abstraction must be designed not to waste a single byte or a single processor cycle compared to equivalent alternatives. This is known as the zero-overhead principle." It is very unfortunate that the wrong wording even found its way into official Rust documents (Google "zero cost" site:doc.rust-lang.org).