Rust's async story is still an embarrassment for web APIs
I came to Rust expecting the memory safety and performance everyone raves about, and for a while it delivered. Then I tried writing async Rust, and all that confidence in my code evaporated.. All of a sudden, I had to fight Pin , decipher Waker , and choose among three runtimes, before I had even processed a single request. ๐ฎ๐จ The language is great. The async story is not. I want to emphasizeโฆ
Rust's async story is still a significant drawback for web APIs, according to a Rust developer's recent account. Initially impressed by Rust's memory safety and performance, the writer soon encountered challenges with Rust's asynchronous programming model. Implementing a Future in Rust demands a deep understanding of Pin, Waker, and selecting among multiple runtimes, which can feel like wrestling with unsafe code or relying on macro-heavy crates.
These complexities deter even experienced developers, as evidenced by withoutboats, a Rust contributor, who advocated for making pinning a first-class language feature due to the current "ergonomic challenge" and "annoying footgun." Moreover, the runtime split among popular runtimes like tokio, async-std, and smol adds another layer of confusion.
Maciej Hirsz, the creator of logos and beef crates, highlighted that making Rust multi-threaded by default is a major flaw, as it forces developers into Send + Sync + 'static constraints, which can cause trait bound errors at inconvenient times. The situation is further exacerbated by the fact that over 20,000 crates are tightly coupled to Tokio, leaving developers with little choice when building web frameworks, HTTP clients, and database drivers.
This hard coupling has led to prolonged migration schedules and recruitment delays. Industry surveys reveal a troubling trend: 22% of non-users find Rust too difficult to learn, while 36% of organizations have no plans to hire Rust developers. These organizations cite the steep learning curve for web and CRUD applications as the main reason.
The Rust team acknowledges the issue but admits that the async functionality still lags behind sync Rust. They are actively working on addressing the problem by aiming to bring the Async Rust experience closer to parity with sync Rust, including a complete story for async fn in traits and the eventual retirement of #[async_trait].
Despite these efforts, the gap between Rust's safety and its enjoyable async experience remains wide, casting doubt on whether Rust is the right choice for web API development.
Written by urgent.news from Dev.to's reporting โ not their text. Machine-written โ may contain errors; check the original before relying on it.