5 ms·
> Who doesn't prefer to just build something in a language where you know first time setup is pretty straight forward Is first time setup of Rust projects a re
by steveklabnik 4y ago
> Who doesn't prefer to just build something in a language where you know first time setup is pretty straight forward
Is first time setup of Rust projects a regular issue for you? That's not my personal experience, but I am of course biased. 99% of projects are "git clone && cd && cargo build," done. 0.95% are "oh, also install some C library via the package manager," which is a one-time thing per library.
In practice, some folks have tried to get a "richer standard library" going, and they've never seen community adoption, and so end up abandoned. It's been quite a while since this sort of thing was proposed by the project, but back when it was, the community also pretty resoundingly rejected the idea.
- giancarlostoro 4y agoI dont mean established codebases. I mean if I ask you to build a web server in Rust how quickly do you have it up? What are those steps? I can have a Django or ASP .NET project up insanely quicker for example. Heck I can have a Go net/http project up quicker than all the above just cause of muscle memory since that package has not changed a whole lot in years, which adds to the value of Rust having an extension to their stdlib that is maintained by them.
- tialaramex 4y agoInteresting, I had never tried to "build a web server in Rust" so, I read these instructions https://actix.rs/docs/getting-started https://actix.rs/docs/getting-started and built one. It did take about a minute to figure it out, and then I also spent another minute fiddling with the examples because I wanted to say funnier stuff. Built, ran, checked on my local machine, very convinced, Rust makes a pretty good web server, would recommend. I feel like that wasn't your point ?
- deleted 4y ago[deleted]
- giancarlostoro 4y agoI guess the story for doing web in Rust is different today, its a little easier, but as someone new to the language, how do I know what Actix is, or who maintains it, having watched that scene a while there was a weird scandal with Actix a few years back, the lead developer just quit or something? But on that note how do I know which web framework is best for Rust for a beginner? If I'm coming from Django, what framework gets me the same experience? I've gone through Actix docs before, and their docs were completely out of date form what cargo installed for me, it was confusing and off-putting, I didn't bother with Rust web dev for years after that.
- steveklabnik 4y agoOkay let's try it: 〉time The current time is: 12:38:36.95 〉cargo new foo 〉cd foo 〉cargo add axum 〉code . (and then copy-paste the axum docs hello world from docs.rs/axum into src/main.rs) 〉cargo build 〉time The current time is: 12:43:37.44 Most of that is waiting on my crates.io index to update (which isn’t something that happens every time you start a project), and that, hilariously, the axum hello world also requires that you do a `cargo add tokio --features macros rt-multi-thread`, which they do not document, and I had to figure out myself. Most packages don't have that issue, and I'm filing a bug right now. > I can have a Go net/http project up quicker than all the above just cause of muscle memory I suspect that this has a larger impact on your experience than you're giving it credit for. You shouldn't discount familiarity, it's a huge bonus! And a good reason for you to do this stuff in Go and not Rust. But it doesn't mean it's universal. Am I going to argue that Rails is not wildly productive? Absolutely not. But at least, for me, the package existing in the stdlib isn't the different factor here. Rails and Django both aren't in the Ruby and Python standard libraries either, you know?
- giancarlostoro 4y agoNever used axum, what does it bring out of the box? Interesting, maybe I've been out of tune from Rust for too long, I don't get paid to work with it so it is easy to fall behind! I'm really into things like Django and ASP .NET these days, and last I looked (months ago?) Rust doesn't offer anything fully batteries included yet (relative to those two frameworks), heck even Phoenix is really good in this regard.
- steveklabnik 4y agoThere’s nothing as out of the box full of batteries as Django. Rust, like Go, tends to use a more “libraries” approach than a “framework” approach. I like axum because it’s maintained by some prominent Tokio folks and fits my sensibilities. There’s lots of good choices out there.
- giancarlostoro 4y agoOn that note, how does a beginner do what you just did in under a minute? Versus, someone going through the walkthrough for Go and seeing you can make a website using net/http, because it is built-in and doing it? This is the nuance I'm talking about, built-in or at least core-maintainer supported libraries are usually easier to adopt because you know there is a lot of investment into them.
- insanitybit 4y agocargo new example-server cd ./example-server cargo add actix-web (quickly searches crates.io for `actix-web`) Cool, copy and paste: use actix_web::{get, web, App, HttpServer, Responder}; #[get("/hello/{name}")] async fn greet(name: web::Path<String>) -> impl Responder { format!("Hello {name}!") } #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new().service(greet) }) .bind(("127.0.0.1", 8080))? .run() .await } takes ~a minute. Not sure std would have saved me any time, I would have just searched the stdlib docs instead of crates.io for actix. And I guess I wouldn't need to `cargo add actix-web` lol that was not the bottleneck.
- giancarlostoro 4y agoHow does a Rust beginner know what actix-web even is though? In Go the net/http library is discussed early on when learning Go.
- stouset 4y agoHaving come from Ruby (where you were also a visible member of the community) I really do prefer Rust's model where the standard library is kept a bit thinner and additional functionality that would have been part of the Ruby (or Golang) standard library is kept separate. The benefits are I'm sure not new to you. Updates and releases can be completely independent of Rust itself, and by not being in the standard library maintainers are able to deprecate and remove misfeatures when needed as opposed to having to support something that holds back a library for forever. The one downside though is that there is the unfortunate reality that—by leaving important parts of the ecosystem to random crate authors—important and heavily-used crates which would be part of other langs' stdlib can become unmaintained over time. This hasn't been too large a problem so far, but I do wonder if more could be done to promote community adoption of crates that are perceived to be more core to the ecosystem. The nursery is probably a good approximation to what I'm looking for, but without necessarily coming along with the implication that it should ever end up in `std`.
- steveklabnik 4y agoAs someone who was merging PRs into a Ruby gem for the first time in years this past week... this also happens in Ruby, ha! I've been that failed random maintainer over there too. And I suspect standard libraries get far less 'maintenance' than many people think they do, especially compared to a popular external library.
- stouset 4y agoYou're not wrong, but the signaling around `rust-lang-community/http-server-async` having one patch release in two years vs `r0ckst4ar-life/tokio-hat-tip` doing the same—even if both repos host the exact same code—is (in my eyes at least) completely different. Both could publish the exact same HTTP server crate but with one of those two, I can a) have some confidence that it's a probably a reasonable default choice, and b) assume that it's much more likely to be stable and mature than simply abandoned.