4 ms·
I've never actually understood why the async thing is so hated. Spend some time in node, and you'll get used to it. A couple weeks ago I was writing a php scri
by redidas 14y ago
I've never actually understood why the async thing is so hated. Spend some time in node, and you'll get used to it.
A couple weeks ago I was writing a php script, and it actually felt awkward to query a database and then do something "immediately" after with the result.
It isn't terrible, it's just different. And if you aren't used to it, it'll feel weird at first. This goes away with exposure and experience.
- andrewvc 14y agoMy issue is definitely not familiarity. I've written more async code in more languages than most (node, java, ruby, clojure). My main takeaway is, unless I absolutely have to use async code I won't. It's almost never cleaner than queuing onto a thread-pool. In the case of highly parallel IO, yes, a thousand times yes async is great. But the great lie about node is that people need to carry over the async from the IO layer to the app logic layer. In node it's all just mashed together. For instance, the problem a websocket server is trying to solve is multiplexing M connections onto N available cores. Async works great for the connections layer, and a thread-pool well for the logic layer. The trick about async is that your server can handle 10,000 connections that are idle, but only a handful active at a given time since you only have a few cores. Thread scheduling works just fine. None of these ideas are novel, in fact, they are decades old. The real problem is the faddishness of ideas.