[Way, way, WAY]TL;DR: author doesn’t understand the meaning of “political”, has some vague complaints about Rust’s ecosystem getting more opaque due to a YouTube video, never used the language much, and doesn’t want its core feature anyway.
For many unclear reasons author won’t be recommending Rust… unclear anyone ever heard such a recommendation made.
In order to make that fast, I did C++-style generics and inlining in C via the CPP. However, it turned out that GCC does not properly optimize the result, which resulted in the following GCC bug:
I suspect things like this happen all of the time in C++ (and by extension, Rust), but developers typically do not look at the assembly output, so they do not notice and bugs are not filed with the compilers. The result is that everyone believes that the compiler will optimize away abstractions, but code can become slower because the compiler is not always able to optimize away the abstractions.
That said, it is awesome when the compiler optimizes away abstraction overhead as expected like LLVM does on that particular code.
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).
5 comments
[ 0.24 ms ] story [ 21.2 ms ] threadFor many unclear reasons author won’t be recommending Rust… unclear anyone ever heard such a recommendation made.
https://github.com/openzfs/zfs/commit/677c6f8457943fe5b56d7a...
In order to make that fast, I did C++-style generics and inlining in C via the CPP. However, it turned out that GCC does not properly optimize the result, which resulted in the following GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109901
I suspect things like this happen all of the time in C++ (and by extension, Rust), but developers typically do not look at the assembly output, so they do not notice and bugs are not filed with the compilers. The result is that everyone believes that the compiler will optimize away abstractions, but code can become slower because the compiler is not always able to optimize away the abstractions.
That said, it is awesome when the compiler optimizes away abstraction overhead as expected like LLVM does on that particular code.
There is nothing like "zero cost". Everything has a cost. Engineering is dealing with trade-offs.
This is why some folks have been trying to switch to "zero-overhead abstraction," in the hopes that it is more clear.
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).