Recently at work I got involved in a somewhat lengthy (and at times a little heated) discussion about the efficacy of Node.js being introduced into our stack.
Naturally, for the next iteration of the web side of the application, a completely from-scratch rewrite using Node.js makes the most sense, right? Of course it does. At least, that’s the argument I lost. But I’m not bitter.
But! I’m an adult, and so I’m aware that I either do my job or find a new one. I think the AR15 platform is a piece of shit but I didn’t really waste any time yelling at the Marine Corps that there’s lots of better ways to kill bad guys, I just did my best to keep mine clean and my proficiency at peak. (Also, we’re talking about a prototype here; we have nothing to lose and everything to gain. If it doesn’t work, no problem, we have other directions to go. If it does work, our application is that much better.)
So to prepare for the clusterfuck^Wgreat leap forward in our application, I’ve been spending some quality time with Node.js. The original Node.js rant, “Node.js is cancer”, is no longer on the web, sadly. You can find other rants elsewhere; my current favorite are on Youtube, here and here. (“You may recall sequential code; that’s the code you can read.”)
I’ve found a few things about Node that I really like, though. It’s not all cancer.
Fun Thing The First: Modules Are Pretty Great
I really, really don’t miss modeling everything as a class. Maybe I’m just bored of OO, but organizing code by gross function feels much more natural and easy these days. I’m sure over the long run it’ll lead to tears but right now it’s very pleasant to work with.
Fun Thing The Second: The Real Deal On One True Platform
One of the holy grails of web work is that you can do all your real work in one platform. For most of history, people talked about the “web stack”. Oh, it was a stack alright; a stack of fecal matter. It was perfectly reasonable to have in one medium-sized web application a set of technologies like:
- Some sort of scripting language (Perl, Python, PHP, Ruby) for core logic
- Shell scripts
- Probably another scripting language – perhaps 2 or more – driving all the tangential parts (sysadmin, deployment, back-end services, etc etc)
- And if you’re lucky, something compiled, like a C library/extension for one or more of your scripting languages
I’ve seen people suffer from horrible task switching: one time a coworker spent over an hour typing what amounted to Perl into a PHP file, because he’d spent the first part of the day fixing a perl script. He went right into the next task and his brain didn’t come along. We’ve all done it.
I’m pretty sure Node.js comes very close to fixing this. Throw in a NoSQL database and you don’t even need to worry about SQL! The worst case is the odd shell script here and there.
JSLint provides a fully automated dunce-cap to keep the stupid down
Thanks to jslint you can pretty much punch anyone in the neck who tries to do something really stupid. If you are some sort of “all Node.js, all the time” and your code doesn’t at least mostly clear a reasonable set of jslint settings, congrats! You’re awful.
It’s not cancer but I’m pretty sure it’s a lot like having food poisoning
I’m immensely frustrated with Node.js. To name but one example, everyone insists on making everything a motherfucking EventEmitter despite Node.js shipping with fully synchronous functions. Yes, the core library ships with not even remotely asynchronous functions. Why? I don’t know, maybe the core team realized sometimes it’s just easier. This logic never filtered out to the great npm-famous masses, so every time I grab a simple library for doing anything, I’m on column 120 before I get to the heart of the matter.
Moreover, I feel like I’ve been sold a bill of goods when I see 3/4 of the README dedicated to hooking up the application to memcached and Redis. Node.js is scalable, please pay no attention to the 40 proxies, key-value caches, and other doodads actually keeping the application running.
But whatever. At the end of the day, every large web application requires all that stuff anyway so perhaps building it in from the start to serve the 5 people using your application is actually the right choice.
So no, it’s not cancer, but it gives me a lot of occasional irregularity.
 Haha, I’m lying, I’m insanely bitter.
 I imagine code reviews thus: “What the hell is this code doing here?” “Because fuck you, I was in a hurry.”