Every programmer must be aware of node.js servers. Node.js is a modern server framework that lets developer to build applications using Javascript on server side under V8 Javascript runtime environment, hmm cool enough! Well we got lot stuff forward.
Things to know about node:
1. Real time Web Applications
2. Non Blocking Code
3. Event Based Programming
4. Event Loop
Google Chrome uses the v8 javascript runtime in client side. so then node.js wraps this runtime and provides additional functionalities that helps you to develop network applications.
"Node.js is writtent in c"
As node.js is very fast you can do stuffs like file upload server, websocket server (realtime content to websites). Now why node.js is fast to know that, well you need to read further for that.
What's Non Blocking Code & Blocking Code?
Let's take an example of file upload server, normally how your file upload works. Let's write a pseudocode for that.
- Read file from client and receive it to server
- Process file do some stuff with the file
- Then do something else
Here in this case the server waits for the file to be uploaded and then waits till its done, then it moves further to do other stuff.
Now in case of node.js this is done something like this.
- Read file from client
- has a callback method which informs file upload, and also do stuffs with chunks of bytes received by client.
- Do other stuff
In this case you see that the server application can receive files as well as do other stuff parallely, and at the same time you can also do process your file.
Event Loop
The event loop model diagram says how actually node.js works with events. Node.js event loop waits for the event to trigger from both server side and client side and then request a specific callback to perform respective task.
Refer : http://www.codeschool.com
Thank You for reading my article, do come again for further part of this tutorial and other programming guides.
Comments
Post a Comment