DEV Community

Discussion on: State of Rust Web Frameworks (Server, DB)

Collapse
 
ghost profile image
Ghost • Edited

I don't know about "best" but I can with absolute certainty say that the ecosystem is getting increasingly fun, I've done some things with Actix-web, is great, now I want to go lower, and I see 2 routes: Tokio -> Hyper -> Warp and async-std -> async-h1 -> tide. The first is more "mature", with quotes just because even tho Hyper has been used a lot, even by other frameworks Warp is very new; on the other hand the Tide path is even newer but making big strides.

A quick simple summary: in Rust, the async executer is not part of the std, because of technical reasons beyond this summary, not long ago the only player was Tokio, but then async-std came along, it has "std" in the name but is not more "official" than Tokio, is just the name. On top of the executers Tokio and async-std (they have other goodies not just the executer), there are libraries to do some basic stuff, like de/serializing http requests and responses, configuring the server, etc. in there we have Hyper and now async-h1 (which is maybe a month old and is not yet integrated in Tide). On top of that there comes the frameworks, that have some extra goodies, like routing and some middleware like loging, cookies, etc.

You can, without much trouble work directly with Hyper (and I assume the same will happen with async-h1), you would have to do your own routing with some regex and the middlewares you need or add other libraries. As I see it Actix-web and Rocket are like Django, Tide and Hyper are more like Flask, Hyper and async-h1 are the libraries not longer frameworks; of course the line is blurry and with Rust you always see more of the belly of the beast.

On the DB side Diesel is almost the de-facto ORM, is great, you have everything checked at compile time, so you are sure your queries are fine and datatypes are checked at compile time which is great, and you have also the non-ORM route with libraries like rust-postgres or tokio-postgres (same thing but async), and the new crate (how Rust calls its packages) SQLx, that lets you write plain SQL queries but checked both integrity and data types at compilet ime which is beyond awesome, it actually check with the real database every query at compile time if you want.

The ecosystem is very new in some places but is getting very good, so simple to understand, so low level yet so clear I'm far from expert but I could make a simple app with Hyper in a couple of hours, its worth at least to check the API docs to have an idea, the documentation is great and after years with Django now I understand a lot of things that where black magic to me.

I hope this is somehow helpful :)

Collapse
 
ben profile image
Ben Halpern

Very helpful!

Collapse
 
readredready profile image
Charles Gibson • Edited

Thanks for your contribution! I posted some questions you might be able to help me with.

dev.to/readredready/comment/ncm1

Collapse
 
ghost profile image
Ghost

I leave you a couple of posts of one of the top devs in the async-std side of the force:

Here explain why Tide, and what they are triying to achieve with it
blog.yoshuawuyts.com/tide/

Here he explain the changes they are making right now, Tide still uses some Hyper, but now they are getting rid of that dependency, and making more modular the whole thing.
blog.yoshuawuyts.com/async-http/