Was Async Fn a Mistake?
seanmonstar.com
seanmonstar.com
1. My overall experience with async is very positive
2. There are tricky bits where even I, an experience borrow check wrestler, don't know what to do - I just refactor the code to avoid the issue in these cases. This is not a very common situation, it has only occurred in 'free time' code where I'm trying to really optimize my code.
3. I am overall very optimistic about the future of async in Rust, even if today it requires some onboarding time.
I'm excited for things to improve. There are ergonomics wins coming soon like async in traits, there are improved compiler diagnostics, expansions of what can be done (to address my 'zero copy' use cases), etc.
Perhaps it's bikeshedding but I hate the `= async` quite a lot.
I'm curious to see how things develop from here in the next 3-5 years, as I imagine we'll see some significant improvements to the existing system.
When I want concurrency/parallelism/distribution, just use the BEAM (iE: Elixir) which is literally made for that problem space. BEAM is not exactly good for computations, though (as are many other tech stacks)... so writing a native extension/library in Rust when there really is a demand is perfect - but any scheduling whatsoever stays in BEAM territory, including keeping an eye on the non-preemptive behavior of the Rust function and schedule calls to it properly.
So for me, I don't need async (or even multicore) rust anymore to begin with, but the base functionality of the language (especially including serde!) knocks it out of the park for some problems like nothing else.
This way beginners don't have to understand things like the event loop or difference between a function that returns a promise and one that doesn't while more advanced users can still manually handle promises
I think that "Ability to forgo naming an associated type name." seems very reasonable to me
> Is there any good reason why I can't use await in a non-async function that returns a Future?
You can do this afaik
What I really want is for my synchronous and asynchronous code to be a lot more transparent and not force my hand depending on whether I'm calling from a synchronous or asynchronous context. I know this is a really difficult ask because of the lack of knowledge of what runtime to use when calling an async task in the context of a synchronous call...
Its the coloring problem I ultimately hate fighting against. There are definitely times that I care about it, long running blocking synchronous calls and getting a handle on a Future are really the only ones I can think of and they tend to be the exception not the norm.