〉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?
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.
I like axum because it’s maintained by some prominent Tokio folks and fits my sensibilities. There’s lots of good choices out there.
You’ll notice the sibling comment did the same thing but with a different web framework they prefer. That’s great too. But other than the choice, it’s entirely agnostic. Another sibling even posted a step by step tutorial, if that level of specificity is helpful.
When people say "we need a rich standard lib" they are more interested in a "blessed set of crates" than a "it should be pre-downloaded with the compiler".
While two different ones were mentioned in this thread even, a new user would be easily served by either.
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 ?
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.