In response to a question from a friend on Twitter (Private account so no linky), but with the text:
"Been reading up a little bit on node.js @robashton @domgreen. What makes it stand out from alternatives or is it just a JS 'me too' play?"
My initial response was, hey - you know what? I can't think of any (popular) alternatives that provide the unique combination that node.js does, and then started writing a torrent of tweets describing why I personally am so excited about node.
Then I decided that rather than spam Twitter, I should write a blog post to link to when asked the same question in the future.
Think about this for a second - it's really not just a gimmick (although some people seem to think it is). Even in a simple web application you're going to have validation logic that you're going to want to execute on the client AND on the server, and usually this can't be shared without going through some sort of rules engine or crazy framework to spit out some rough client-side equivalents.
No need with node, you can write your model (complete with business rules, etc), and write a nice task-based user interface around that model, running it all locally in the browser, and then dispatching and validating the commands on the server - because hey, everything is just JSON at the end of the day, and everything you're writing works against that.
Take this a step further, and consider that we have some pretty awesome document databases on the scene at the moment whose primary communication and storage mechanism is - guess what? JSON (well BSON) - at no point during any of this do you need to sit there dealing with mapping frameworks or hand-written mapping code, because you're just flinging JSON around.
Now, in the browser these long-running requests are limited to... well HTTP calls to the server to get/post data, but on the server we do nearly everything like this; requests to other machines, requests to the file system etc.
We don't need any crazy language keywords (looking at you C#), we don't need any crazy Task of X/Y and Z objects (Looking at you C#), we just need:
This gives us some brilliant performance benefits, dealing with potentially gazillions of connected clients an easy possibility Sorry for a "the register" link this early in the morning, it's a bit indecent of me.
This also makes dealing with concurrency (at least within a single process) really easy too, all your variables are safe to be accessed at any time as you haven't got any potential race conditions, you can mutate state all you want and not worry that somebody else is going to come along and take away your cheese.
Hell, even the plans for future-node seem to be keeping this philosophy intact, with multiple node processes being given a way to communicate safely (or at least as far as I understand the slides that I've read from conferences I wasn't at).3) Awesome package management!
Just like Ruby, and just like Linux-land in general, if you want to do something there is probably a library/package waiting for you to pull down and consume, and you can do this via the wonderful magic of NPM
npm install socket.io
It's that easy to get the libraries you need, and there are libraries available for most of the things you can think of, the primary ones I am using myself are:
This isn't anything particularly unique to node, but in this day and age it's a bit hard to be taken seriously without a good package manager in your ecosystem and it's good to see something of quality here.4) Community community community
The community around node.js is brilliantly active, passionate and y'know - generally quite bright - and willing to try new things out (Kinda goes with the territory really)
This, just like Ruby, is a really big draw for those of us from ecosystems which... lack anything of this scale
Having direct access to the HTTP pipeline, and not hiding it behind crazy levels of abstracted framework cruft is a big, big win - and once you start writing code like this you start to wonder where this kind of thing has been all your life.
"I want to do this: " has not once resulted in me banging my head against the constraints and limitations that somebody else has put in my way (supposedly to help me).
My personal website currently runs on pixie dust and grated unicorn horns - I'm pulling in content from my old subtext blog and spitting it out on the front page (with plans to pull in content from CodeBetter and Altdevblogaday too), whilst acting as a reverse proxy for the old site (in very few lines of code).
That's utterly crazy, and I drafted it up in just a few hours of hackity hack hack hacking, with those goals in mind.Anyway...
The beauty of node comes in the combination of these attributes, not just one thing (because none of those things bar point #1 are by themselves particularly new or ground breaking
If you've previously dismissed node as something pointless because you think it brings nothing new to the table compared to your X, Y or Z then I urge you to have another look at it, as The Creators prepare to bring it natively to Windows it's only going to get more popular and you'll want to be involved.
2015 © Rob Ashton. ALL Rights Reserved.