Meta Broadcast

we write about the things we build and the things we consume

node.js, what for and why?

Node has opinions split. Some believe that because it's JavaScript, by default it's ugly and pointless, others believe it to be the second coming. Here at MetaBroadcast we see it as another tool in our belt!

Liam and I have been using Node for a number of different prototypes over the past 6 months, some of which have been blogged about, that mainly revolve around grabbing data from various APIs (including Atlas), doing some simple manipulation and then firing the results off to a client. Simple stuff that any language could do, so why Node? The answer—why not? It's JavaScript—almost everyone knows JavaScript, it's asynchronous and it is actually quite fast. Sure it's lacking in some areas, but they're well documented by the community, so avoiding the bottlenecks is fairly trivial.

more than just javascript

Node can serve static files, connect to other servers and get data from databases, just like many other languages, however the NPM (Node Package Manager) makes the whole process a lot easier. NPM is a repository of user submitted packages that can easily be included in your Node project. Some packages provide simplified wrappers, others provide specific interfaces for APIs but they all increase the speed at which you can get something up and running, especially considering most only require 'npm install [package]' to be typed into your CLI before they're ready for use.

I can't bring up packages without mentioning the package that made me try Node in the first place—Socket.io is a web socket wrapper that allows you to transfer data through web sockets, or alternative fallbacks for older browsers. We use Socket.io in nearly every project now, as it allows us to make our prototypes a lot more user friendly, giving immediate feedback to interactions and streaming such things as federated search results, as we receive them.

I've recently been working on an Internal Dashboard in Node, showing various statistics in the office. Originally browser based, our dashboard made multiple AJAX API calls to various services like Jira, Git and Twitter, which unsurprisingly was slow. The 'adapters' for these services were written modularly, so when we decided Node would be a better choice, I could copy the modules over with minimum alteration. Much time was saved!

more than just your local web server

Installation locally is a straightforward affair for the most part. If you're on OSX or Windows you get a handy little installer. Linux users should check their package managers. If you can't find a prebuilt package, I'm afraid you're going to have to build it yourself. We use Debian on our production boxes, which doesn't have the latest version prebuilt, so Adam valiantly maintains a build on our AWS backed repository.

Luckily the most recent versions of Node come with NPM built-in. Gone are the days of building both Node and NPM separately.

what works well for us & what doesn't

I could compare Node to Java, or more accurately JavaScript to Java, but the differences are well known and masterfully debated. It's worth noting we're not going to be switching from Java to Node in large scale production services and applications any time soon. Node simply is not mature enough, established enough or predictable enough. That being said, we love the rate of growth Node is experiencing, and the subsequent community, along with the ease of creating powerful websites and user experiences.

What language you code in is inevitably a personal choice and I'm glad that mine is becoming more of a catch-all language. I think JavaScript has legs and it's already proven itself by being in our browsers since forever, so as browsers become even more connected to our servers, using JavaScript on the server side makes a lot of sense.

We'll be writing about Node again, as we use it more and it develops further, documenting things we've learnt and use cases at MetaBroadcast. What do you think of Node? What are the alternatives? We're always looking to try new languages and widen our tool belts.

categories

blog comments powered by Disqus
hiring makers: 8 positions Creative Technologist | Design Ninja | Software Engineer | Systems Engineer >> APPLY NOW
metabroadcast

reading others