Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Rust's async story is zero-cost in the sense that it is not possible to implement a better asynchronous state machine than the one the compiler will provide for you, but it is explicitly not zero-cost in the sense that there is no overhead to asynchronous execution in comparison to synchronous execution. See experiments like this for examples.
There is a proposal for top-level await in JS. I'm guessing this would effectively kinda do the same thing? Or am I wrong there?
Async in rust needs a runtime (aka executor) to run. You can maybe get a better description from the rust docs. As an example, Tokio attempts to provide an interface for a developer that is minimal change to the more common blocking code. So you'd end up putting #[tokio::main] above your main function to spin up the executor and most of the rest of the code is similar to a non-async version with a few sprinkles of .await, which you can see in the hello world for tokio. In contrast, async-std provides a more hands-on/low-level approach. If you are unlucky enough to have libraries that choose different stacks to work on, you'll possibly (probably?) have to handle both.