Welcome to Node.js

1) Why Node.js?

2) Getting Started With Node.js In 3 Minutes

3) Setting Up Node.js in Eclipse in 5 minutes

4) Server Side Javascript - Hello World Node.js Application

5) Master the node.js


1) Why Node.js?

JavaScript is a scripting language that has quick loading time. Conventionally the JavaScript from the webpage would thrive on the client side browser. JavaScript took several births and the most recent being Node.js with server side scripting.


There have been multiple other server side scripts in existence over the decades. However Node.js is the closest to perfection and surely going to be a bleeding edge technology in the near future.


The V8 Javascript Engine developed by Google (used in Chrome) compiles the JavaScript to native machine code and then executes it. The compiled code is additionally optimized dynamically at run-time leading to high performances. Node.js ships with it its own V8 version as its run-time.


So here I am rattling away on Node.js as one of the cutting edge tool for building the next generation websites. The question is it going to replace proven competitive technologies such as Java, Dot Net, Python, Ruby, Adobe Flex etc.


The answer is in the following points … figure it out yourself and let me know :) 

Aliters on Node.js features:


1)      High Performance using V8 engine

2)      Non-blocking event oriented nature similar to Adobe Flex

3)      Ease of implementing Publish-subscribe models using Socket.IO

4)      Rich set of support from the community with increasing number of re-usable modules for features such as Mailing, REST calls, File Upload, Stream writing.

5)      Efficient frameworks for Node.js at the UI, Styling, Middlewares, Backend such as Express, Jade, Stylus and Backbone.js.


I will be writing lot more articles illustrating with examples multiple features of Node ranging from Getting Started Examples to Advanced Concepts in the coming weeks.

2) Getting Started With Node.js In 3 Minutes

1)  Download the node.js  from the official site http://nodejs.org/
2)  Once you have completed the installation from the site, open the command prompt, and enter

node --version

3)  You should see the milestone build version downloaded from the site.eg:  v0.8.14
4)   Create a simple File called test.js
5)   Type in the following line of code in the file and save it:

console.log("Welcome to the world of node.js.....");


6) Traverse to the folder that holds the File in command prompt and enter the following:

node test.js

On the command prompt you should see the output as follows:

Welcome to the world of node.js.....

3) Setting Up Node.js in Eclipse in 5 minutes

1) Download the eclipse from the official site http://www.eclipse.org/downloads/ preferably download Helios or Juno flavors of eclipse.

2) Assuming at this point that the eclipse is started up with appropriate JDK in the system, open the  Install New Softwares option from under the Help in eclipse.

3) Enter the following update site for the node.js plugin   http://www.nodeclipse.org/

4) Restart eclipse when prompted after the update

5) Right click on the navigator pane and you should see as follows with option to create node.js projects


6) Create a Node Project 
7) Create a Node Source File say test.js

8)   Running the file from eclipse
       
 a) Click on External Tools Configuration in eclipse
               

  b) Enter the details as shown below



 c) Hit Run and you should see the node.js application run from within eclipse.

4) Server side Java scripting - Hello World

We are going to illustrate the rendering of web pages hence we add the http module.

Assuming at this point you have covered all of the steps of my previous posts. Follow these steps:

a)     On the command prompt, traverse to the project root dir. For example: Create a folder under c:\demo
b)     Hit “npm install http” on the command prompt. This will install the http module.
c)     Create a file called app.js
d)     Copy paste the below code.
var http = require("http");
http.createServer(function(request, response) {
  console.log("welcome to node world.............");
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World");
  response.end();
}).listen(3001);
e)     Hit “node app.js” on the cmd prompt
f)      Open your favourite browser and hit - http://localhost:3001/
g)     You should see the output as follows:



Leanings from this demo are as follows:
a)     Defining HTTP module and the need of it.
b)     How to define a port for a web application
c)     Syntax for creating a server
d)     Sending response back to client.


5) Master the node.js









 2) Intro to Node.js from Chris Cowan



Intro To Node.js from Chris Cowan


3) Node.js debugging from Nicholas McClay






3 comments:

  1. How can you create a app to talk to FB video chat from your website?


    Lydia

    ReplyDelete
  2. Thanks for such a great article here. I was searching for something like this for quite a long time and at last, I have found it on your blog. It was definitely interesting for me to read
    Node JS Online training
    Node JS training in Hyderabad

    ReplyDelete