14 ms·
yep, 100% I personally think the Rust community has missed the biggest advantage of unsafe, and that's tooling. Imagine an IDE that could highlight and warn w
by celticmusic 7y ago
yep, 100%
I personally think the Rust community has missed the biggest advantage of unsafe, and that's tooling. Imagine an IDE that could highlight and warn when touching state that is accessed in unsafe blocks, or when state being accessed in unsafe blocks isn't being properly tested.
Or tools that kick off notification for a required code review because code that touches state used by an unsafe block got changed.
To me, these sorts of things will have a far greater effect on security and stability than just the existence of the unsafe block in code.
- Cyph0n 7y agoBut isn’t the most important step having a compiler-enforced keyword for code that seems to be doing unsafe stuff? The rest are just plugins and tools that look for said blocks and “do stuff”. I don’t see why these tools should be part of the language.
- celticmusic 7y agoI never said they should be part of the language, I said the rust community over-emphasizes the "safe" part of having the unsafe keyword and neglected the part that's actually useful in keeping things safe. Another poster responded to me stating they are starting to work on those tools, so it looks like the rust community is starting to come around. It's just that I've seen a lot of people tout the safety of rust as if the unsafe keyword was a panacea that automatically prevented problems. That attitude is really what I was responding to.
- Cyph0n 7y agoAh, gotcha. Yes, improved tooling in this area would add a lot of value to the feature.
- steveklabnik 7y agoThose tools exist or are being worked on! Servo (last I checked) uses a “unsafe code was added or modified in this PR, please review extra carefully” bot, and Miri is on its way to becoming a fantastic tool.
- celticmusic 7y agoThat's good to know. The Rust community can be a bit... fanatical, lets say. I've seen so many people argue that the unsafe keyword by itself makes rust so much safer than alternatives, when really safe code can cause unsafe code to explode. So you end up writing modules to protect the unsafe code, which is what you do in any other language as well. Which means the unsafe keyword is valuable, just not nearly as valuable as I've seen a lot of people claim. Now the unsafe keyword combined with the sort of tooling I've mentioned? That to me is a killer combination. Unsafe isn't a silver bullet, it still requires work, but it enables tools to make that work immensely easier to deal with.