While skimming through my RSS feed I stumbled upon an interesting article on Ajaxian about server side JavaScript programming.
I really, really enjoy writing JavaScript code so I decided to read through the article and take a look at the node.js library linked there.
Node is a framework to build server-side event-driven JavaScript applications. Developed in C++ on top of Google’s V8 JavaScript engine and accompanied by a set of JavaScript libraries Node seems to make building distributed (over a network), fast applications a piece of cake even for inexperienced developers.
Event-driven here really is the keyword because it represent a big change in the way applications are built (and architected in your brain).
Node is similar in design to and influenced by systems like Ruby’s Event Machine or Python’s Twisted. Node takes the event model a bit further—it presents the event loop as a language construct instead of as a library. In other systems there is always a blocking call to start the event-loop. Typically one defines behavior through callbacks at the beginning of a script and at the end starts a server through a blocking call like
EventMachine::run(). In Node there is no such start-the-event-loop call. Node simply enters the event loop after executing the input script.
The example below (taken from Node’s website) will make everything clear… hopefully.
http = require(‘http’);
http.createServer(function (req, res) {
setTimeout(function () {
res.sendHeader(200, {‘Content-Type’: ‘text/plain’});
res.sendBody(‘Hello World’);
res.finish();
}, 2000);
}).listen(8000);
sys.puts(‘Server running at http://127.0.0.1:8000/’);
Can you see the beauty?!
I have only one worry. This is an open-source effort. The community behind it on Google groups is just 181 members strong (so far). What if node.js suddenly stops being the cool thing and the community disappears.
As much as I love writing JavaScript and I can really see the value in what they are building I’ll still wait until there are 100 Google Groups for node.js and a trillion members in each before using it in anything close to a production system.
Having said that I’m going back to writing silly node.js apps now. Well done to all the developers involved in the project and keep it up!














Node has gotten a LOT of mentions over the past two weeks but Ryan has been hacking on the project since at least February and checks in changes more or less daily. There are normally 4-5 committers in a group of 2-3k users, so it’s not like the project is unsupported or the maintainer is looking to quit. Holding off on production isn’t a bad idea, but I expect node to become one of the major SSJS implementations since it works so well with the long polling that we love.
Thanks for the comment and figures Karl. I certainly hope that the project will keep growing and become a de-facto standard.
Meanwhile I’ll just keep hacking away and playing with it.
Social comments and analytics for this post…
This post was mentioned on Twitter by sapessi: RT @sapessi Server side JavaScript with node.js http://bit.ly/6iCoGm #javascript #programming…
Interesting article, thanks for posting
In Python? Really? Did you read the web site at all?
Node.js is written in Javascript. It’s build system uses Python.
Sheesh….so much misinformation.
You are right. Thanks for the correction. I updated the article.
Node is actually written in C++, the libraries are obviously written in JS.
I’m not sure I buy that event-driven is such a big change, just because of a fork in the process (or a thread-spawning) being executed. Event driven development became a new thing ages ago when Xtoolkit for X Windows started (or maybe a lot earlier than that, even) and was subsequently popularized by Visual Basic/etc. I also don’t view it as much of a language construct (you’re just passing a closure to the function).
That said, I am very excited to hear about these upcoming developments with node.js. The simplicity of what they are doing is great; hopefully we’ll see a nice web framework built on top of it soon (maybe someone could take TrimPath Junction and mod it for this?).
Yes the event-driven model has been around for a long while. I’m not talking about a new technology but a change in the way these sort of app are conceived and written. Many programmers are used to writing big apps with a main loop in which they have to keep everything under control.
What Node has done is simplify this concept. The only analogy I can come up with now is a sort of restful API. That’s for me is exactly the way to go. makes the developer’s life a lot easier.
Interesting stuff. For the example you mention I see the dispatching code moving from the main loop which has moved ‘under the hood’ to the service function. Does not seem like a huge win at first glance.
BTW what is to ’stumple’?
[...] This post was Twitted by apanitsch [...]
Cheap SEO Company India
We offer best and Affordable SEO Services, SEO Freelancing Services and SEO Services India.
thanks for updates