4 ms·
I always thought this, but people don't seem to find the convenience of async as a strong selling point over threads. There isn't a fundamental reason, but doin
by kevincox 5y ago
I always thought this, but people don't seem to find the convenience of async as a strong selling point over threads. There isn't a fundamental reason, but doing something like:
thing1_promise = get_thing(1)
thing2_promise = get_thing(2)
thing1 = thing1_promise.await
thing2 = thing1_promise.await
is almost always more difficult to do with threads. Sure, some threading APIs support joining nicely but it tends to be more awkward. Especially if you want to do something like handle the first request to finish first.
Also the startup cost of threads affects how you write code. Does your library spawn a new thread for every HTTP request? Probably not, it is expensive and the server may be on the same host. So you end up with less consistent async support. Since async programming is a lot cheaper you tend to see better support which adds up.