Actually I don't understand why the `async` keyword is needed at all.
Actually I don't understand why the `async` keyword is needed at all.
At the top of the chain, this ultimately blocks the entire event loop (Javascript semantics are generally not concurrent), so no UI/network events can be processed until that promise resolves and the page/server is left non-responsive.
(And that's assuming you can somehow define clear semantics to run any Javascript code involved in resolving the promise; otherwise, you're deadlocked!)
Await actually pauses your function and allows the async runtime to work on other stuff, such as completing the function you just awaited on.
Synchronous I/O functions don't rerurn until the I/O is complete (or complete enough, anyway). The calling function effectively waits for completion.
Asynchronous I/O functions return right away, but completion is signaled elsewhere. The calling function does not have to wait (but it can choose to wait for completion if necessary). Asynchronous messaging may not even provide a completion signal, if you want to know it got there, the other side needs to send an asynchronous message back to confirm.
Await/async is confusing enough without redefining terms to mean their opposites.
Indeed:
$ raku -e'sub non-async { await start { say "hello world" } }; non-async'
hello worldNo, I'm not bitter.