I believe in picking the right tool for the right job.
It just happens to be that Node.js seems to be the right job for 90% of the work out there.
Let’s cover why I believe Node.js is a great tool to build applications.
This means that it allows for a lot better scalability with concurrent connections.
It also allows for better real time connections to the client browser via WebSockets. Which it does not add a lot of overhead.
And with newer Node.js versions, you may use async and await functionality to make your asynchronous code as if it’s synchronous.
Async/await will help to keep your code more readable.
Here’s an example with ES6 Promises.
It’s not too bad. We can see that it’s going to try get some JSON data, then we have a couple callback functions.
Let’s do this in async/await:
Tada! We’ve reduced this code to 8 lines, and we’ve avoided that crazy nesting pattern.
Synchronous programming languages execute one thing at a time.
Asynchronous programming allows you to execute multiple things at a time. You don’t have to wait for one thing to finish if you don’t have to.
For example, let’s look at making a cake.
First you need to gather up your ingredients, than you need to preheat the oven.
Are you going to wait until you hear the buzzard sound before you go onto the next step? Probably not.
You’re going to than make the batter which has multiple synchronous steps.
You’re going to add the butter and sugar. Then mix the egg, and then the flour.
All these synchronous actions are being executed while the oven is still heating up!
You would then add the batter to the oven and let it cook. This may take a long time, perhaps an hour.
Are you going to wait until the batter mix is done cooking before going on to the next step? Probably not.
You’ll move on, and make the frosting.
This is why asynchronous programming is powerful, because you can do multiple things at once and still move at full speed.
By default, Node.js is not a strongly type language. But with the rise and support of TypeScript, that all change for Node.js.
Integrating TypeScript with Node.js gives you all the benefits that a strongly type language such as Java would.
Node.js allows support on all major operating systems (Mac, Windows, and Linux).
And it does not require you to use Nginx or Apache to run your app. Which I still highly recommend you do, to reduce the stress on your app.
But it’s not needed.
You can also believe that a lot of those GitHub projects are living on NPM, Node Package Manger.
Plenty of communities to help you get stuck out of a rut, and plenty of libraries to help you build an awesome Node.js application.
I recently wrote an article explaining the top 3 benefits of using Node.js to do server-side rendering applications.
So no need to re-iterate on this. Just go to the article link below to read up on it.
Most new development is being done in Node.js for good reasons:
For these reasons, teams that I’ve had the chance to work with such as Yahoo, HuffPost, TechCrunch, and Rosetta Stone are using Node.js as their primary server language.
It also helps to know that PayPal, AirBnB, Amazon, and Facebook are huge supporters of Node.js