(no title)
squiguy7 | 4 years ago
Does anyone else think the Rust HTTP ecosystem is becoming increasingly fragmented? I can't keep track of which library is best suited for common operations. Is it a web framework built on hyper? Should I pay attention to tower middleware? Where does tracing fit in?
nicoburns|4 years ago
- There was a split between tokio and async-std asynchronous executors, but the ecosystem now seems to be coalescing back around tokio.
- There was weird split where Hyper was the de facto http library, but the best web framework was actix-web which wasn't based on hyper. But now there is Axum, an official Tokio project that is good enough to generally recommended for all web projects, and looks to be the project with momentum going forwards.
- Tracing is really the only game in town when it comes to asynchronous logging, and again is part of the Tokio project.
Tower is a bit of a weird one. It's a very general middleware layer which I think does actually provide a very good abstraction. But that abstraction is quite complex, and learning it is in many cases trickier than doing an implementation from scratch. I suspect it might come to play a bigger part in the Rust ecosystem at some point, but for now I'd ignore it.
d4mi3n|4 years ago
I don't write Rust professionally, but it was a bummer seeing that this seems to be a place that was figured out (painfully) in ecosystems used heavily for web development--Javascript and Elixir have their own Rack equivalents[2][3]. I hope that Tower plays a similar role to unify the library ecosystem in Rust.
1. https://github.com/rack/rack
2. http://expressjs.com/en/guide/writing-middleware.html
3. https://github.com/elixir-plug/plug
ibraheemdev|4 years ago
actix-web, like hyper, is built on tokio, so I'm not sure why you see this as a weird split. The underlying HTTP server is not something you generally interact with. actix-web even _uses_ hyper (the h2 crate) for HTTP2.
the__alchemist|4 years ago
And its begging the question "Is this what I want, or should ditch these, and build a new one using threads". I am not sold on the async paradigm. Some of the Rust OSS community uses it on embedded too, but to me, code using interrupt handlers (or RTIC) is more intuitive.
Immediately on viewing the Hyper guide and hello world, the program structure is messier than a normal Rust program. Colors propagate through the program. I am giving this a shot, but am not optimistic this will be cleaner than threading.
dralley|4 years ago
The point of async is that at scale threads start becoming expensive. If you don't have high performance requirements under heavy load, async is largely unnecessary.