Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

First, there's a misconception to be cleared :)

Unsafe code is not the only solution to borrow checking problems, as Rust supports reference counting, which is an implementation of shared ownership.

Whether this defeats the point of Rust is subjective, but regardless, it's a solution to at least certain ownership problems.

A very typical area where you can observe this is bidirectional trees. They're ugly in Rust! :)

Now, memory unsafety is not a black and white matter. In my experience with the community, you'll be surprised at how much pragmatism there is. Nobody will scream sacrilege if one expresses the necessity to use memory unsafe code¹.

The connection to your question is that overally, the Rust memory safety model is not all-or-nothing, rather, a spectrum of safety above the convenientional entirely-unsafe approach. With this in mind, I'd say that "98% Rust-safety" is well beyond the "100% unsafe" approach of traditional low-level languages.

As a matter of fact, I suppose that in the future, we'll see languages developing intermediate memory safety features (I think Zig was doing something like that).

[¹] The actix-web case is a very interesting one. I haven't looked at it, but my personal suspicion is that it made use of _wildly_ unsafe code, and that usafe of unsafe code was not the problem, rather that unnecessary usage was.



view as:

> The actix-web case

IIRC it was mostly the initial reluctance of the author to merge PRs that rewrote unsafe to safe Rust. Some escalation, some emotions, and then everything move forward in harmony and with more safety.


> IIRC it was mostly the initial reluctance of the author to merge PRs that rewrote unsafe to safe Rust.

No, not really. Spinning the actix-web as the author's reluctance to accept PRs is a gross misrepresentation of the problem faced by the project.

The author even went to great strides to explain that his use of unsafe code was indeed safe.

For context, here's what the author had to say about that regrettable episode.

https://github.com/fafhrd91/actix-web-postmortem


> No, not really. Spinning the actix-web as the author's reluctance to accept PRs is a gross misrepresentation of the problem faced by the project.

No, not really. The author, a professional at Microsoft, was a hobbyist with rust who (by his confession) wished to explore the limits of performance using various techniques. People made a mountain out of the fact that his project rocketed up to the top of the TechEmpower benchmarks -- as if this obligated him to conform to their flash-mob wishes regarding sanitized code, whereas the project very explicitly made it clear that production use was at one's own risk.

What happened to him was a hit-job by a bunch of entitled bullies. No less than Steve Klabnik acknowleged this ("far, far, far over the line"[0]). The fact that ntex exists today[1] yet the world has somehow not exploded yet demonstrates how overblown the criticisms were.

[0] https://steveklabnik.com/writing/a-sad-day-for-rust

[1] https://github.com/ntex-rs/ntex


As an outsider, as it was clear that the author wasn’t that interested in reviewing safety patches, wouldn’t a “safe-actix” fork maintained by someone else have made everyone happy?

> No, not really. The author, a professional at Microsoft, was a hobbyist with rust who (...)

It's very hard to believe that "a hobbyist" would, by mere chance, write the absolute best performing framework in the world.

https://www.techempower.com/benchmarks/

Your comment not only lacks credibility but also sounds extremely petty.


The problem is that actix-web (at the time, at least) was also quite benchmark-oriented -- it was doing a lot of things you don't necessarily want to do in production in order to get better benchmarks.

And that was especially true of the benchmark code itself.

TechEmpower's methodology, additionally, is not perfect. IIRC they support HTTP 1.0 only, which is not what most modern servers are focusing on, but actix-web did.


You can't boil what happened down into a black-or-white simplification. Because what happened is more complicated than that. Some people went over the line, absolutely, but that doesn't mean any criticism of the project was overblown or inappropriate. Lodging criticism against a project doesn't have to imply any sort of obligation on anyone.

There was some pretty bad misuse of unsafe in actix-web. And as I recall it, the author was resistant to fixing it, even when patches were provided. This is the author's right. It's their project. But it's anyone else's right to make this sort of thing visible, and to advocate against holding up actix-web (at the time) as a good example of what Rust programmers could deliver.

A lot of people can't or won't communicate effectively, and often blur these lines. Either assuming there is entitlement where there is none, or expressing entitlement when they didn't mean to. But there is a reasonable position underlying what happened, and unfortunately some took it too far.


> The author even went to great strides to explain that his use of unsafe code was indeed safe.

Some places of code were actually unsound (which means: got function containing unsafe and marked safe even if it didn't upheld the invariant of the unsafe block, meaning you could trigger UB from safe code: this is a big no-go in Rust).

That being said, the whole drama with people mobbing the author on every social media, calling him name and so on, is indeed regrettable.


> The author even went to great strides to explain that his use of unsafe code was indeed safe.

That's what any author of unsafe code is supposed to do right? Explain why the unsafe code is in fact safe (enough).


It is, yes. The parent is defending them, not trying to say that they were wrong.

With actix, the author was both misusing unsafe, as well as being completely unreceptive to PRs that resolve it with safe variants, claiming it was not dangerous in its current internal state and that the safe variant would shave percents and possibly lose it its spot as an ultra fast web library.

Legal | privacy