Choosing a Rust web framework
lpalmieri.com
lpalmieri.com
I don't mean to start drama -- I just feel like if the project is still prioritizing speed and experimentation over safety, that's worth including in comparisons like this, and if it's not anymore (or if I misunderstood the story in the first place), that would be good to know too.
Looking at the benchmark code, it doesn't appear to be doing too many shenanigans to hit those benchmarks: https://github.com/TechEmpower/FrameworkBenchmarks/tree/mast...
It eventually grew to be so long that it made little sense as part of Chapter 3 itself - I thus decided to publish it as its own article and link it in the introduction to Chapter 3 (hopefully to be released next week!).
Warp seems to have one of the better api experiences but has significant performance issues.
In the async world I think
https://github.com/stjepang/smol
is going to have a pretty big positive impact on the useability of the whole system so I wouldn't rush to go all in on either async-std or tokio just yet. Last I read it was still having some fairness issues that were next to fix though.
There is also
https://github.com/withoutboats/ringbahn
Which is very disruptive in that io-uring doesn't have a natural async interface?
It should be possible to create a an API that uses an intermediate, managed pool of buffers to pass to the kernel, but this would imply extra copies.
What about server rendered websites that aren't API? Which framework would you recommend in this case?
I'm on the 0.4 branch, which isn't the 0.5 async branch, so I'm blocking on db calls and such, but I'm targeting very low qps so I don't care.
I got the diesel database integration working with little fuss, and can guard requests
#[get("/me")]
fn get(user: &User) {
// Logged in view
}
#[get("/me")]
fn get() {
// Logged out view
}Is this actually true? I've heard mixed things about this, including that Rust itself has no particular position on the preferred concurrency model. Even the async book[1] says:
> It's important to remember that traditional threaded applications can be quite effective, and that Rust's small memory footprint and predictability mean that you can get far without ever using async. The increased complexity of the asynchronous programming model isn't always worth it, and it's important to consider whether your application would be better served by using a simpler threaded model.
[1] https://rust-lang.github.io/async-book/01_getting_started/02...
The community is overall very excited about async right now, and so the community may expect things to be async-first, even if the language itself does not have a preference.
This comes in handy when your frontend is a SPA (e.g. Vue, React) and it’s just updating state via API calls
[1] https://github.com/routerify/routerify [2] https://github.com/go-chi/chi
Diesel is more mature, but it is an ORM, albeit one with significantly less "magic", so maybe you'll like it more.
It's simple to use too, async and includes a pool.
SQLx is also a really good option, too, and has some ORM-like features (such as transforming SQL rows into a Rust struct via macros) while still allowing SQL to be a first-class citizen. SQLx is also async, so that would probably be the best one to look at first.
Rome wasn't built in a day.
last week, in research i discovered a few different implementations. no clear winner.