3 ms·
The fatal mistake here is using the STL...
by intelVISA 3y ago
The fatal mistake here is using the STL...
- tialaramex 3y agoThe safe thing Rust did here is affordable in Rust (Option<T> is the same size as T for many T including all references) so they could afford to do it, whereas it's expensive in C++. Could it have been made cheaper in C++? Sure, but safety wasn't their priority so who cares? That prioritisation applies to the whole ISO language, not only to the standard library.
- pjmlp 3y agoTalking about C? https://godbolt.org/z/vYcMhE9h7 https://godbolt.org/z/vYcMhE9h7
- tialaramex 3y agoYou turned on a feature which helps diagnose this type of mistake at runtime, and it helped you by diagnosing the mistake at runtime. What does that prove? What I'm talking about is that Rust's Option is very cheap in all the cases where it can be very cheap, which makes this whole design feature more affordable. C++ eventually grew std::optional which is not powerful enough for this work and yet is also bigger and slower. They could have done better, but safety wasn't a priority.
- pjmlp 3y agoIt proves that there is a way to diagnose this type of mistake, that is what matters. Unlike C, which the only way to be safe is not to touch it at all. As for performance, ISO doesn't implement compilers, there are many ways to improve performance while keeping the semantics in line with the standard. If the compiler vendors decide to focus elsewhere is another matter, a bit like there are languages as complex as Rust and compile faster, because that has been a concern, whereas rustc developers have their concerns elsewhere.
- pjmlp 3y agoThe fatal mistake is not enabling bounds checking, which most STL implementations support.
- intelVISA 3y ago-Wabsolutely-everything I haven't written the Language of Kings in a while: does GCC -Wall truly enable all warnings yet?
- staunton 3y agoObviously not. It would be an instant scandal if they tried that.
- astrange 3y agoIt doesn't, and that would be a bad thing, because warnings aren't magic and bug-free themselves. Nor is there any reason to comply with every single warning every person in the world has come up with. clang has a -Weverything and it isn't supported.