Skip to main content

Getting Started - Introduction to node.js


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

Popular posts from this blog

Free Cloud Server | Get A Free Cloud Server | Amazon AWS

Hello Developer | Reader | Creator | Explorer! I was going through cloud servers on Internet, as it becomes very difficult to manage everything on shared hosting. Amazon AWS is one of the providers of cloud services, which has a scheme of pay as you use. Amazon AWS includes a lot many web servirces like, Api Gateway, SNS(Mobile Messaging), S3(Strorage), etc. AWS has almost all those reuirements which a developer would require. And also the best part is Amazon AWS gives 12 months free access to its web services. In this post we will discuss about creating an Account on Amazon AWS and setting up with cloud on EC2 (a service of amazon aws which provides cloud computing). Amazon EC2 cloud computing, that includes a public ip and a free domain(domain would be somthing like ec2-bla-bla.bla-bla.amazonaws.com) Follow these steps to create Amazon Account:- Create a amazon AWS account go here  https://aws.amazon.com/  on top left click on sign in to console. After doing t

Laravel 5.2 Multi Authentication

Today I wasted almost 3 hours to search on internet about Multi Authentication in Laravel 5.2. I have gone though laracast's post and other few forums too, I was still not able to find any solution for it. Their were packages such as sboo/multiauth, ollieread/multiauth, kbweb/multiauth etc. yet was not satisfied with their solutions, I tried to use them a lot but very soon I got stuck with bugs. Finally after a long research I finally found out a great solution for it, i found it on a frequent website I visit for my solution of any coding problems, and the solution was really shocking for me that it required no package installation or any other kinda stuff. It's already included with Laravel 5.2. Thanks to  Hasmukh Tank  a stack overflow user, he made a beautiful step by step procedure to do that. Here are those procedures: Refer Url :  How to use multi Auth in laravel 5.2 1. First we create two models 1 ) user , 2 ) admin 2. Update the config / auth . php fil

Redirect Non-www to www and vice versa | Non www to www | www to Non-www

You have a website say example.com, you want it only to be accessed by www.example.com, instead of both example.com & www.example.com or you may want your domain to be only accessed by example.com instead of both example.com & www.example.com. What is www and why should I redirect to my preferred domain?  Well here's the answer: Www is actually a subdomain of your domain. www actually refers to [world wide web] hmm! well than why redirect? The best answer is both the domains might have same content i.e. yourdomain.com and www.yourdomain.com, and its not very good to the search engine bots. What should I choose? www or non-www domain? This is completly depended upon you and the name of your domain. Sometimes domains are quite good without www for example https://letsencrypt.org . The domain with or without www does'nt effects search engine optimization (SEO). 1. Redirect your website from non-www to www  i.e. example.com to www.example.com Configure your ngin