Node.js logo, http://www.nodejs.org

Node.js! Wait, how many modules do I have to choose from?

Michael Diolosa
4 min readMar 18, 2013

Node.js is an absolutely fantastic technology. It's a relatively new framework that allows developers to write applications in JavaScript. It executes incredibly fast because of Google Chrome’s V8 engine, it has a wonderful ecosystem of enthusiastic developers, and it's incredibly easy to install and begin coding for. Unfortunately some of it's strengths are also it's weaknesses, and this is the point of my ramble.

As a note, I come from a varied background of technologies. I've spent a good deal of my professional career working with C, Perl, PHP, Python, Ruby, and C#. Most of my 15 years has been spent building applications both simple and complex with either Ruby on Rails or Microsoft's ASP.NET; both of which benefit from being widely used and very focussed for web application development. If you were building a Rails app you had a pretty well defined structure and set of technologies; and the same goes for ASP.NET, where only recently have you been given a choice between building applications in a Web Forms or MVC style. The same is not true for Node.js.

Modules

Node.js at the moment feels a bit like the wild west, there are, as of this writing, 25,365 modules to choose from in npm, which is it's official package manager. A search for the acronym MVC on the npm website brings up a total of 117 different frameworks; a search for the word testing brings up a total of 250 different frameworks. How are we to choose the right technology for our application with all of these choices? We spend lots of time researching the libraries that are kept up to date, have the most complete feature sets, are most widely used, and are backed by either large companies like Google or have rockstar developers behind them; @tjholowaychuk, I'm looking at you! Where do you find the time for all those contributions?

Languages

Take another step back and try and choose a language, CoffeeScript or JavaScript, or do we dive into something different like ASM.js? For Ruby developers CoffeeScript feels like the right language to choose, but debugging it can be a real chore (though there is a great deal of work going on to make this easier), and what about all those wonderful new projects like Tern that we can't take advantage of? The other argument is that JavaScript is hard to read and understand quickly, and since developers spend more time reading code than writing code shouldn't we use languages that are easier to understand?

Admittedly I think the argument that JavaScript is hard to understand is pure rubbish, it all comes down to how clearly developers organize, write, and comment their code. For example you can write some really unreadable code using CoffeeScript's comprehensions.

Templates

Once you have a language and MVC framework selected What templates should I use? Mustache? Jade? Dust? Or should I use an alternative to those templates like Handlebars or Blade? Heck, Mustache alone has a ridiculous number of alternatives with truly phenomenal names!

Our decision for a templating language was based on our decision for an MVC framework, and I think that's a good way of selecting technologies. Choose the best language that ties in most closely with the tools you are using otherwise you are going to spend a great deal of time integrating technologies when you could better spend that time writing your application.

Style Sheets

Along with templates what style sheet language should I use? LESS? SASS? SCSS? Stylus? This is a bit easier, though I'm not sure for how long. Currently there is no native, viable Node.js support for SASS or SCSS, so to get them working in your stack you must add a dependency of Ruby and potentially a bunch of time integrating. Stylus I don't believe is as widely used as LESS, Bootstrap currently is the most popular GitHub repository and has all of it's styles written in LESS. I think for the time being LESS is a pretty easy and clear choice, but you do miss out on the benefits of SASS/SCSS and Compass.

I'm not proposing any answers to this conundrum, the fact that there are so many ways of slicing an apple in Node.js is what gives it such a vibrant community. I think the point I'm trying to make is that if you choose to develop your application in Node.js, know that you should consider and experiment with a lot of technologies before choosing an application stack you are happy with. If you have a choice between writing your own module or giving back to the community by participating in an open source project, do the latter, you'll feel better about yourself for helping others.

--

--

Michael Diolosa

Crafting artisanal technology with ❤︎ since MCMXCVII.