NodeJS

NodeJS, The Next Big Platform, ...period

  • Published on Wednesday, 14 January 2015 03:51
  • Hits: 3048
User Rating:  / 1
PoorBest 

Last monday I was having one of those "profounds" conversations with a work colleague about JS frameworks, Server Apps, building Rest Services, etc, and he came up with this statement: "I don't understand why people are starting to build web apps with nodeJS while there are already so many great and awesome server side platforms in the market with tons of resources in the web!!", ..I left a couple of seconds to pass by and then I just had a very simple answer: "Because it is the Next Big server side platform, ...Period!!".

Immediately I was asked with the obvious question: "Why??". ..And that is when I decided to answer it writing this article!!.

NodeJS is a server-side JavaScript framework, which means that all of a sudden all the code that you have written in Javascript, that code which powers awesome Ajax applications in the client side will now power the server side as well!!, ...so creating a JS server-side server sounds a good idea after all.

It seems nodeJS creators were so smart to think about creating the first javascript server, ...hey, wait a minute, not so fast..., THIS IS NOT THE FIRST JAVASCRIPT SERVER-SIDE FRAMEWORK, let me give you 3 examples of previous ones:

  •  SpiderMonkey - https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey - he first-ever JavaScript engine, written by Brendan Eich at Netscape Communications in the fall of 1996, ..it is said that the foundation of spidermonkey was created from him in a couple of weeks.
  •  Rhino - https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino - It also started at Netscape in 1997 just when the company was writing javagator, a fully browser built with Java. It needed an implementation of JavaScript written in Java for the browser to be able to "understand" js. Netscape stopped the "Java Browser" project and the Rhino project was finished as a JavaScript engine.
  • V8- https://code.google.com/p/v8/ that is where nodeJS comes from. The first version of the V8 engine was released at the same time as the first version of Chrome, September 2, 2008. As SpiderMonkey it is written in C++ but in this case it compiles JavaScript to native machine code (IA-32, x86-64, ARM, or MIPS ISAs)[3][6] before executing it.

V8 enabled Chrome to initially post significantly faster benchmarks than other browsers, and Ryan Dahl, creator of Node.js, took a smart decision when selected V8 as the engine for his awesome framework. But why V8 was it so fast and so good??. Mainly because the following 3 great features:

  1. Certain JavaScript objects are dynamically compiled directly into native machine code before execution based on a predictive analysis of the code
  2. A new approach to property access
  3. A more efficient garbage collection system

Dahl was inspired to create Node.js after seeing a file upload progress bar on Flickr. The browser did not know how much of the file had been uploaded and had to query the Web server. It was created and first published for Linux use in 2009. Ryan Dahl then ceded his position as gatekeeper to Isaac Schlueter so he could work on  improving the third party module system experience.

So now that we know a bit of Javascript Server-Side Frameworks, ..why NodeJS is the best one???. Hmmm, in my opinion because of the next functionalities (besides being based on the awesome V8!!):

Code Reuse

How much code do you already have written in JS that you can reuse at the server side??. For sure more than you think. Actually as soon as AngularJS 2.0 hits the market then you will be able to reuse your angularJS code in nodeJS, ...actually you can already do it using this module.

Actually, the best of all is that you will not need to use 2 programming languages anymore for your awesome developments!!, ..no more PHP, Ruby, Perl, or whichever server side language, ....unless you still want to use them of course

Speed

It’s driven by asynchronous design. That means that it doesn’t have to wait for slow file I/O or database operations to continue processing, which makes it really damn fast (by that I mean faster than most other popular server languages / platforms). It also means that it can handle millions of concurrent connections at once. It makes real-time applications a walk in the park. No longer do you have to bother with low-level sockets and protocols. You can make a Comet-driven real-time chat application in the same time you would have made a simple blog in PHP or a birthday cake with a ready-made mix.

Package Management

NodeJs uses a very nice and easy package manager called NPM. what is nom?, ..as you can read in its website npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing. They to install any package is just to execute "npm install nameOfPackage" creating the node_modules directory (if one doesn't exist yet), and will download the package to that directory. For example to install Express that is a minimal and flexible web application framework that provides a robust set of features for web and mobile application, you would just type npm install express, ....easy, isn't it??

Non-blocking, event-driven I/O

Excuse me??, non-blocking event driven I/O??. Is that a benefit?, a NodeJS Strength?. ..Actually it is for many the most important one to start using it!!. This enables the creation of fast, scalable network applications, as it’s capable of handling a huge number of simultaneous connections with high throughput, that is data-intensive real-time applications and that leads to the next great feature about this framework

Real Time Applications

It is one of maybe the best server side framework to be able to handle real time applications in which the server and the client needs to maintain a persistent connection. Yes a persistant connection without eating up all the server resources as it happens in Ruby, or some other server side frameworks. So nodeJS is just perfect, or let me say the best one to build browser-based chat, a real-time trading app or even a peer to peer file sharing. (I see great benefits for apps as BitTorrent to be moved to the browser using NodeJS as for example handling your downloads from any mobile device (iOS, Android, Windows), your smartTV, or even you PC at work as it is a browser-based app.

Learning Curve

It is just as Fast as the Framework itself. I recommend you to start with the basic Learnyounode and then just all you have to do is keep going as you already know Javascript, ...yeah, no need to learn another programming language ...daaaahhhhh!!. 

Hopefully now you will be saying: "Fantastic, Sepelka!!, thanks for these words, It is time to start using NODEJS as it is Awesome!!!", but i don't want to finish this article without mentioning some Usefull Modules that will save you tons of coding in your daily projects:

Express

It is you perfect tool for HTTP Servers, ..and HTTP Servers for your web and mobile applications is what a majority of you will use NODEJS for.

Check it Here

Connect

"Connect is an extensible HTTP server framework for node using "plugins" known as middleware.", ....ehhh, what??. Well that is the definition in the module site but believe me that you will need it, for example when you need to parse parameters in a Post Request

Check it Here

Moongose

Best module to connect to mongoDB Databases

Check it Here

Mocha

Needn't a testing framework customisable enough to support both behaviour-driven and test-driven development styles??. Use Mocha, it is easy, intuitive but very powerful

Check it Here

Jade

It is a template engine with many, many fans. I haven't used it, ...and most likely I will not as I was not very "attracted" of how it works, ...but again it has many, many followers so I just mention it to you

Check it Here

It is your time to start using NODEJS.

IT News to be aware of ..

Most Visited...

QR Codes: The best 9 QR Code Generators

Hits:41004

QR Codes: The best 9 QR Code Generators

Last week we talked a little bit about how the QR Codes are becoming very, very popular and a bit of its history which is always good to know :)...

Read more

AngularJS, No more Dom Manipulation

Hits:6715

AngularJS, No more Dom Manipulation

You love to access the DOM, to change the information in it. You just love it!!!, ..but that is because you are using JQuery. It is like using assembly language,...

Read more

Famous, the most beautiful javascript Li…

Hits:4048

Famous, the most beautiful javascript Library

Yes, now there a couple of ways of becoming famous, ..the first one is following your dreams and becoming the best in class developer with a great idea, or use...

Read more