Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Writing asynchronous code is trying to fix how your code is executed in the code itself. It is the wrong solution for a real problem.

But I think what many people get wrong (not the person I'm replying to) is that how you write code and how you execute code does not have to be the same.

This is essentially why google made their N:M threading patches: https://lore.kernel.org/lkml/20200722234538.166697-1-posk@po...

This is why Golang uses goroutines. This is why Javascript made async/await. This is why project loom exists. This is why erlang uses erlang processes.

All of these initiatives make it possible to write synchronous code and execute it as if it was written asynchronously.

And I think all of this also makes it clear that how you write code and how code is executed is not the same, so yes, I'm in agreement with the person I'm replying to, I don't think this will change how code is written that much, because this can't make writing code asynchronously any less of a bad idea than it is now.



> This is why Golang uses goroutines. This is why Javascript made async/await. This is why project loom exists. This is why erlang uses erlang processes.

JavaScript async/await is different from the others. It requires two colors of functions [1], and it conflates how the code is written with how it's executed, so it has the same problem you were talking about at the start of your comment.

Also, JavaScript async/await is suboptimal in that it's ultimately built on top of unstructured callbacks. Or, as Nathaniel J. Smith put it in a post about Python's asyncio module, which has the same problem, "Your async/await functions are dumplings of local structure floating on top of callback soup, and this has far-reaching implications for the simplicity and correctness of your code." [2] That whole post is well worth a read IMO.

[1]: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...

[2]: https://vorpus.org/blog/some-thoughts-on-asynchronous-api-de...


> JavaScript async/await is different from the others.

It allows me to write synchronous code and execute it asynchronously. The mechanism is different - but the purpose is the same. I'm not endorsing the implementation. But I do use it, because it is way better than writing asynchronous code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: