Introducing Back-end Technologies

This article will introduce us to the other side of the coin. We will get to know the server side usage of JavaScript code, We will see how a JavaScript developer can also become a successful full-stack developer using these back-end technologies.

What is Node.js

Node is an open-source and cross platform run-time environment. Using node we can execute JavaScript code outside a browser. It was launched back in 2009 be Ryan Dahl and since then it has become a premium back-end choice for the developers.

What makes Node fast is its asynchronous I/O data and event-driven capabilities. This feature gives it a visible edge over its competitors which are Ruby, Perl, Python, .Net, etc. Node.js is not file specific extension but a name to relate it to JavaScript.

Working of Node.js

Node.js makes use of JavaScript which handles the different modules running on the web servers for its core functionality. Modules are provided for various reasons which are data streams, core functions, bunary data buffers, networking and file system I/O. To reduce complexity in code, node.js makes use of designed APIs which makes it compatible with other platforms as well like Linux, Windows, Unix servers, etc.

The Architecture

Node.js has a very simple yet powerful architecture. In this architecture, node makes use of event-driven programming on the servers. Such feature enables the users to create highly large servers without the use of threading. It simply utilizes JavaScript with Unix network programming. This is simple achieved by using an event-driven programming model which makes use of callbacks to notify task completion. Node.js processes the requests in a loop called eventloop.

First Node.js Application

It requires 3 main components to properly run a basic node application. These are:
– Importing required modules.

This stores the returned http instance into the http variable

– Creating a server where the application to run the application.

http.createServer() method is called to create a server instance on http instance. We then bind this server to 8081 port with the help of listen() method. Then it returns the message “Hello World” showing its implementation.

– Reading and returning of request and response.

we put our code to test the request and response from the server naming it main.js

we run our code by excuting main.js

and then we verify the output