Dynamic Website Application Development with Node.js
October 20, 2016
Javascript and Node.js:
Javascript is a very useful and important tool in the arsenal of a front-end web developer, and you would be hard-pressed to find a site on the internet that uses any dynamic content but doesn’t use javascript somewhere. It is really the life-blood of interactivity on internet websites, and while some of its big uses, namely animation, are now being offloaded to things like CSS keyframes, it still certainly has a place.
All modern web-browsers include a javascript engine allowing them to run javascript content on sites. There are always some limitations when building something, and you will always be required to think outside of the box to solve some problems, but nodeJS takes that to a completely different state of being. Node.js is a lightweight, efficient javascript runtime program that is able to do a lot of things that you would spend ages creating in standard javascript.
Example of Node JS:
The primary uses of Node.js are to create asynchronous I/O, high I/O operation, dynamic and interactive applications. This can include things like real-time chat, browser games, and Single Page Applications (or SPAs). Here is an example of a short, sweet, and simple Node.js script:
var http = require('http'); http.createServer(function(request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end("Testing!"); }).listen();
What this does is create an http server and run a function that requests a response from the server. The server itself is responding with a 200-response and the word, “Testing!” in plain text to any requests that it gets.
This example is about as simple as it gets, but it can get a lot more complex. Some larger websites that are built on node are walmart.com, LinkedIn, Yahoo, and even Uber.
Get Started with NodeJS:
If you are interested in giving this a try, there are a few ways to get started.
1: Set up Node.js on your development server or desktop machine. There are plenty of tutorials, but there is also the npm documentation if you would prefer that.https://docs.npmjs.com/getting-started/installing-node
Or 2: Use a third party online service.
There is a small learning curve for this, but take the plunge and spend a few hours learning the syntax. Also get more familiar with HTTP responses to make the transition into this new style of development a bit easier. Start small and work your way up to bigger things and before you know it, you will be happily plucking away at keys effortlessly!