5 ms·
Whats the state of Rust if I wanted to get into it for backend development? I've looked briefly into Rocket and liked it but didn't delve too deep, I understand
by jamil7 7y ago
Whats the state of Rust if I wanted to get into it for backend development? I've looked briefly into Rocket and liked it but didn't delve too deep, I understand Actix is one of the most mature?
- hd4 7y agohttps://www.arewewebyet.org/ https://www.arewewebyet.org/
- _-___________-_ 7y agoI wouldn't call Actix the most mature, but it's definitely the one that gets talked about the most. I built a fairly complex backend directly on top of Hyper[0] (it doesn't even involve that much glue, really) in 2016 and have updated it as Rust and Hyper have matured. It's actually a delight to work on, and I brought a new hire on board recently who had no trouble getting up to speed, since everything is just straightforward, idiomatic Rust. I've looked at basically every Rust "web framework" that's been released since 2016, and I can't see any of them simplifying the codebase enough to justify using them. Quite a few of these frameworks result in code that isn't obvious to a Rust programmer who hasn't used that framework before, too, which I consider a disadvantage (I prefer obvious over clever). [0] edited to add for those that may not be aware: Hyper is a client & server HTTP library. Many/most of the frameworks are built on top of it.
- DarthGhandi 7y agoActix smashes a lot of benchmarks. For the regular dev/company in production use have no idea why people would use it. Hyper seems the sane option for most trying to simply build a backend. It's really good to see others building on it though. Won't deny how clunky it once was before async got stabilized.
- _-___________-_ 7y agoYou have to adjust the filters, because hyper isn't considered a "framework", but the TechEmpower benchmarks show hyper beating even actix (though it's narrow). Definitely agree things were pretty clunky for async Rust web stuff before async/await!
- DarthGhandi 7y agoThe sugar is real nice with async/await, plus some performance improvements. I got all excited upon release and moved my backend over to async, do somewhat regret not waiting 6 months. Docs are sparse, this is across all the various crates needed, a bunch of required interoperable parts all needing specific alpha versions or separate preview crates. Can't deny it's not user friendly right now. Very much early days. Regardless, a lot of effort was put into the design and have to respect core devs for that. Think it was the most discussed/debated feature ever.
- Dowwie 7y agoAsync-await is a game changer for all async rust development. Futures combinators became a sunk cost. Good riddance.
- codetrotter 7y agoYeah I agree with this. I am working on an API backend in Rust too, and I originally started out writing it using actix-web. After the concerns about the massive use of unsafe in actix-web in the past I grew a bit concerned and already made me think about going away from using actix-web. When I started looking at upgrading to actix-web 2.0 there was a lot of rework needed to be done, but very lacking documentation. I also reached out and got some help from the maintainer of actix-web a few times prior to that but he was always really really brief and for me personally it was difficult to make sense of. Of course I understand that he can’t spend his time helping everyone as that would take up all his time. But from purely a developer point of view, the docs were too lacking for me, and everything felt quite convoluted to try and make sense of. I was left feeling frustrated because actix-web was so hyped and seemingly popular but for me it was difficult to work with. I switched to hyper and so far am happy with my decision. I am not going to touch actix-web again anytime soon, but that is only my personal opinion and feeling.
- ay 7y agoI ended up building my own l framework for my use case (about 30KLOC NMS, all Rust) - http://github.com/ayourtch/rsp10 http://github.com/ayourtch/rsp10 - would be interesting to hear your critique if you have a minute to look at it!
- s_c_r 7y agoThat's good to know! I got burned pretty bad trying to switch away from actix-web to one of the other frameworks (rocket, gotham, warp) after the whole kerfuffle and lost my taste for Rust as a backend web language as a result. Seeing your experience makes me want to try again with only hyper! I've always heard it was too "low level" and never gave it a proper look as a result.
- mamcx 7y ago> I wouldn't call Actix the most mature Surely? I try several other for replace my .NET core project, and Actix is the only one that barely get there. Which other handle without much fuzz: - Auth (big!) - Routing with state and db pooling - Forms - Templates - Encode/Decode all stuff (query string, headers, etc) - Allow to inject middle-wares - Have (at least) the bare minimum of functionality like gzip encoding - And many other small details I forget now I have worked, alot, with django, then use .net core and now Actix, and the others rust frameworks are lacking badly as far I see. What I see the rust ecosystem is lacking now is mostly around templating (need more love for dynamic options!) and some stabilization around rdbms usage..
- _-___________-_ 7y agoActix has a lot of features, but to me that's not the same as maturity. I don't want one "batteries-included" framework, I want components (preferably mature and relatively boring) with well-defined interfaces that I can use together to build my backend.
- mamcx 7y agoThats is fine, but is surprising how many stuff you need to make a semi-complex site. Is better for a ecosystem to have the "batteries-included" framework that cover the needs of many and then specialize. Django, ROR pull a lot of people into.
- dragonsh 7y agoAt present Rust's primary focus is systems programming language, it will take another 3-5 years to be a viable web programming that too in a niche area. I doubt the libraries will be mature enough to provide easy way to build the way other languages do. If you know Ruby or Python or C# or Swift or Go language or Dart or TypeScript or JavaScript don't change to Rust yet. It's far far away from having similar library, documentation and developer eco-system. I believe Haskell has more mature web development eco-system than Rust at present, but they also suffer from same issue most libraries do not have enough documentation and it's tiring to go through the library code to understand how to use it. But if you want to do Rust, why not try Haskell, you will learn much more and it offers a new way of functional programming. Indeed Rust, Swift, C++, Java, Python, Ruby, JavaScript etc. all borrowed ideas from Haskell or OCaml. Indeed Rust was initially written in OCaml Actix which is the most popular framework in Rust just had a core developer who left it and was dead for a while before community tried to revive it. [1] [2] [1] https://words.steveklabnik.com/a-sad-day-for-rust https://words.steveklabnik.com/a-sad-day-for-rust [2] https://github.com/actix/actix-web/issues/1289 https://github.com/actix/actix-web/issues/1289
- EugeneOZ 7y agoOops, I'm writing web backends in Rust 5 years already and didn't know it's not "viable" yet.
- dragonsh 7y agoYes probably viable for you as an individual, this does not collate into viable for most. It’s still a niche inside a niche. People are writing web backend in Haskell for decades, it is a viable choice for very specific niche of web development. Rust has miles to go before it can reach even that stage. At present elixir has much bigger eco-system than Rust.
- Qwuke 7y agoI don't think the 'Rust is not as far along as backend web Haskell' is true in my (minimal) experience. I've worked at one very small company and one very large company, and at both Rust was a much more serious/common consideration for web services than Haskell.
- zelly 7y agoI think if you want to do web dev backend with Rust (or C++ or any bare metal lang), you should do it behind a RPC framework (Thrift, gRPC) if only for security purposes. But it's also way more convenient. There's no need to have your core business logic also become entangled with a web server unless the networking minutiae is relevant. There are too many things that could go wrong on a public-facing endpoint to trust the runtime of something you are essentially rolling on your own if you use Rust, C++, C, etc.
- qaq 7y agoIt's definitely workable but async/await landed relatively recently most key libs have been updated but things can be rough on documentation side of things.
- Qwuke 7y agoI've used Rocket and Actix for production web services. I love Rocket's conciseness; however, it still has a nightly dependency, and is still in the process of updating to async. If you can live without those two things, I'd highly recommend rocket. Actix is one of the most mature but (in my opinion) complicated for someone to stand up when just standing up a simple web service. It's extremely performant though. I'd look into tower and warp too if I were you - they seem to be almost as concise as Rocket, but have no nightly dependencies and already have async support.
- skohan 7y agoFWIF I have played a bit with Actix for a few small projects, and it wasn't for me. It's a very "battery's included" library which does a lot of things for you, like transforming data structures into responses automagically. It feels a bit like rails where you just have to know the magic words sometimes to make things happen, and it's not exactly clear how things work.
- Qwuke 7y agoI think that's a great description! Every 'batteries included' Rust web framework I've used so far makes the same boilerplate/magic trade off as Rails, though some magic has felt more intuitive than others. Hyper doesn't remove much boilerplate but it's one of the most intuitive options that I've seen.
- pjmlp 7y agoStill quite immature versus what you can get in Java, .NET, Go and Erlang. Actix is probably the closest to it, but then there are the message bus, database bindings, monitoring, orchestration, ... to look for.
- tlamponi 7y agoWe do a new project in rust. It has a REST API building upon tokio and hyper, effectively the whole backend is in rust. Building upon hyper isn't to bad, but not the "plug and play" way, I'd guess. For us it's OK, as we have a lot of control over the design and the stuff on top isn't to much. Things are fast, code is OK once you wrangled about it with the compiler, async support is already OK (but definitively needs to improve, especially in the compiler for diagnostics and errors).
- dakom 7y agoI'm looking at warp[0] and like the concept behind it very much... a bit higher level than hyper, but using a concept of composable filters without being too opinionated. Haven't done much kicking of the tires yet though [0] https://github.com/seanmonstar/warp https://github.com/seanmonstar/warp