News for hackers. Stuff that matters.
Re:Hobby x86 kernel written with Zig by phendrenad2 on Monday January 06, 2020 @02:22PM (#21972194)
What I find is that, while Rust unquestionably improves the security of software, the argument that you can minimize unsafe code and thoroughly inspect it doesn't tell the full story, because in my experience people end up writing general-purpose unsafe blocks, and while they are controlled by the "safe" outside, the sequence of actions the "safe" code tells them "unsafe" code to execute can lead to subtle bugs.
Re:Hobby x86 kernel written with Zig by celticmusic on Monday January 06, 2020 @03:25PM (#21972901)
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.

Re:Hobby x86 kernel written with Zig by Cyph0n on Monday January 06, 2020 @04:20PM (#21973450)
But 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.

Re:Hobby x86 kernel written with Zig by celticmusic on Monday January 06, 2020 @04:56PM (#21973832)
I 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.

Re:Hobby x86 kernel written with Zig by Cyph0n on Monday January 06, 2020 @05:07PM (#21973995)
Ah, gotcha. Yes, improved tooling in this area would add a lot of value to the feature.
Re:Hobby x86 kernel written with Zig by steveklabnik on Monday January 06, 2020 @04:51PM (#21973786)
Those 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.
Re:Hobby x86 kernel written with Zig by celticmusic on Monday January 06, 2020 @05:45PM (#21974334)
That'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.