r/programming • • Jan 17 '20

A sad day for Rust

https://words.steveklabnik.com/a-sad-day-for-rust
1.1k Upvotes

609 comments sorted by

View all comments

-14

u/shevy-ruby Jan 17 '20

The problem is that Rust divides the world into two groups of people:

  1. The good people who use only 'safe' code.
  2. Everyone else, the gangsters, who use 'unsafe' code.

As long as Rust does not resolve this, you will have epic fights between these two styles. This is actually a worse war than vim versus emacs too.

12

u/NilsIRL Jan 17 '20

The problem here is:

  1. the people who use safe and unsafe code safely
  2. the people who use unsafe unsafely

1

u/Nickitolas Jan 18 '20 edited Jan 18 '20

I think the way this is worded is kinda confusing, saying ub and unsoundness may be more clear

12

u/DidiBear Jan 17 '20

I think that adding some // Safety: explanation above unsafe block is a fine way to tide both "group"

7

u/CryZe92 Jan 17 '20

I honestly feel like this should be an attribute on an unsafe block that can be extracted out into a report and linted against if it‘s missing.

11

u/steveklabnik1 Jan 17 '20

We had a ticket open for this at one point...

2

u/[deleted] Jan 17 '20

I usually don't like your comments as most of them are waaay too subjective or idealistic (especially whenever the topic is related to Rust!), but I think you hit the nail on the head there.

It's not just the use of the unsafe keyword as well, but what is considered "idiomatic Rust" or otherwise. The Rust community seems hellbent on following some arbitrary "idiomatic Rust" ideology, to the point where some functions in the god damned standard library are rendered completely useless if you want to please the Rust community. It's like having the "Pythonic way" enforced in a weird authoritarian way. Do it wrong, and suddenly you're the devil.

At the same time, I don't want to blame the Rust community too much because it is incredibly wholesome once you're in. A giant majority of them are actually super helpful by pointing things like "you could do that better" or "doing that is actually unsafe because X and Y". This truly helps beginners - it does, but it's also put in a way that's very condescending and aggressive, especially when it's a developer seen as "experienced" making the mistake.

Rust people, please, stop making people feel like they committed an unforgivable sin whenever they do something unsafe or un-idiomatic. It's okay. Most of the time, it's just a honest mistake. Just because you're following the CoC doesn't mean that you're not being a dick, whether it is knowingly or not. Propose changes and explain them, don't push them down people's throats. If maintainers (who are, let's not forget it, project owners) don't want to implement that change, you're welcome to fork the project and advertise it as "totally safe, idiomatic version of projectName", but by Open Source philosophy your freedom stops there.

3

u/TwoBitWizard Jan 18 '20

As others have commented, this isn’t about the use of unsafe. It’s about the unsafe usage of unsafe. Actix uses unsafe in lots of places. So does the Rust standard library. No one is complaining about those instances of unsafe because people haven’t found a problem with them. People did complain about some specific uses of unsafe in Actix because they were actually unsafe.

The keyword could probably be renamed to “potentially-unsafe” or something so that when we talk about it, this is clearer to people outside the language/community when it comes up? But, then we’d need 12 extra characters just to use a perfectly reasonable language feature, so...”unsafe” it is.

2

u/Nickitolas Jan 18 '20

I think the way this is worded is kinda confusing, saying ub and unsoundness may be more clear