6 ms·
And yet it succeeds. I think it's simply that async IO is in javascript developers' blood - sure, everything you can do in node you've been able to do for five
by lmm 14y ago
And yet it succeeds. I think it's simply that async IO is in javascript developers' blood - sure, everything you can do in node you've been able to do for five years with twisted, but if you start trying to do something in twisted all that wonderful python ecosystem is suddenly useless to you, and no-one wants to talk about creating replacements because they've all moved on to tornado or gevent or incompatible-framework-du-jour.
Because javascript started in the single-threaded execution environment of the browser, the whole ecosystem has had to be nonblocking; browser APIs were callback-oriented so the whole ecosystem has been written in callback-oriented fashion, and all the libraries play well with each other. Single-threading is a hair shirt that results in better code in the long run, like laziness in haskell. And async I/O is so much more performant than blocking (in modern application stacks) that that's making node dominate there.
I do wonder whether other languages could have ended up the same way if threading hadn't been invented. Perl always had these unreliable bodged threads, and so there were some really interesting event-driven libraries for it - but the threads were good enough for many practical uses, and AFAIK the ecosystem never converged on a single approach. Did I hear of a PEP attempting to standardise a compatible API for doing these things in python?
- drakaal 14y agoIn web languages threading is often not the win that people think it will be. True web scale is serving 1000s of requests per minute if not second. Each of those users is a "thread" in Python, Java, Etc. So enabling multiple threads per users robs Peter to pay Paul. For this reason the Async model doesn't offer the huge performance gains in deployed code to enterprise scale, that it offers to single users trying to build fast one off projects.
- lmm 14y agoYou seem confused. The whole point of the async model is to allow one thread to serve many users, and it's precisely on large scale projects that this becomes useful.