5 reasons why you will want to pick Node.js

4 reasons why nodejs

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.

Node.js is asynchronous

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.

ES6 promise example

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:

async/await code example

Tada! We’ve reduced this code to 8 lines, and we’ve avoided that crazy nesting pattern.

What is the difference between synchronous and asynchronous programming?

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.

Node.js can be strongly typed with TypeScript

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.

  • Reduce silly errors on compilation time
  • Allow for better performance optimization
  • Let your IDE help you catch hints and errors
  • Create interfaces to define schemas

Node.js is easy to setup and debug

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.

With the popularity of VS Code, and the VS Code team supporting TypeScript and JavaScript; they’ve made it easy to debug JavaScript and Node.js on their IDE.

The Node.js community is huge

When you think of community for Node.js you must also include the JavaScript community.

GitHub chart of the JavaScript being the top language.

If you analyze the image above, JavaScript/Node.js has been the top language for the last 4+ years on GitHub.

With TypeScript (which is essentially JavaScript) coming at number 7 really quickly.

So you can bet that you can find an answer to some of your most obscure Node.js/JavaScript questions on Google or Stackoverflow.

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.

Build universal/isomorphic applications

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.

Article link:https://linguinecode.com/post/3-reasons-javascript-server-side


Most new development is being done in Node.js for good reasons:

  • Great performance
  • Supports strongly typed
  • Strong community support
  • Universal application/site builds

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

I like to tweet about Node.js and post helpful code snippets. Follow me there if you would like some too!