Friday, February 27, 2015

The Event Loop and Non-Blocking I/O in Node.js

Node.js is written in C/C++ and JavaScript and basically lets you run JavaScript code without a browser. It was created by Ryan Dahl in 2009.
“Why did he choose JavaScript?(!)”, you might ask.
Well, first of all JavaScript is just a programming language. So – why not?
It’s well integrated into browsers and so we are tempted to see browser features like the DOM tree as part of the language. They are not. They are provided by the environment it runs on (often: a browser).
If we remove all the browser features we still get a language that
  • has functions as first class citizens
    This means that you can pass a function around like any other variable
  • has an event model
    This is used for things like OnClick in the Browser
To use a language we need some environment that is able to run code written in it.
Node uses Google’s “V8″ JavaScript engine which is also used by Google Chrome.
V8 basically transforms the JavaScript code into efficient machine code for your platform, runs it and takes care of the memory management and garbage collection.
So take V8 and some JavaScript code and you will be able to run it without a browser.
read more here

Leave a Reply

All Tech News IN © 2011 & Main Blogger .