All About Node.Js You Wanted To Know ?

                                               Image Source

Lot of youth aspires to be a most sought after software developer and so goes on to learn the required programming skills to match to the current market and industrial needs. They have broadly two choices to make

  1. To Be A Front-End Developer
  2. To Be A Back-end Developer.

#ChandrayanLogy

Remember we are the product of choices we make, So listen to your heart and choose right technology to build the right kind of product , for the right purpose .

Front-End Development:

Front-end development covers coding the UI interface, handling events and interacting with back-end server to pull the data on the front-end UI side. Front-end is where user engages with the app and perform activities

Developer who are seeking careers in front-end side mainly needs to master

  1. Java : For Android Front-end development/ desktop solution development
  2. C/C++ : For Android/IOS Front-end development
  3. C-sharp : Unity Game and Windows Mobile App development
  4. Objective C : For Iphone app development
  5. Swift : For iPhone app development

Back-end Development :

Back-end mainly deals with the technical stuff which is not visible to the end user. It mainly deals with server side scripting and data base interaction so that front-end apps can request for the required data to be populated in the front-end mobile /web/desktop app.

  • This server-side application directly interacts with the database via an application programming interface (API), which pulls, saves, or changes data.
  • The data are returned and converted into front-end code a user interacts with: filling out a form, creating a profile, shopping online, etc.
  • In general, anything you see on a site is made possible by back-end code, which exists on, and is powered by, a server.

Today We will cover Node.js which is the most sought after backend scripting language in the current technology market and is becoming the preferred language options for back-end programmers.

Node.js Introduction :

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. npm is a Node.js package of open source library which is largest in the world.

It’s an asynchronous event driven JavaScript runtime, which is designed to build scalable network applications.It can handle many concurrent connections at a time, where when connection request are made concurrently for each connection a callback is fired .If there is no task to be performed Node will go to sleep.

Node.js connection handling mechanism is super efficient than our existing classical thread based model Thread-based networking is relatively inefficient and very difficult to use. Furthermore, users of Node are free from worries of dead-locking the process, since there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, scalable systems are very reasonable to develop in Node.

As per Wiki :

Node.js is an open-source, cross-platform JavaScript run-time environment for executing JavaScript code server-side. Historically, JavaScript was used primarily for client-side scripting, in which scripts written in JavaScript are embedded in a webpage’s HTML, to be run client-side by a JavaScript engine in the user’s web browser.

How It All Started : History of Node.js :

Node.js was first conceived in 2009 by Ryan Dahl and was developed and maintained by Ryan which then got sponsored and supported by Joyent.Dahl was not happy the way Apache Http server used to handle the lot of concurrent connections and the way code was being created which either blocked the entire process or implied multiple execution stacks in the case of simultaneous connections. This lead him to create a Node.js project which he went on to demonstrate at the inaugural European JSConf on November 8, 2009. He used Google Google’s V8 JavaScript engine, an event loop, and a low-level I/O API in his project which won lon of hearts and standing ovation.

In June 2011, Microsoft and Joyent implemented a native Windows version of Node.js. The first Node.js build supporting Windows was released in July 2011.In January 2012, Dahl stepped aside, promoting coworker and npmcreator Isaac Schlueter to manage the project.In December 2014, Fedor Indutny started io.js, a fork of Node.js. Due to the internal conflict over Joyent’s governance, In February 2015, the intent to form a neutral Node.js Foundation was announced. By June 2015, the Node.js and io.js communities decided to work together under the Node.js Foundation.

Node.js Architecture :

Node JS Platform does not follow Request/Response Multi-Threaded Stateless Model. It follows Single Threaded with Event Loop Model. Node JS Processing model mainly based on Javascript Event based model with Javascript callback mechanism.

Node.js comprises of two main component core & its modules. Core: it’s built in C & C++. It combines Google V8 JS engine with Node’s Libuv library and protocol bindings including sockets & Http.

1. V8 Engine : Run time Environment

It’s an open sourceJIT(Just In Time) compiler written in c++ which has outperformed PHP, Ruby and python performance wise. V8 compiles Javascript directly into assembly level code. V8 Runtime environment comprises into 3 major component

  1. Compiler : dissects the JS code
  2. Optimizer : Optimizer called crankshaft create abstract syntax tree(AST) which further converts to SSA : static single assignment and gets optimized
  3. Garbage Collector : V8 divides the memory into 2 spaces Old spaces and new spaces both belongs to heap memory and keeps track of JS objects, any new objects is stored in new space. When new space is fully occupied V8’s garbage collector removes dead objects from new space and puts into old space. Gabage collector play vial role in keeping NodeJs lightweight.

2. Libuv : A C++ library

This library handles Node’s asynchronous I/O operation and main event loop. There are thread pool reserve in Libuv which handles the thread allocation to individual I/O operations.

3. Design Pattern :

Node utilizes object pool, facade and factory design pattern.

3.1 Object pool :

are a list of objects available for a specific task. Node relies heavily on Object Pool design pattern to which is a centrally memory management system.

3.2 Facade :

Facade provides interface to the body of the code like class library. In Node Libuv act as that facade around smaller libraries like Libev and Libio.

NPM : Node Package Manager

It’s an official open source package manager for Node written purely in Javascript.

Node.js Highlights (Features) ?

But before that lets understand Node.js importance by this Infographics coined by Engine Yard :

                           Image Credit : Engine Yard, Source :

Following are some of the prominent highlights that make Node.js the first choice of software developers specially backend.

1. It is asynchronous and event Driven −

All APIs of Node.js library are asynchronous, that is, non-blocking. It essentially means a Node.js based server never waits for an API to return data. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.

2. Super Fast :

Being built on Google Chrome’s V8 JavaScript Engine, Node.js is super efficient and quick in code execution.

3. Single Threaded but Highly Scalable :

Node.js uses a single threaded model with event looping. Event mechanism helps the server to respond in a non-blocking way and makes the server highly scalable as opposed to traditional servers like Apache which create limited threads to handle requests.

4. No Buffering :

Node.js applications never buffer any data. These applications simply output the data in chunks.

Because of above specifications some of the biggies like eBay, Paypal, Godaddy, General electronic , Yahoo etc.. relies on Node for their server side programming needs.

                                                         Image Source

Application of Node.js :

It is being employed in

  • I/O bound Applications
  • Data Streaming Applications
  • Data Intensive Real-time Applications (DIRT)
  • JSON APIs based Applications
  • Single Page Applications

Let’s Create our First Application In Node.js :

We will try to build and run our first small code using node.js features to understand why it is the darling of the modern day programmer in our next article in the NodeJS series..

Also don’t forget to read one of my most loved article on Nodejs :

Node.js Vs PHP : Battle of Supremacy & survival

If you are 💚 💚 my contribution do 👏 👏 clap Click Here and subscribe to reach out to me for more and i would feel blessed to hear and respond you back.

 

Pramod Chandrayan

Founder & CEO (Mobibit Soft (P) Ltd) | Mobile App Development Consultant | Startup Mentor | Spiritual Seeker

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle Plus

Related posts

Leave a Comment