5 ms·
> Actix-web is in 2.0. What's the situation with use of unsafe now? Although toxicity that was shown by the community was obviously uncalled for, I was very p
by golergka 7y ago
> Actix-web is in 2.0.
What's the situation with use of unsafe now?
Although toxicity that was shown by the community was obviously uncalled for, I was very put off by the original author's stance on the issue and am wary of using it in production.
- libria 7y agoDon't know current situation, here's from a couple months ago, from a maintainer (not the original author): > Performance remains the key reason for the unsafe blocks. As per the safety dance charter, changing std Rust so as to eliminate the need for unsafe seems like the best course of action, but this work is beyond my comprehension. https://www.reddit.com/r/rust/comments/efk7n7/actixweb_v20_released/fc300rm/ https://www.reddit.com/r/rust/comments/efk7n7/actixweb_v20_r...
- steveklabnik 7y agoThe original author has handed it off to some of the other maintainers.
- correct_horse 7y agoAll issues dealing with undefined behavior (UB), segfaults and the like are currently closed. Actix-Web makes use of unsafe (as high-performance Rust usually does) so there could be some UB hiding.
- AgentME 7y ago"Closed" as in ignored, or solved with actions taken? Asking legitimately, because the stuff I'd read previously didn't fill me with confidence.
- correct_horse 7y agoWith actions taken in all of 5 issues. See all issues here https://github.com/actix/actix-web/issues?q=label%3Aunsafe+ https://github.com/actix/actix-web/issues?q=label%3Aunsafe+
- adamc 7y agoHonest question: What is the point of using Rust if you have to use unsafe constructs to get performance?
- steveklabnik 7y agounsafe is an escape hatch. You don't have to use unsafe to get performance, in the general case. Often, safe code is as fast or faster than unsafe code. But sometimes, it is needed. Even then, the point of using Rust is containment: you can write a safe abstraction over that unsafe code, and minimize the hunt for what you did wrong, if you've made a mistake and caused a problem.
- kbenson 7y agoIt might be useful to think of unsafe portions the same way you would consider calling out to a C library from some managed language. If you have one or two modules you're using that cal calling out to C libs, and your managed language is segfaulting, it's probably somewhere to do with those libraries, or how you're utilizing them (maybe a bad API or abstraction). Rust just lets you take that reasoning further in the case of unsafe, since you can see the unsafe code in the same codebase, it's basically the same language plus a couple extra features, and can be kept much smaller (at least in the case where the functionality is implemented in Rust). Unsafe isn't meant to imply "don't do this", it's meant to imply you're giving up the safety generally afforded. It's like driving a car without seatbelts and airbags down the freeway, not like driving a car at 100Mph on a windy cliff-side road. 1: Or to the same level, if using unsafe to abstract over a C lib also
- eeZah7Ux 7y agoNot much.
- Too 7y agoWhat are your alternatives? Managed memory language or C/C++? Rust has much more modern and ergonomic syntax, features and package management over C, so even inside unsafe blocks it's simply easier to write.
- 7y ago
- cercatrova 7y agoThe author chose a new maintainer who is fixing the unsafe issues. It seems to be much better now, as well as working on stable instead of nightly, and the maintainer is much less "toxic" than the original author.