JavaScript has long held its place as the language of choice for the Web, but it’s only recently become fashionable to run it on the server-side. While Sun Microsystems and others mumbled about server-side JavaScript as early as 2006, it is the recent popularity of Node.js that has given the language a foothold on the server. And while Node.js has grown on Unix systems, its creators are now working on bringing it to Windows.
Node.js was created by Ryan Dahl when he was searching for a way to bring event-driven programming to the Web. The project is currently sponsored by hosting company Joyent.
“Ryan is a C developer, and he didn’t have any relationship with JavaScript before Node,” said Tom Hughes-Croucher, chief evangelist for Joyent. “He was writing high-performance Web servers in C and C++. He wanted to use this event-driven model more. He saw himself writing the same applications again and again. He played with Twisted, the Python event-driven framework.”
But the existing libraries and languages didn’t quite do it for Dahl, said Hughes-Croucher. “The predominant reason is that there is a lot of heritage in server-side programming already, so when he wanted to use some other library, or access a database, or do something that involved input/output, the existing heritage of those languages didn’t work very well with an event driven system,” he said.
This is because all the existing libraries were blocking, he said. “The event-driven system requires that it can continue doing other work while it’s waiting for a task to be completed. I don’t have to wait for the database process to be complete in order to do more work. People had built all this infrastructure that didn’t work this way.”
The eventual catalyst for Node.js actually came out of Google. The Google Chrome team opened up its own JavaScript runtime, V8, as an open-source project, and this provided the language runtime Dahl needed to build out an event-driven framework.
But Hughes-Croucher calls the creation of Node.js a perfect-storm situation. He said that the release of V8 was only half of the recipe for success. The other half came from the fact that JavaScript was essentially devoid of server-side code. Dahl would have to write the code for handling essentials like TCP/IP and file access.
“He was in a position where he could design all this from scratch,” said Hughes-Croucher. “His intro to JavaScript was this combination of having access to V8, but also the fact that he wanted a clean slate to write this on.”
Since its release in 2010, Node.js has grown in fashion among the startups in Silicon Valley. Popular developer link site Hacker News showed a steady increase in links related to Node.js since its release, and it is now as popular as JSON among posters to the site.
Hughes-Croucher said that Node.js has a bright future ahead of it, as well. That future will soon include Windows.
“The big project we have now is Windows support. This is a big topic. We’re extremely keen on having Windows support. We feel really strongly about this,” he said.
“If you look at programming languages, there really aren’t any that have good support across Windows and Unix. There are things like Python and PHP that run on Windows, but they don’t have the performance, and they have all these Unix conventions that are so fundamental to the language, but people don’t use them in Windows.
“We think JavaScript is universal. We want to make it possible for people to write platform-agnostic programs in JavaScript,” said Hughes-Croucher.