back

by jtwaleson·5y ago·view on hn ↗
If we designed a new async language today, would it include async/await keywords? I think they don't add anything conceptually and it's just a patch for languages that didn't design for async from the start. Am I missing something?
2 comments
Maybe not async as I think the await keyword is probably enough on its own. As for why it exists...

Await/explicit yielding enables cooperative multitasking where the programmer has exclusive control of some execution context, be it a thread or fiber or whatever, until they decide to yield.

Without that you only have implicit scheduling and execution could be yielded at unpredictable times. The programmer then needs to add other things like semaphores to specify the critical sections and you run the risk of deadlocks.

There might be a new language that comes along but right now await exists for a reason.

I think this is a compelling vision, but as a practitioner of functional core/imperative shell, I make use of the async/await keywords to understand where I/O is happening and to work towards moving it to the edges of my program.

I can do this without those keywords, but there's actually something quite nice about being certain that a given function does no I/O simply based on its function signature.