4

I am just wondering how node.js is compared to other frameworks. Is it possible to develop rich internet applications using node.js? How is it compared to java NIO? In short I am looking for the target domain of Node.js

Farshid Zaker
  • 1,960
  • 2
  • 22
  • 39
  • Please take a look at my other answer to help you get started: http://stackoverflow.com/questions/5655774/live-chat-with-php-and-jquery-where-to-store-information-mysql-or-file/5683443#5683443 – RobertPitt Jun 27 '11 at 17:04

1 Answers1

6

not sure why there are people voting to close this question when I think it's perfectly viable, Node.JS is a new server side framework that is still undergoing heavy development.

to answer your question may be a little difficult for myself as I know nothing of Java, but I know a little about Node and use it on a regular basis whilst it's under development.

Node JS is basically a framework built up of several components that are built for speed, such as Google's Javascript Engine (V8), it was originally designed for Google Chrome but released as an Open Source project.

Many developers have taken V8 and placed it on the server, combining it with custom libraries integrated into V8 to allow File I/O and network access.

So what is Node.JS

Node JS is basically Googles V8 javascript engine as the language platform, Mixed in with Lib Event, which is a technique of using 1 thread to perform multiple tasks by creating Events from the kernel.

The primary usage of Node it's it's networking functionality, Ryan has contributed a really powerful HTTP Library that has helped it take of with Web Services, which is what it's main intention is for.

Why do I use NodeJS

I like Node JS simply because it's easy, fast and very modular, being able to supply information such as Files, Images, Text to a web browser directly from the Servers Memory (RAM) in under 10 lines simply helps understand the power behind it.

For instance, Nearly every web-browser makes a request for favicon.ico, which is usually ~10KB, Now if i had 100 Requests per second and every request was requesting my favicon, my hard drive would have to locate that file, blocking all other reads in the mean time.

I can just load the data, store it within a variable and send it to every client much much faster then the traditional methods.

What's the best part about Node.JS

The best part about node.js personally is the concept, the idea of being able to search thousands of clients concurrently without blocking any other client is the drive behind the speed, every thing is speed motivated, hence Google V8, it's called V8 for a reason, Lib Event, it's removes the requirement for loads of threads, which can be heavy on resources.

Getting Started

I seems like you have not really had a play with Node.JS, and if you have not then is suggest you isntall it and have a play for a few days, Join there IRC Chat and speak to some of the guys over there, there is usually a member of the immediate team there that will help you.

You can simply install node.JS on Ubuntu like so (In Bash):

if you do not have git

sudo apt-get install git-core

install node JS:

cd /etc/
sudo git clone git://github.com/joyent/node.git
cd node
sudo ./configure
sudo make
sudo make install

to test make sure you have it installed

node --version

if you get the version your ready to go, go to your home directy

cd ~/
mkdir Nodes
cd Nodes/

create a simple file in you ~/Nodes Directory called test.js and start away, you can run the code lie so:

cd ~/Nodes
node test.js

I had written that small guide to setting NodeJS up not just for yourself but for others who may read this and would like to set things up.

Community
  • 1
  • 1
RobertPitt
  • 56,863
  • 21
  • 114
  • 161
  • Thanks for this comprehensive answer and thanks for defending against the closers! In "What's the best part about Node.JS", you've mentioned that it's possible to handle thousands of client requests. How is it possible? Is it related to being single threaded? If yes, how a single thread is able to handle several clients? – Farshid Zaker Jun 27 '11 at 18:21
  • There are many factors involved in why it can handle many concurrent connections and yes the reduction of threading is one of them, but there are many more the primary being the non-blocking concept, things are passed to the kernal and while the kernal do the work, then node does many many other things, and when the kernal comes back with some data, node has supplied a few hundred clients, it basically creates a work list, anything non blocking takes nano-seconds to complete where as blocking takes much more time – RobertPitt Jun 27 '11 at 18:27
  • The best answer I was wishing. Thanks. – Farshid Zaker Jun 27 '11 at 19:01