

Async-await status report
source link: https://www.tuicool.com/articles/hit/UzUNBrf
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

I wanted to post a quick update on the status of the async-await effort. The short version is that we’re in the home stretch for some kind of stabilization, but there remain some significant questions to overcome.
Announcing the implementation working group
As part of this push, I’m happy to announce we’ve formed a async-await implementation working group . This working group is part of the whole async-await effort, but focused on the implementation, and is part of the compiler team. If you’d like to help get async-await over the finish line, we’ve got a list of issues where we’d definitely like help (read on).
If you are interested in taking part, we have an “office hours” scheduled for Tuesday (see the compiler team calendar ) – if you can show up then on Zulip , it’d be ideal! (But if not, just pop in any time.)
Who are we stabilizing for?
I mentioned that there remain significant questions to overcome before stabilization. I think the most root question of all is this one: Who is the audience for this stabilization?
The reason that question is so important is because it determines how
to weigh some of the issues that currently exist. If the point of the
stabilization is to start promoting async-await as something for widespread use
, then there are issues that we probably ought to
resolve first
– most notably, the await
syntax, but also other
things.
If, however, the point of stabilization is to let ‘early adopters’ start playing with it more, then we might be more tolerant of problems , so long as there are no backwards compatibility concerns.
My take is that either of these is a perfectly fine answer. But if the answer is that we are trying to unblock early adopters, then we want to be clear in our messaging , so that people don’t get turned off when they encounter some of the bugs below.
OK, with that in place, let’s look in a bit more detail.
Implementation issues
One of the first things that we did in setting up the implementation working group is to do a complete triage of all existing async-await issues . From this, we found that there was one very firm blocker, #54716 . This issue has to do the timing of drops in an async fn, specifically the drop order for parameters that are not used in the fn body. We want to be sure this behaves analogously with regular functions. This is a blocker to stabilization because it would change the semantics of stable code for us to fix it later.
We also uncovered a number of major ergonomic problems
. In a
follow-up meeting ( available on YouTube
), cramertj and I
also drew up plans for fixing these bugs
, though these plans have
not yet been writting into mentoring instructions. These issues
include all focus around async fns that take borrowed references as
arguments – for example, the async fn syntax today doesn’t support
more than one lifetime in the
arguments
, so
something like async fn foo(x: &u32, y: &u32)
doesn’t work.
Whether these ergonomic problems are blockers , however, depends a bit on your perspective: as @cramertj says, a number of folks at Google are using async-await today productively despite these limitations, but you must know the appropriate workarounds and so forth. This is where the question of our audience comes into play. My take is that these issues are blockers for “async fn” being ready for “general use”, but probably not for “early adopters”.
Another big concern for me personally is the maintenance story . Thanks to the hard work of Zoxc and cramertj, we’ve been able to standup a functional async-await implementation very fast, which is awesome. But we don’t really have a large pool of active contributors working on the async-await implementation who can help to fix issues as we find them, and this seems bad.
The syntax question
Finally, we come to the question of the await
syntax. At the All
Hands, we had a number of conversations on this topic, and it became
clear that we do not presently have consensus for any one syntax
.
We did a lot
of exploration here, however, and enumerated a number
of subtle arguments in favor of each option. At this moment,
@withoutboats is busily trying to write-up that exploration into a
document.
Before saying anything else, it’s worth pointing out that we don’t
actually have
to resolve the await
syntax in order to stabilize
async-await. We could stabilize the await!(...)
macro syntax for the
time being, and return to the issue later. This would unblock “early
adopters”, but doesn’t seem like a satisfying answer if our target is
the “general public”. If we were to do this, we’d be drawing on the
precedent of try!
, where we first adopted a macro and later moved
that support to native syntax.
That said, we do eventually want to pick another syntax, so it’s worth thinking about how we are going to do that. As I wrote, the first step is to complete an overall summary that tries to describe the options on the table and some of the criteria that we can use to choose between them. Once that is available, we will need to settle on next steps.
Resolving hard questions
I am looking at the syntax question as a kind of opportunity – one of the things that we as a community frequently have to do is to find a way to resolve really hard questions without a clear answer . The tools that we have for doing this at the moment are really fairly crude: we use discussion threads and manual summary comments. Sometimes, this works well. Sometimes, amazingly well. But other times, it can be a real drain.
I would like to see us trying to resolve this sort of issue in other ways. I’ll be honest and say that I don’t entirely know what those are, but I know they are not open discussion threads . For example, I’ve found that the #rust2019 blog posts have been an incredibly effective way to have an open conversation about priorities without the usual ranchor and back-and-forth. I’ve been very inspired by systems like vTaiwan , which enable a lot of public input, but in a structured and collaborative form, rather than an “antagonistic” one. Similarly, I would like to see us perhaps consider running more experiments to test hypotheses about learnability or other factors (but this is something I would approach with great caution, as I think designing good experiments is very hard).
Anyway, this is really a topic for a post of its own. In this particular case, I hope that we find that enumerating in detail the arguments for each side leads us to a clear conclusion, perhaps some kind of “third way” that we haven’t seen yet. But, thinking ahead, it’d be nice to find ways to have these conversations that take us to that “third way” faster.
Closing notes
As someone who has not been closely following async-await thus far, I’m super excited by all I see. The feature has come a ridiculously long way, and the remaining blockers all seem like things we can overcome. async await is coming: I can’t wait to see what people build with it.
Recommend
-
126
在很长一段时间里面,FE们不得不依靠回调来处理异步代码。使用回调的结果是,代码变得很纠结,不便于理解与维护,值得庆幸的是Promise带来了.then(),让代码变得井然有序,便于管理。于是我们大量使用,代替了原来的回调方式。但是不存在一种方法可以让当前的执行流...
-
76
ASP.NET 谨用 async/await
-
75
C# 5.0 引入 async/await 关键字,旨在简化异步编程模型,抛去语法糖就是 Net4.0 的 Task + 状态机。其实在处理异步编程使用 Task 还是挺简单的,不过既然推出了新的语法糖,难免会尝试一下,然而在使用中却没想象中那么单纯。以下针对ASP.NET 应用程序实际使用过...
-
81
So I finally hopped on the boat with usa...
-
44
I’m really excited to announce the culmination of much of our work over the last four months: a pair of RFCs for supporting async & await notation in Rust. This will be very impactful for Rust in the network services...
-
70
Node.js express.js MongoDB JWT REST API - Basic Project Skeleton Getting started This is a basic API REST skeleton written on JavaScript using async/await. Great for building an MVP for your front-en...
-
56
看到彭总写的文章 这破 Python ,感慨颇多,我也来灌水吧。 首先,我司算是在国内比较敢于尝试新东西的公司吧,最直接的提现就在于我们会及时跟进社区相关基础服务的迭代...
-
50
什么是async? 现在面对日常工作时,总避免不了面对异步操作带来的一些麻烦。在时代演变的过程中,处理异步的方法有许多种:回调函数、Promise 链式语法、Generator 函数到现在比较流行的 async 函数。那什么是 async 呢? async
-
62
JavaScript is an event driven language . This means that JS will keep executing code while listening to other events. Ok, I know, this may not sound so clear, so take an example: ...
-
17
I wanted to give an update on the status of the “async-await foundations” working group. This post aims to cover three things: the “async await MVP” that we are currently targeting; how that fits in...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK