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
Thank you a lot about very beneficial to my work was very useful thank you
Inspired by Ruby and Python, ssjs seems to be very nice!
Considering Node is backed by Joyent, being experimented on by Yahoo and lots of other companies and already runs in some production environments, it’s very unlikely that it will “fade” in the short term. It nears 2 years of development and I bet will have at least a decade long stay
thank you! it’s real
I enjoy what you tend to be doing. This type of clever work Server side JavaScript with node.js plus exposure! Carry on this very good works everyone I’ve added you guys to blogroll!.. Oh yeah whats the latest on Charlie Sheen remarkable announcement?
Unfortunately, there is something that I notice that needs to be pointed out. It’s something that you might be missing. Anyway, what I am thinking is that you could all be making some money with the amount of writing that you do. Making money online is a lot more simple than people make it out to be. This could be something that you would be interested in. It just takes owning the right software, and having the right training. Social media is all the rage and this software uses this power, along with article and video marketing, to help everyday people achive their financial goals. Two hours of coaching are included with the software. So if you are brand new to this, you can grab all the details in the step by step video presentations or if you are already well on your way to being a successful Internet marketer, you can skim through all of that and get right to the 2 very well-rounded pieces of software that come with this package. The 2 pieces of software that you’ll get are article marketing submission & rewriting software, and video submission software that will bring lots of traffic if used correctly. Just think, you could be just a few clicks away from finally taking control of your financial independence. Go ahead and check it out: http://adf.ly/1TyAd
I do not even understand how I ended up right here, but I thought this put up was great. I don’t realize who you are but certainly you’re going to a famous blogger for those who are not already. Cheers!