Remix.run Logo
ori_b 4 hours ago

Async and await is manually scheduling threads. So, if you're quite careful about what functions you call, you can arrange things so that you don't get concurrency when you don't want it.

Being careful about what functions you call is quite fragile and tedious, and doesn't compose well: what if a library changes when it adds a yield point?

Overall, async/await is a result of people programming like it's 2003, when threads were still very expensive.

josephg an hour ago | parent | next [-]

This works a lot better in JavaScript, which is exactly this model - a single threaded executor with async await. The problem you talk about is solved with function colouring. Async functions are marked as such. In general, sync functions can’t call async functions. (Well, you can invoke them. You just can’t run them to completion before returning).

For all the complaints about function colouring, I’m glad JavaScript has them. A sync function becoming an async function is a breaking API change. This is much better than the situation in Python, where yield points are invisible.

pocksuppet 44 minutes ago | parent [-]

Until every function is async.

vlovich123 2 hours ago | parent | prev [-]

Threads are still expensive in Python - can’t use them for concurrency really like you can with async io afaik.