How’s all that possible? Well, in Node.js virtually any long-running code is asynchronous. For example, loading a file, making an HTTP request or database query. All such operations are callback-based. When the result is ready, our code is notified. In the meantime, CPU is free to handle other requests. Modern CPUs are faster than I/O by several order of magnitude. So you can easily handle tens of thousands of concurrent requests in Node.js. On a single core! That’s way better than traditional Python, PHP or .NET web frameworks. They wait for pretty much any I/O, consuming precious memory.
To be honest, in Node.js you can’t even use more than one core. So it’s not a good choice for CPU-intensive applications. But most of the applications these days spent the majority of their time… waiting. Waiting for a database or other services. So this design choice seems to pay off.
I mentioned briefly about libraries.
There are millions of them!
Now we have
npm, node package manager.
It hosts packages along with their dependencies.
Node community is known for creating tiny libraries with a large number of dependencies.
This ecosystem is quite brittle and vulnerable.
But it also enabled thousands of developers to share their code.
That’s it, thanks for listening, bye!