Can you say why Node.js is better than Java? Node.js is superior when it comes to concurrency. I’d concur if I knew what that meant. Node.js wins when it comes down to handling
thousands or hundreds of thousands of connections. Node.js handles more concurrent inputs and
outputs than Java. Doesn’t Java handle it? Sure, but not as many. And a website loses
a customer when they get connection errors. In a mobile world, people might hit the refresh
button once or move on to the next site on their list who offers what they want. Node.js is the only server based solution
with non-blocking asynchronous connections. Nobody gets the error that they can’t get
a connection unless there is a denial of service attack. I won’t deny that. But how does Node.js manage
to do it? Because Node.js doesn’t create a single thread
for every connection, it more readily handles people who drop off or close connections while
using fewer resources doing so. End result, fewer resources needed to handle
the same volume of people. Either they get faster connection times and
you get more sales, or you need fewer servers to handle the load. Both of which look really good to big companies.
Why is Java slower? Java gives each thread a stack, and each stack
uses memory. Asynchronous connections prevent the threads from tying the server in knots. This is interesting because I’d heard that
Java was faster. Java can use non-blocking calls and multi-threading.
That programmers don’t use it is a whole other discussion. I’m surprised Node.js does better since it
runs everything on a single core. It was designed to handle lots of calls simultaneously
because it uses only a single core. Node.js is like the trained octopus in customer service
who can handle eight calls at once, while everyone else processes each one at a time
in a hurry. I’ve never seen an octopus in customer service. OK, bad example. But Paypal switched to Node.js,
so that’s a good example of why you should use it, too.