2 ms·
Many 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
by Rochus 3y ago
Many 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).