3 ms·
This is a misapplication of "zero cost abstractions." The slogan, taken from C++, means: > C++ implementations obey the zero-overhead principle: What you don’t
by steveklabnik 10y ago
This is a misapplication of "zero cost abstractions." The slogan, taken from C++, means:
> C++ implementations obey the zero-overhead principle: What you don’t use, you don’t pay for [Stroustrup, 1994]. And further: What you do use, you couldn’t hand code any better. - Stroustrup
Everything has costs; that's engineering. But "I chose the wrong data-structure for my task" is not what the slogan is addressing.
- qwertyuiop924 10y agoIndeed. But my point is that the idea that immidiately presents itself when you think "zero-cost abstraction" is wrong. >What you do use, you couldn’t hand code any better. And that will never be true: if you know exactly as much about your usecase as the abstraction, than that might be possible, but that is almost never the case (which was my second point).
- steveklabnik 10y ago> And that will never be true It is often true. Higher-level Rust code can and often does compile into the same assembly (or sometimes better!) than a lower-level construct. That's the entire premise of optimizing compilers. They're not perfect, but they do achieve this goal more often than "never". See the Option comments above for one trivial example.