Feeds

Node.js Native breakthrough: cloudy C++ on steroids

Cancer or performance buster?

Build a business case: developing custom apps

Cancer or not, Node.js is attracting plenty of interest, and just like smoking cigarettes at school Node.js is seen as the cool thing to do.

Started by Ryan Dahl in 2009, this server-side scripting environment has in less than three years attracted enough coverage to persuade Microsoft, the world's largest software company, that Node.js is worth fine tuning for Windows and its anti-Amazon Azure cloud to win developer converts.

Some say Node.js is the new Ruby on Rails; this may, or may not, be a flattering comparison given the steam seems to have escaped from that particular engine and attentions have moved elsewhere as you don't hear so much about RoR today as a few years back.

Also, the numbers for this proclamation of popularity are suspicious: these smelly, Alexa-style market statistics are based on GitHub commits and conversations on Twitter. Tim O'Reilly once made similar assertions about RoR based on sales of books by his company about the language.

The allure of Node.js is undeniable: it harnesses server strength to the flexibility of JavaScript - all on Google's V8 JS execution engine. This is exciting as JavaScript applications increase in scale and complexity.

But here's a question: Node.js is written in C/C++ and Javascript - so what happens if you strip out the JS and keep the C++, which is already known for its blazing fast performance once compiled?

That's what programmer Daniel Kang from South Korea is attempting, with a project porting Node.js to latest update of the language - C++11 - published last year. The project is called Node.js Native.

"I thought this was the time for us to go back to native languages for cloud computing," he told The Reg during a call from his home in the peninsula republic.

Kang's port doesn't just remove the JavaScript bits, it also turfs out the V8 engine that was injected by Dahl. The port would be straight C++ (Node) on C++ (application) action with the intermediary layers stripped away.

Scream if you want to go faster

According to Kang, Node.js performance is fast enough for most projects on the client and server, but he's started to see more that are straining the environment. He said: "I saw interesting projects [on GitHub] using Node.js and they required more performance on their operations."

He cites the example of one backend system under development to collect .dat image file information from Microsoft's Kinect Xbox controller to redirect that to other services.

"Because it's not a frontend service it requires some very complicated operations and instructions. In such cases we need to use C++ as the frontend language", he said. "If I put C++ on top of that, we don't have any middleware or abstraction layers. We are just talking between two interpretive systems."

Why C++ is doubleplusgood

Invented by Bjarne Stroustrup more than 30 years ago, C++ is a statically typed language that delivers fast performance partly because it can be compiled into native instructions the processor can execute directly, rather than interpreting it at runtime - as happens with dynamic languages like Javascript.

C++ is so compelling that much of the world's most popular software still uses it - OS X, Facebook, Chrome, MapReduce, Windows 7, Firefox and MySQL to name just a few.

Kang reckoned a port to native C++ is more than 80 per cent faster than "conventional" Node.js, according to a highly unofficial "hello world" benchmark here.

Like many attracted to the original Node.js, Kang likes the non-blocking architecture; this is something that supposedly can handle thousands of concurrent user connections without the application slowing down while it waits for requests to be processed. Node.js does this because it combines all user requests as a single thread but offloads I/O operations that can slow things down for things such as disk or database operations from that main thread.

Kang picked C++ for porting because it's already his main programming language, and reckons he's not "naturally a Node.js developer" because most of his JavaScript experience is on the client side on AJAX.

"I'd tried different frameworks - AppEngine, Jungle, Flask and finally Node... but when I first saw Node I thought this is a very real thing - it was the simplicity and performance that attracted me," he said.

The port was only made possible thanks to C++11, according to Kang. Completed last year, and the first major revision to the language since 1998, C++11 was designed to make it more suited to distributed computing using CPUs with multiple cores.

C++ introduced a standardized memory model that means C++ developers no longer have to build or pick their own libraries to achieve concurrency in C++ applications. A standard memory model means greater consistency in the way apps are built when running on multi-core processors that power servers found in cloud data centres.

Other changes saw features such as lambda expressions introduced to help make coding in C++ a lot easier. C++11 "completely changed the former standard" Kang reckoned.

Kang, currently moving to start a coding job in Silicon Valley, started Node.js Native just three weeks ago. While it's a very preliminary stage, and despite his move, he promised: "I'm focused on the project." Challenges remain, though. The goal is for a first release in a month or two.

Whether Node.js means cancer is coming to C++ is unclear: the internet is littered with plenty of the latest hot framework or new programming language from either individuals or small teams of devs, which either lose the backing of the participants or that forever ride the narrow end of the "long tail". What ever happens with Node.js Native, you can keep track of the project, and potentially contribute, here. ®

Gartner critical capabilities for enterprise endpoint backup

More from The Register

next story
Why has the web gone to hell? Market chaos and HUMAN NATURE
Tim Berners-Lee isn't happy, but we should be
Microsoft boots 1,500 dodgy apps from the Windows Store
DEVELOPERS! DEVELOPERS! DEVELOPERS! Naughty, misleading developers!
'Stop dissing Google or quit': OK, I quit, says Code Club co-founder
And now a message from our sponsors: 'STFU or else'
Apple promises to lift Curse of the Drained iPhone 5 Battery
Have you tried turning it off and...? Never mind, here's a replacement
Linux turns 23 and Linus Torvalds celebrates as only he can
No, not with swearing, but by controlling the release cycle
Scratched PC-dispatch patch patched, hatched in batch rematch
Windows security update fixed after triggering blue screens (and screams) of death
This is how I set about making a fortune with my own startup
Would you leave your well-paid job to chase your dream?
prev story

Whitepapers

Top 10 endpoint backup mistakes
Avoid the ten endpoint backup mistakes to ensure that your critical corporate data is protected and end user productivity is improved.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Backing up distributed data
Eliminating the redundant use of bandwidth and storage capacity and application consolidation in the modern data center.
The essential guide to IT transformation
ServiceNow discusses three IT transformations that can help CIOs automate IT services to transform IT and the enterprise
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.