4 ms·
I totally agree that Rocket requiring nightly is a deal-breaker for production. I suspect the author picked Rocket because it feels more beginner friendly than
by correct_horse 7y ago
I totally agree that Rocket requiring nightly is a deal-breaker for production. I suspect the author picked Rocket because it feels more beginner friendly than alternatives.
Actix-web is in 2.0. The original author stepped away recently, but it has quite the community behind it.
If readers are curious why Rocket requires nightly, it has to do with the macros (that resemble Java annotations/python decorators). Specifically Rust wants all its macros to be hygienic - they shouldn't be able to (for example) create variables that clobber user-defined variables. Rust has multiple types of macros, but the type used by Rocket, procedural macros, don't have this hygienic property yet. For context, procedural macros operate on TokenStreams, whereas "normal macros" (declarative macros) operate on AST nodes. See the issue https://github.com/SergioBenitez/Rocket/issues/19 https://github.com/SergioBenitez/Rocket/issues/19
- 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
- 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.
- nicoburns 7y agoNote: there's a PR in for stabilisation for the requisite macro feature, and it looks like it's going to be merged soon.
- swsieber 7y agoI did some digging for those interested. Compile on Stable (Rocket): https://github.com/SergioBenitez/Rocket/issues/19 https://github.com/SergioBenitez/Rocket/issues/19 Stabilize Proc Macro Hygiene (Rust): https://github.com/rust-lang/rust/issues/54727 https://github.com/rust-lang/rust/issues/54727 Partially Stabilize Proc Macro Hygiene (Rust): https://github.com/rust-lang/rust/pull/68717 https://github.com/rust-lang/rust/pull/68717