Last Updated on
Node is often compared with other backend languages such as PHP and Python, but is it actually a language? Today I am going to answer that question once and for all.
I often see people making a comparison of Node with other languages which then leads to silly fights between people that “you can’t make a comparison because it’s not a language” and all that. But when people do such comparisons, what they really mean is Node as the complete thing, and not just a language or the tool. So let me tell you a bit more about this runtime environment.
Table of Contents
- 1 What is the Node runtime environment?
- 4 What is the difference between browser JS and Node JS?
- 5 What Node JS is used for?
- 6 Advantage of learning Node
- 7 Final Thoughts
What is the Node runtime environment?
To give you a clear example, let’s say I tell Node to write the user information in the database. Node will then send the request to the database. While the data is being written to the database, Node will not wait for it, instead, it will move on to the next task on the list. When the database gets back to Node, it will resume and do the appropriate action. This single attribute makes it possible to make faster and more efficient server applications.
What is the difference between browser JS and Node JS?
Since Node is capable of reading and writing files, there is a global method require which can read and include files from the directory. There is another module called fs (file system) for doing all the input and output operations.
All the browser-related APIs like the fetch, localStorage, Notification is not available in Node because it’s not a browser.
Node made few custom methods but kept the same name as the browser for consistency; like the console.log, setInterval, and setTimeout could be named anything but wasn’t.
On top of that, Node has a list of built-in modules that can help the user build a server and do all the CPU and server related tasks.
What Node JS is used for?
As you already know, Node is used for building server-side applications and this was the original plan. However, as time went on, developers found many new ways to use Node. Here are some of the prominent use cases:
Node as a Full Stack Application
The best use of Node JS and the reason why I got into this was to be able to build full-stack web applications. Node is good for building all types of web applications. I made social networks with it such as the Twitter and Reddit clone. Other people have made SaaS applications, chat applications, and many different sites.
With Node, you can create the backend using a framework such as Express JS and build out the frontend with a view engine such as pug. Node renders HTML pages by dynamically generating them from the backend. It’s not just only limited to creating web applications, but you can also create just the backend of a server for any type of application.
Node as the backend API
Another popular use of Node JS is making the backend of any other type of application. You can make an android or iOS app to have it as the frontend and then make the API server using Node.js. Node is good for making REST APIs that can be used on any type of front end. You can even make a desktop application with Java or C++ and have Node to handle the server endpoints.
Currently, I like to make the backend with Node and use React.js as my frontend client application. With that being said, did you know that the biggest use of Node JS is currently in the frontend?
Node JS in the frontend
Being a server-side platform, ironically Node JS is now hugely used on the frontend.
But it’s not the way you are thinking.
Using Node in the frontend does not really mean you are running Node.js in the browser. You see Node is very good when it comes to reading and writing lots of files in a short amount of time. Developers have used this feature to build lots of frontend tools. Nowadays, most of the popular tools in frontend development are built and run by Node JS.
For example, webpack is a popular tool for minimizing JS and CSS files. Webpack does this on the fly using Node. The same goes for other tools like babel, gulp, browserify and many more.
And this is the sole reason why you have to download and install Node even when you are working in the frontend using React or Angular. Node JS is everywhere when it comes to building web applications. Even if you are not building a web application, you may still encounter tools that are built using Node.
Advantage of learning Node
Since Node is the only tool out there for building the tooling and the backend services, you can make a good career being an expert in it. I am sure, over time there will be more and more uses of Node which you can benefit from.
If you are interested to get started with Node, here are some tips for you:
- Pick one area and be awesome with it, build something
- Comment on this post and let me know what do you think of Node
- Dahl, R. (2009). Ryan Dahl: Original Node.js presentation. Retrieve on April 9, 2020, from https://youtu.be/EeYvFl7li9E?t=796
- JSConf Europe. (2009). Node.js by Ryan Dahl. Retrieved on April 9, 2020, from https://www.jsconf.eu/2009/video_nodejs_by_ryan_dahl.html