If there were ever a contest for the sexiest technology, Node.js would no doubt be a contender. Node.js has had my attention for some time, and continually surprises me with how many problems, both big and small, it’s helping me and other technology lovers crush.
What is Node.js
In short, Node.js is server-side JavaScript built around an asynchronous-first API.
Node.js is going through its teenage years, at least in terms of perception of identity. This is one of those technologies that can be difficult to describe adequately due to the number of problems it attempts to solve. The authors of Node.js sum it up pretty well:
Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
That’s a lot to stuff into two sentences, and only begins to touch on the types of problems Node.js is equipped to solve. I’ll attempt to fill in some blanks along the way.
The Cool
Bantamweight
Node.js is like a Heavyweight boxer in a Bantamweight class, with its thin software stack, intended for broad usage across a variety of scenarios. The performance and cost-saving benefits of a light stack are great, but, the generic philosophies position the platform to be consumed in a vast array of problem solving and not pigeon-holed to become a rock star at one thing and lackluster in another.
Node.js loves I/O
While Asynchronous I/O and Parallel processing are most certainly not unique to Node.js, the platform attempts to rethink the practice of solving problems synchronously, one task at a time, and with a surprisingly simple and elegant solution that does not bare the typical complexities that generally accompany parallel processing. Take your typical web application, how many of you PHP or .NETers typically service a single HTTP request with asynchronous tasks to solve for X sooner than otherwise achieved? In the world of Node.js, it’s not only simple to service requests with multiple concurrent I/O (or Parallel Processing) requests, it’s the standard and default practice.
Whether you’re loading files from disk (hopefully, due to cache expiration and not common practice!), or requesting internal or external network resources, why limit your response times to the summation of all combined times? You can just as easily handle all of these tasks concurrently, resulting in the final response being based on your slowest horse. It’s not uncommon to see some complex applications at Go Daddy that must collect dozens of distinct resources (files, database records, etc) before responding to a single request. This is an area where Node.js really shines.
Additionally, a 3rd-party Node module async is a popular choice for performing parallel and series tasks that Node.js does not natively expose quite as elegantly. Oh, the power of the Module Ecosystem.
require(“async”).parallel([
function() { /* do something */ },
function() { /* do something else */ }
], callback);
JavaScript and V8, Yum
This is a love hate topic for many, knowing that Node.js is based on—you guessed it—JavaScript running on V8 (Google V8, the other good stuff), one of the fastest JavaScript VMs around. On the surface, this means making the platform accessible to a very broad audience that may have otherwise ignored it altogether. After all, who doesn’t know enough JavaScript to “get by”? Where JavaScript falters, is when it comes to Processor intensive tasks.
Module Ecosystem
If leveraging one of the most popular languages for our new favorite platform wasn’t cool enough, an incredibly vibrant and freakishly fast growing ecosystem for new public and freely consumable Node.js Modules is available via npm (often known as Node Package Manager, but technically it is not an acronym). For those unfamiliar, npm is nothing more than a way to install (or publish) a Node.js module with a single command-line call, like so:
npm install express
My server now has the latest coolness that is known as express, a nifty framework for building simple or robust web applications.
As with any third-party technology, I encourage you to use caution when consuming npm packages and recommend you carefully evaluate performance and security on a case by case basis as the quality of these packages can vary greatly.
Not so Cool
As with any technology, new or not, it’s not all roses and unicorns.
Processor intensive tasks
Natively, Node.js performs sub-par when compared to the likes of lower-level languages such as C/C++. But, before you drop Node.js for your next super-computing project in favor of spending ten times the cost in developers to build a more performant solution, Node.js has you junkies taken care of as well via Native Modules, otherwise known as Node Addons. However, if you find that a large chunk of your application is very computationally intensive, then Node.js may not be the right tool for you.
API Maturity
If I were to pick one pet peeve about Node.js as a whole, it’d be the fact that they’ve decided to create yet another API from the ground up, which is no small feat, at least when making claims of a platform. Clearly inspired by *nix crowd, with references to entities such as forking and signals (which may be a bit foreign to the Windows crowd), the overall the conventions are pretty accessible due to simple calling conventions and adequate documentation.
As with any 0.x API or framework, you’re either held back by bad decisions made early on or breaking changes as the result of correcting mistakes along the way. Luckily, the authors have made the difficult decision to make the necessary breaking changes along the way to get it right, even if that means some of the burden is felt by its early adopters, though typically in the form of mild signature changes.
Node.js at Go Daddy
As fun as Node.js can be, it’d be short-sighted to consider it simply a toy to play around with. Node.js is solving real and substantive problems, even here at Go Daddy. Powering many utilities, and both internal and public APIs, Node.js has been a welcome addition to our arsenal of technologies. We’ve barely scratched the surface, but our conservative adoption is paying off as we increase our confidence and understanding in this exciting technology.
Ready for the big time?
The simple answer is, yes. However, with any problem, you select the right tool for the job, and however sexy Node.js may be, it is just another tool.
Utilities – Big time
I am sick of writing utilities of all flavors (build processes, deployment, unit test tasks, etc) across multiple platforms using the favorite flavor of the OS, having to remember a language and API unique to each. Actually I’m not, because I will no longer do this, as 100% of all utilities my team and I build are based on Node.js. Powerful platform, accessible language, and feature-complete API are the tools of success when it comes to writing utility software to perform your dozens of common internal tasks. Having to make a code change to a year-old utility that we forgot about has never looked so good.
Web APIs – Awesome
Web APIs are incredibly I/O dependent and rarely CPU bound, and Node.js loves I/O. My only warning would be to use caution with the relatively young Module Ecosystem, as modules for connecting to various data sources (relational sql, nosql, etc) are a mixed bag, depending on the popularity of your data source, with varied stability and performance. Verify your data sources have quality Node.js modules available which are actively maintained, and you’re good to go.
Web Applications – Getting there
Due to the exploding Module Ecosystem, real-world complex web applications are quickly becoming legitimate options under the umbrella of Node.js. Great modules are available, including low-level web servers such as express, and various templating or view rendering engines for those of us that enjoy the likes of Razor views and Embedded JavaScript templating, and so much more. While it’s certainly possible to build robust web applications on Node.js, there’s enough fragmentation in this space to stress caution. I see no reason not to be very optimistic in this space, and even start your next web application on Node.js. But, I recommend careful research and evaluation of your desired technologies before you go too deep down the rabbit hole.
Computationally Heavy Applications – Not so much
Creating applications that require heavy computations is certainly an option with the use of Node.js Addons. But, in general, Node.js may not afford enough luxury to these applications to warrant its use. Don’t get too caught up in the “cool” of Node.js; select the right tool for the given job.
Dive In
Despite my words of caution for our beloved Node.js, now is a great time to get started. Go ahead, dive in, the water is just fine.
Will godaddy have a shared hosting platform with node.js offered? The best computer engineer I know says it is really amazing and opens up a tremendous potential for the future. I am ready to start taking the plunge.
Thanks,
James
ditto
Hey there James,
Sorry for the late reply, missed the email notification. I’m not on the hosting team, so it might be worth while to post an inquiry on our support forums.
http://support.godaddy.com/groups/web-hosting/forum/