3 ms·
"Abstraction without overhead" is explicitly a goal of Rust. https://blog.rust-lang.org/2015/05/11/traits.html https://blog.rust-lang.org/2015/05/11/traits.htm
by sciurus 8y ago
"Abstraction without overhead" is explicitly a goal of Rust.
https://blog.rust-lang.org/2015/05/11/traits.html https://blog.rust-lang.org/2015/05/11/traits.html
- blub 8y agoFrom your link: "C++ implementations obey the zero-overhead principle: What you don't use, you don't pay for". In Rust you pay for e.g. bounds checking or integer overflow handling or optionals. But I don't understand why everyone's getting so defensive about this, since it's the only way (static verification and proofs aside) to get the desired safety characteristics...
- steveklabnik 8y agoYou only pay for bounds checks if you use them, same with the overflow stuff, or option types. That's not in contradiction to this principle.
- deleted 8y ago[deleted]
- carlmr 8y agoIn Rust release builds the integer overflow of checks are disabled. They're not zero cost and there's no magical way to do it, so it's only done in debug builds. You can disable them in debug builds as well with wrapping integers. So this is again a practice of making the safer option the default, but won't incur runtime costs if it bothers you. If there is a way to do it at compile time that will usually be used in rust.
- deleted 8y ago[deleted]