Having been in the Node community for about 2 months now it’s very clear that 99% of users of node are using it to build some sort of web site or framework. This is obviously one of Node’s strong points, due to the stellar HTTP support built into the API.

But I’m not a web guy. I haven’t done much coding for the web in the last 10 years (what I have done is small UIs for our anti-spam systems at work). And back then using Javascript was considered a no-go area, and so prior to getting into Node I hadn’t done any Javascript coding beyond cut-and-paste into some little web pages.

So then I built Haraka, a very capable SMTP server written in Node that uses plugins for all of its functionality. Those who have used Qpsmtpd or Lamson will find this concept familiar. The key idea with these is to be a front-end to an email delivery system such as Postfix or Qmail, and provide easier configuration and hackability in a much easier to code language.

Node’s strong point is network servers. Unfortunately that does mean it’s weak point is command line tools. There’s no “getoptions” parsing provided in the Node API which is a big downer, and furthermore there’s the fact that a number of libraries use console.log() for debug information, which by default on Node goes to stdout, which is bad if you’re piping tools together and you get unexpected output on stdout. There’s been various discussions recently about this on the mailing list. My basic feeling on this is that libraries should do no logging by default, but have a way to turn debugging on, and that should go to stderr (probably via util.debug()). If you find any libraries that don’t do this then patch them.

There’s another problem I’m coming across just now – there’s no fsync exposed in Node. There’s callbacks to write() which get called “when your data is written” according to the docs, but I’m pretty sure that just means it’s in the hardware buffers, not synced to disk. There’s a callback to close() which *might* be enough, but I remain unconvinced. This stuff is important when writing an SMTP server as you can’t return “250 Queued” to the sender until you can guarantee that the data is on the disk.

I guess overall this post was meant as a callout to anyone looking at writing network-y type stuff regardless of whether that’s for the web or not. Node.js is great for writing web stuff, but it’s also pretty damn good at writing non-web stuff too. More importantly it’s really fast for a dynamic language. Current benchmarks seem to show it is second only to Lua (with JIT) (and maybe PyPy, but that only seems faster in microbenchmarks). But nobody seems to write anything major with Lua, apart from using it as a language to embed in some application.