Archive for category Server

Node.NET: Running Node on Windows via .NET

Node eventually wants to support all POSIX operating systems (including Windows with MinGW) but at the moment it is only being tested on Linux, Macintosh, and Solaris.

At the Node.js meetup in Palo Alto, someone asked about running node on Windows, and the answer wasn't pretty yet. You can probably hack it together, and it is coming, but today? Painful. It hasn't seemed to be a huge issue though ;)

However, if you are interested in running Node on Windows, and the idea of this excites you:

C:\> node.exe server.js

... then you can thank Dan Newcome for creating Node.net which gives ya:

  • Same theory of operation as Node.js (single threaded eventing front-end, non-blocking IO back-end)
  • API compatibility with Node.js
  • Written entirely in Javascript (JScript.NET)
  • Runs on the .NET runtime

EtherPad Goes Open Source

Following their recent acquisition by Google, AppJet announced they would open source EtherPad, the collaborative, real-time, notepad. That’s now done, and you can find the project home at – surprise, surprise – Google Code.

Checkout Instructions

Browse the Source

What’s especially cool about this is that Etherpad is Javascript on both sides of the wire. In a new ReadWriteWeb article on Server-Side Javascript, I wrote that EtherPad is probably the most popular site powered by Javascript (anyone want to up the ante?). As server-side Javascript is getting interesting again, with Comet a major driver, it’s a big deal that we now have the entire source tree for a Comet-style, server-side Javascript, application that’s been proven in the real world.

AppJet also released appjet.jar when they discontinued the general server-side Javascript platform earlier this year. Unfortunately, the download link is broken on AppJet.com, so I don’t know if there’s any way to get hold of the official version. It does, however, live on as a cloud-hosted offering at JGate.

Node and Djangode Follow-Up

Simon Willison's Talk last week on Node generated a healthy dose of post-conference buzz, and he's followed up with a blog post on Node and his higher-level API for Node, Djangode.

Node’s core APIs are pretty low level—it has HTTP client and server libraries, DNS handling, asynchronous file I/O etc, but it doesn’t give you much in the way of high level web framework APIs. Unsurprisingly, this has lead to a cambrian explosion of lightweight web frameworks based on top of Node—the projects using node page lists a bunch of them. Rolling a framework is a great way of learning a low-level API, so I’ve thrown together my own—djangode—which brings Django’s regex-based URL handling to Node along with a few handy utility functions.

JAVASCRIPT:
  1.  
  2. var dj = require('./djangode');
  3.  
  4. var app = dj.makeApp([
  5.   ['^/$', function(req, res) {
  6.     dj.respond(res, 'Homepage');
  7.   }],
  8.   ['^/other$', function(req, res) {
  9.     dj.respond(res, 'Other page');
  10.   }],
  11.   ['^/page/(\\d+)$', function(req, res, page) {
  12.     dj.respond(res, 'Page ' + page);
  13.   }]
  14. ]);
  15. dj.serve(app, 8008);
  16.  

Pretty simple, and gets a whole lot more interesting when he shows how to build a simple Comet server with this API. He also covers database access, where there's a good fit between server-side Javascript and the NOSQL servers that speak HTTP and JSON.

His article also provides a nice overview of Node itself, along with some straightforward install instructions.

At first glance, Node looks like yet another take on the idea of server-side JavaScript, but it’s a lot more interesting than that. It builds on JavaScript’s excellent support for event-based programming and uses it to create something that truly plays to the strengths of the language.

Node describes itself as “evented I/O for V8 javascript”. It’s a toolkit for writing extremely high performance non-blocking event driven network servers in JavaScript. Think similar to Twisted or EventMachine but for JavaScript instead of Python or Ruby.

Full Frontal ‘09: Simon Willison on Server-Side Javascript and Node.js

Simon Willison snuck in a last-minute topic change, and is now going to give the server-side Javascript talk.

The news of the past 24 hours is ChromeOS. For the first time in years, someone's re-thinking how an OS should work. With Chrome, you turn on your computer and you're in the browser. What's really interesting is to contrast it to the introduction of the iPhone, where Apple's apps used native APIs while they expected developers to write web apps running in the browser with limited abilities. Here, Google's apps are using the same web platform...it's a level playing field.

Javascript combined with JSONP makes it real easy to write quick and dirty apps. An example of a quick app is Tweetersation Simon wrote with Natalie Downe. Simple app, 200 lines, written in an afternoon. At a larger system level, there's Google Moderator, which is essentially a pure-Javascript solution with a no-op in the noscript tag.

These pure Javascript apps are great for experimenting and prototyping. The problem with this style of development, though, is you're completely breaking web standards. The web Simon "felll in love with" is one where you point to a URL and you get content coming back.

With server-side Javascript, we can get the benefits of the things we like about Javascript, but without throwing away with the things we like about the web. Simon has been playing with node.js, and evidently the results were important enough to throw out the old talk and make this new one.

Take a step back and look at the interaction patterns with a web server. The conventional model is straightforward request-response, where the server tries to respond and disconnect as quickly as possible. But ... there's also the event loop model. As in Comet; it's generally considered to be more efficient, so why do web developers avoid it? Simon says traditional server-side languages aren't designed to deal with event-driven programming. It's more like "do A, do B, do C, exit". Javascript, on the other hand, is well suited to do callback-driven event programming.

Brave Simon now proceeds to live code with node.js. He shows a "Hello World" daemon, where the code looks like Ajax in reverse, and runs extremely fast. But where it gets really interesting - and useful - is with Comet. Another demo. The code is tiny and the benchmark looks good.

Simon's built his own framework on top of node.js: Djangode takes the best features from Django and sticks them on the server.

JAVASCRIPT:
  1.  
  2. var dj = require('./djangode');
  3. dj.serve(dj.makeApp([
  4.     ['^/$', function(req, res) {        dj.respond(res, '<h1>Homepage</h1>');    }],    ['^/other$', function(req, res) {
  5.         dj.respond(res, '<h1>Other page</h1>');
  6.     }],
  7.     ['^/page/(\\d+)$', function(req, res, page) {
  8.         dj.respond(res, '<h1>Page ' + page + '</h1>');
  9.     }]
  10. ]), 8008); // Serves on port 8008
  11.  

The more interesting example is Comet, which he's demo'd here.

Moving on to persistence, there's the NOSQL trend of the past 18 months, and he shows how simple it is to write CouchDB queries from node. It's easy to talk to CouchDB from Node.js apps. Redis is another interesting database, which could lead to pages being rendered very quickly, given its performance benchmarks.