Think Twice Before Using Async Rust | Prime Reacts

ThePrimeTime
1 Oct 202328:29

Summary

TLDRThe video script delves into the current state of async Rust, highlighting the challenges and complexities of the ecosystem. It discusses the dominance of the Tokyo runtime and the difficulties of creating runtime-agnostic async code. The script also touches on the issues with async standard and the community's mixed feelings towards it. The author expresses concerns about the future of async Rust, suggesting that while it offers performance benefits, it also introduces unnecessary complexity and potential for blocking. The script concludes with advice for newcomers to approach async Rust with caution, learn from the synchronous model first, and consider alternatives like threads and channels.

Takeaways

  • 😀 The Rust async ecosystem has a rich history, with Aaron Turon's work on Tokyo being foundational.
  • 🤔 There's a current ambivalence in the Rust community regarding the state of async Rust, with a need for newcomers and maintainers to understand the ecosystem.
  • 🔒 The 'one true runtime' issue in async Rust leads to challenges in writing runtime-agnostic code, often requiring conditional compilation and handling edge cases.
  • 📚 Documentation and examples for async Rust can be outdated or incomplete, which can be problematic for both new and experienced users.
  • 🚧 The async standard library attempt faced challenges and has seen a decline in active development, leaving some projects in limbo.
  • 🌟 Tokyo's role as the canonical async runtime in Rust is significant, but it makes assumptions about async code design and execution environment.
  • 🧩 The Rust async ecosystem is fragmented, with multiple runtimes offering different features and philosophies, leading to a complex landscape for developers.
  • 🤖 Async Rust can be more complex and less ergonomic than using threads, but it offers potential performance benefits in certain scenarios.
  • 🛠️ For new Rustaceans, the advice is to master synchronous Rust first before venturing into async, to ensure a solid foundation.
  • 🔄 There's a call for the Rust community to continue experimenting with async designs to find the best solutions for the language's async future.

Q & A

  • Who is Aaron Turon and what is his contribution to the Rust community?

    -Aaron Turon is a significant figure in the Rust community, known for his work on the Tokyo runtime, which forms the foundation of Rust's async ecosystem. He authored a series of blog posts titled 'Zero Cost Futures in Rust,' which are considered cornerstones in Rust literature.

  • What are the challenges faced by newcomers to async Rust?

    -Newcomers to async Rust face challenges such as navigating a fragmented ecosystem with multiple runtimes, dealing with potentially outdated or incomplete documentation, and making future-proof decisions in a landscape with no clear single standard.

  • Why is writing async code in a runtime-agnostic fashion difficult in Rust?

    -Writing async code in a runtime-agnostic fashion in Rust is difficult because it requires conditional compilation, compatibility layers, and handling edge cases. This is due to the fact that all async libraries still need to be written against individual runtimes.

  • What is the 'async standard' and why was it considered an alternative to the Tokyo runtime?

    -Async standard was an attempt to create an alternative runtime that is closer to the Rust standard library, with the promise of being almost a drop-in replacement. It aimed to provide a more standard library-like experience for async programming in Rust.

  • What are the issues with the async standard runtime?

    -The async standard runtime faced issues such as being hard to fully replicate the standard library's functionality, leading to subtle incompatibilities. It also faced community resistance to its approach of abstracting away blocking operations, and it has since been essentially abandoned with no active development.

  • What is the role of the Tokyo runtime in the Rust ecosystem?

    -Tokyo is the canonical async runtime in Rust, offering more than just a runtime with additional modules for file I/O, networking, process handling, and more. It has had a pioneering role in async Rust and has become deeply integrated into the ecosystem.

  • What are the concerns with Tokyo's design assumptions for async code?

    -Tokyo makes many assumptions about how async code should be written and where it runs, such as defaulting to a multi-threaded runtime which mandates certain types and synchronization primitives. This can lead to accidental complexity and goes against Rust's emphasis on explicitness and ownership.

  • Why might using threads be a simpler alternative to async Rust in some cases?

    -Using threads can be simpler than async Rust when dealing with CPU-bound workloads or when the complexity and ergonomics of async code are not justified by the performance gains. Threads offer familiarity and can leverage the operating system's scheduler without the need for async runtimes.

  • What advice is given to Rust developers regarding the use of async features?

    -The advice given is to use async Rust only when necessary, learn synchronous Rust first, and if using async, stick to well-established libraries and avoid async-only public APIs. It's also recommended to explore alternatives to Tokyo and consider isolating async code for better composability.

  • What is the significance of the statement 'Fearless concurrency is your friend' in the context of Rust?

    -The statement 'Fearless concurrency is your friend' emphasizes Rust's ability to handle concurrent programming safely without data races, null dereferences, or dangling references, thanks to its ownership and type system, and the absence of a garbage collector.

Outlines

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Mindmap

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Keywords

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Highlights

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Transcripts

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now
Rate This

5.0 / 5 (0 votes)

Related Tags
Async RustRust EcosystemTokyo RuntimeAaron TuronConcurrencyProgrammingPerformanceRust CommunitySoftware DevelopmentAsync Standard