Node JS: Primer Introduction & Foolish Assumptions Hey everyone! Welcome to the best fundamental tutorial on Node JS. I would like to “fool

Node JS: Primer By Praveen Kumar

Node JS: Primer By Praveen Kumar

Introduction & Foolish Assumptions

Hey everyone! Welcome to the best fundamental tutorial on Node JS. I would like to “foolishly” assume something about the students or developers, who take this course:

  • You know the basics of web development, i.e., you understand HTML, CSS, JavaScript, etc.
  • You have a basic working knowledge of JavaScript, AJAX calls, etc.
  • You know a little bit about any of the server-side programming like ASP, PHP, Java Servlets, Ruby on Rails.
  • You are comfortable using command line.

Okay, let’s dive deep into Node JS. When you head over to the Node JS website and find the introduction, you are faced with a page saying something like:

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. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

Well, that doesn’t make any sense, right? Either it’s too technical or it’s something that doesn’t help you understand what’s Node JS and how can this help you. This is not at all a user (or a newbie) friendly text to place in the home page of the website. Well, here’s what Node JS is:

  • It’s a platform which allows us to run JavaScript on a computer / server.
  • Create, read, update, and delete files on the server side.
  • Establish a connection with a Database and perform operations on it.

A good thing about Node JS is, it helps not only build n-Tier applications, but also the whole three layers are written in JavaScript as well:

  • Presentation Layer – You use the client-side JavaScript.
  • Application Layer – This is written in JavaScript using Express JS and Node JS and it’s run by Node JS.
  • Database Layer – MongoDB, open-source cross-platform document-oriented database program.

This way, you don’t need to learn multiple languages in the three tiers. You just need to know the syntax of one language, that’s JavaScript via Node JS.

Motivation behind migrating to Node JS

Node JS: Primer

So, why would you want to migrate to Node JS? You have a great enterprise application running in, say Ruby on Rails or PHP but you decided to switch it to Node JS. The first thing is, it’s insanely popular, as it uses JavaScript. JavaScript is used by almost all the web developers and you cannot build a modern web application without JavaScript. This alone gives an advantage of not needing to learn another new programming language.

Another reason would be it’s extremely faster as it runs on V8 JavaScript Engine, which is Google’s open source high-performance JavaScript engine, written in C++ and used in Google Chrome, the open source browser from Google. The advantage is that it uses non-blocking code, as most of the Node JS functions are from standard library and they are asynchronous in nature. This way, when a program goes into an infinite loop, it will not block further code from executing.

Who likes writing the same code again and again? Node JS has a huge eco-system of open source packages that can be installed via an application that comes bundled with Node JS called Node Package Manager or npm. The community of developer base this has is humungous. Along with this, you can also use Node JS for writing real-time socket services such as a chat program, queueing system, push notifications, etc. through Web Sockets.

How is this course split up?

We have a small agenda to work our way through the application. We will be learning more of:

  • How the Node JS itself works – the V8 Engine, Modules, Events Emitters, File System, the inner workings.
  • Creating your first Node JS Web Server – Routing, Middleware, Templating.
  • Making a Node JS application – Say something like a ToDo Application.

Hope the above three parts give you a basic idea of what we will be aiming to cover. This is going to be a complete end to end training from the basics till you get hands-on and create your own server. Using the knowledge gained, you will be able to create a nice and quick ToDo application similar to the one below:

We will be able to add things to the list, edit them, and delete them. I’ll be suggesting Sublime Text as the text editor to use for the tutorial and I hope you will enjoy working on it as it is a highly programmable free software (you may buy the license, but it’s not at all needed if you are learning). You can get Sublime Text from its official website at sublimetext.com/2.

I will be adding the assets for the whole training in GitHub public repositories. I’ll be releasing the assets as we go and not the final one, as this will suppress the learning excitement altogether. If you are curious, all that’s there in the final GitHub repository is just an image, a stylesheet and a HTML file. Nothing more.

Let’s start cracking with the code soon with the next post. Make sure you have the following ready for the next one:

  • Sublime Text installed in your system.
  • Node JS installed in your system.
  • A little bit of knowledge in JavaScript, HTML, and the command line.

Thanks to Praveen Kumar for being our guest writer this week.

 

Book in for a free 10-minute candidate attraction call with us today? Please click here to make an appointment.

© Ronald James Ltd. 09824756. Q16 Business Exchange, Quorum Business Park, Newcastle upon Tyne, Tyne and Wear, NE12 8BX, United Kingdom. Website by Outlines Design.