Today Node.js is a hot topic. It’s the server side programming environment de rigueur for fast, lightweight development. But that hasn’t always been the case. Node.js inventor Ryan Dahl, saw Node.js as a personal experiment more than anything else. Developers scoffed at the idea of JavaScript, a mostly client-side language, running on the server side.
See also: What You Need To Know About Node.js
But some four years after it first appeared, Node.js is now clearly in the mainstream. Node.js runs JavaScript by leveraging V8, Google’s fast JavaScript engine designed for Chrome. This allows Node.js to create a runtime environment that pushes content and datfrom the server to the client quickly. V8 translates JavaScript into native machine language, instead of working overtime to interpret it as bytecode, giving Node.js its speed. Today, this is what makes Node.js is the darling of the developer world.
As the SVP of Engineering at Joyent, the corporate steward of Node.js, Bryan Cantrill, has had a front row seat for this transformation.
“Two years ago, people would talk about Node.js capabilities by saying, ‘Yes, but it’s not in production,’ ‘Yes, but it hasn’t been proven,’ ‘Yes, but,’” Cantrill said. “Now as more projects built in Node.js are coming out, the skepticism is going away.”
Patching The Gaps In Node.js
Of course, in the early days there was a very practical reason for developers not to implement Node.js—the platform could be infamously difficult to debug in production.
Cantrill is unique because he has an engineering background, not a Web-developer background like most Node.js adopters. He came to Joyent armed with his own creation, an application called DTrace, which diagnoses software bugs in real time.
“It sounds like a low-level detail, but being able to correlate outside activity to what’s going on inside the program, actually allows you to understand the program,” he said.
He and his team set to work integrating Node.js with DTrace for debugging, a technology Joyent still uses to diagnose problems with Node.js today.
In another measure to make deploying Node.js as risk-free as possible, the team worked to resolve memory leaks. In what Cantrill calls a classic development problem, sometimes a Node.js program will use more and more memory while seemingly doing nothing—and at the time, nobody could figure out why.
“Finally, Joyent engineer Dave Pacheco had a big breakthrough that allowed us to look at a core dump—an image of a running process—and determine higher level JavaScript state,” he said. “It could actually tell programmers which JavaScript objects were consuming memory. We use this all the time for debugging and development.”
It’s a big deal of personal importance to Cantrill, formerly of Sun Microsystems, which stewarded the Java language. While employees at Sun argued about whether or not to make Java open source for years, Node.js has been from the start. For the developer who has worked at both companies, he sees it as something of a do-over.
“Node has gone further than Java thanks to the direction we’ve taken it,” he said. “Node.js is more debuggable and more robust on the server side than Java is. Which is amazing since Java had a decade-long head start.”
What’s It Good For?
Node.js’s increasing stability has led to its increasing adoption, spurring its growth for larger and larger projects. Some companies, like communication innovators Speek and Voxer, are built entirely on top of Node.js. And most people would recognize the big names that are currently utilizing it: Walmart, Microsoft, Yahoo, and more.
According to Cantrill, though, it’s not one notable use or one big name that jolted Node.js into the mainstream. Microsoft and Yahoo, he says, had already been using it for years.
“What was the killer app for Java? There wasn’t one. It was more that Java represented a collection of really good ideas, that traveled based on their own merit. People adopted Java for all the right reasons.”
The same goes for Node.js, he said. But it’s also that Node.js is what he calls “general purpose.” While other developers would shy away from championing the framework so strongly, Cantrill says, “if I had to pick one dynamic environment to take with me, I think Node.js would probably be my desert island dynamic language.”
For example: Node.js is especially popular among developers working on Web-based applications, like those for chatting and gaming. But Cantrill’s team actually used Node.js to develop command line tooling.
“I think that might be counterintuitive for some people,” he said. “They ask, ‘Why would you use Node for that?’ Our counter: ‘Because it’s the right tool for the job.’”
“I’ll never say you’ll have a Node.js operating system or Node.js database,” he continued. But it still has a very broad use. For anything that needs to speak HTTP and be web facing, Node.js is going to be on the shortlist.”
But the biggest change in Node.js in three years? Instead of taking Cantrill’s word for it, developers can just find out for themselves, quickly and painlessly.
“The nice thing about Node is that it’s really easy to develop things that are small. It helps people build really easy proofs of concept that would take longer in other environments,” he said. “When it comes to Node.js, people shouldn’t believe what anybody else does with it. They should mess around with it themselves and see if it fits their needs.”
Photo of Bryan Cantrill by Joyent.