I do a lot of full-stack development courses, and over time, courses go out of date. So it was great to redo one of my more popular courses on Building a Website with Node and ExpressJS. Originally, the course focused on creating a simple website using Node and ExpressJS. Deploying a site with Node was light years easier today than in the past and allowed me to do much more.
#5 Easy Deployment
One of the problems I found with the original version of the course was how hard it was to deploy a site. Most cheap servers couldn’t handle serving a NodeJS project. I tried all types of approaches including buying a VPN server and installing Node myself…not a pleasant experience.The easiest thing at the time was Heroku, but the documentation was hard to read and deployment challenging.
Today, I found there’s a lot more ways to deploy your app including services like Now and Firebase. Now from Zeit example makes it ridiculously easy to deploy a NodeJS site using a simple npm command (literally $ now). Platforms like Firebase provide easy, cheap hosting and an easy to use real-time multi-user NoSQL database.
Deployment is no longer anything to stress about, but besides deployment, this combination of technologies gives you some serious advantages that are tough to program using the alternative LAMP (Linux, Apache MySQL and PHP).
#4 Non-blocking Architecture
A huge advantage of NodeJS is it’s non-blocking architecture. That means that you make a request for a document or data, your app can make send the request to your server and keep on doing other stuff. When the request if fulfilled, it gets passed back to your app, so the server request doesn’t block your application. That makes for sites and apps that are more responsive and can handle connections much more efficiently.
When you use something like PHP with MySQL and you make a request from a database, the page will wait until the query you’ve made is done. You can easily tax a server with a complex query that will make it stall. Database AJAX requests feel faster and more responsive using Node.
Another reason for working with Node sounds obvious. A single language to manage your front-end and your back-end is more efficient. Plus, you get all of the features available in Node, including things like file access.
Node has thousands of plugins that can easily add functionality to your project, so things like real-time communication, access to noSQL databases and template engines are easily added. In that way, Node is more modular than something like PHP, which is hugely complex with many more features than you’ll ever use.
#2 Routing your App & Verbs
Another big advantage is Node’s ability to have control over the routing of your application, so URLs become more than just paths to filenames, but can be useful in the management of content. With NodeJS you get direct access to verbs and can build interactions that are tougher to do with LAMP. You can control how you manage GET, POST, UPDATE and DELETE requests directly.
#1 Real Time Multi-user Features
Because NodeJS already gives you superior routing features, but the language makes it easy to access files and packages like Socket.io make it ridiculously simple to build real time multi-user applications.
That means you start thinking of your site as an application instead of an electronic brochure where users can interact in meaningful ways. Those types of interactions are harder to achieve in a LAMP environment.