Everything is a Nail

Lately I've been doing a lot of work with Node.js for Rest Devices. I first got started working with Node when I was doing an internship at Cool Earth Solar, and have been dabbling with it since then. For some reason, I never really picked up Ruby, and the Express framework really suits me.

If you haven't worked with Node before, the entire platform is asynchronous (which takes some getting used to), and it's fairly low level. It's absolutely phenomenal for building low level communication protocols, and it can do some crazy things in just a few lines of code (e.g. create your own internet radio station).

In my own personal work, I recently built an email handling system that allows emails to be routed, and then responded to over SMTP. This system allows people to have much simpler transactional email systems than are currently used, and is no more difficult to set up than a simple web server. It's yet to be production tested, but I'm very confident that it'll be able to handle a decent load of emails without much work.

In addition, at Rest Devices, the entire communications layer between our WiFi base station and our servers is over UDP. Using Node, I can re-use all of the same model and database connection code, while working in the binary land of our protocol. This makes developing the two sides of the server much, much simpler.

Basically, Node has been an absolute pleasure to work with, and I've found myself turning to it more and more often.

However, I've been worried that lately I'm starting to try to shoehorn Node into every project in front of me. Node.js is the hammer, and every project is turning into a nail.

For example, at Rest Devices, we have a series of algorithms that need to be run in order to provide alerts for parents. These algorithms need to be run in series, and are fairly CPU intensive. They run in their own thread, completely isolated from either exposed piece of the server, but they have to interact with the same data, and the same models.

If I use Node to implement the algorithms, I get to reuse all of the work that goes into the current models, making the whole process a little bit quicker and easier (not to mention easier to maintain). However, Node really shines because it's a single-threaded async platform. It wasn't built for running a series of synchronous calculations. While it can be shoehorned into the application (we made it work in previous versions), we might just be better off working in another language.

The biggest drawback of introducing a new language into the mix, is that now we have to support more environments. If we use Python, we have to make sure that we have the correct packages installed (and so far, pip just doesn't compare to npm), and we have a whole other set of dependencies to check (many of which will be effectively duplicates of functionality between Node and Python).

In all likelihood, we will end up using Node along with something like Step to speed up our development (reducing the volume of code), until we have time to re-implement the algorithms in another language.

Maybe this is a case of cogito ergo sum, where if I'm at least considering the different options, I'm not completely blind (yet!).