The Register® — Biting the hand that feeds IT

Feeds

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

Cancer or performance buster?

Agentless Backup is Not a Myth

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. ®

Regcast training : Hyper-V 3.0, VM high availability and disaster recovery

Huh?!?

I didn't down-vote you, and I'm in what follows I'm using "you" in a general sense.

You're doing what Microsoft have been doing for years - you're relying on tools to insulate your organisation or yourself from shit programming practices.

The implications (security, robustness, performance, scalability, maintainability) of Node are anecdotal and yet to be fully understood. A 20-something pimply-faced kid will make an architectural decision (to use Node) purely because he's teh hackerz and knowz teh JavaScript.

A better approach, and one I push for pretty strongly at work, is to educate teh hackerz. Topics range from authentication and authorisation to configuration management, DR and monitoring.

Node works well if you're working out of your garage, writing a web support page for a fart app in iTunes. But if you're dealing with user data, financial data or anything business critical It. Just. Doesn't. Cut. It.

13
0
Anonymous Coward

Re: I guess common grounds would be Lazarus

Christian,

My last company and my current company are both completely C++ shops. Each of them had at least 10 people who can code C++ extremely well for extremely stable application. One was producing shrink wrap software that we couldn't afford to have crash or be packed full of vulnerabilities. The second produces realtime (not hard realtime) software that processes ridiculous amounts of data. Neither organisation could have produced the same thing in a garbage collected language for performance reasons.

With every language it is a case of picking the correct tool for the correct job. C++ is there when you want blinding speed in an object oriented package, and don't mind paying additional development costs to get it (C++ has longer development times than the garbage collected languages - both from compile times, also from the additional checking for memory leaks or corruption that you have to do, and from the simple fact that the language is more complex).

I'm happy to use garbage collected languages or dynamically typed scripting languages when the time is right for them.

By the way, copy on write is not a panacea. In fact in multi-threaded applications, the additional overhead of reference counting (even with compare and swap) can be huge. For blinding speed, I like the fact that I have choice about what string library to use. I can use a copy on write library, I can use a hybrid library (example one which has a small stack based buffer for strings which are deep copied around, and a pointer to a copy on write string), I can use a copy always library, or I can use an explicit deep copy based library. I can even come up with additional stuff as and when I need it. Of course, in 90%+ of applications built around the world, and default will be fine, and that is why Java, C#, Javascript, Perl etc. are so popular.

11
0
Anonymous Coward

Horses for courses

@Christian Berger: "C++ has the huge problem that a) It doesn't even try to prevent you from shooting yourself into the foot and b) that there are only few people who are able to write C++ code without shooting themselves into the foot."

Why does every, single article about C++ attract a gaggle of "ooohh, C++ might blow your foot off" comments? You've mentioned 'shooting', so lets rephrase this as if we were actually talking about a gun:

"A gun has the huge problem that a) It doesn't even try to prevent you from shooting yourself into the foot and b) that there are only few people who are able to fire a gun without shooting themselves into the foot."

Now, how clever does that sound? C++ can be like a gun - they are both powerful and can be disastrously misused in the hands of someone untrained, inexperienced, or unbalanced. But they both have essential roles in the hands of trained, licensed professionals. And clearly, point B is false. There are literally thousands of professionals around the world who use C++ to great effect in "real-life conditions". And it's nice to occasionally see articles covering developments that concern the language. If you aren't one of those people, feel free to ignore the articles and - above all - don't even look at the comments, let alone contribute.

9
1

More from The Register

Bjarne Again: Hallelujah for C++
Plus: Now officially OK to admit you never used STL algorithms
Interwebs taunt Sir Jony over Apple eye candy makeover
Hey Ive, Ive... add more unicorns, willya?
SCO vs. IBM battle resumes over ownership of Unix
Zombie lawsuit back and wants to suck the brains out of Linux
Apple: iOS7 dayglo Barbie makeover is UNFINISHED - report
Plus: You don't like the icons? Blame marketing
Red Hat to ditch MySQL for MariaDB in RHEL 7
So long, Oracle! Don't let the door hit you on the way out
Shy? Socially inadequate? Fiddling with your phone could help
App 'tells the brutal truth' about social inadequates' chatup lines
Java EE 7 melds HTML5 with enterprise apps
New release arrives with GlassFish, NetBeans support
 breaking news
'Office Facebook' firm Tibbr wants you to PAY for mobe-meetings app
Great idea. Punters won't cough for it though
 breaking news
The only Waze is Google: Ad giant tipped to gobble map app 'for $1.3bn'
Pac-Man-satnav-ish upstart in bidding war with Apple, Facebook
 breaking news
PM Cameron calls for modern, programmable computers! (We think)
IT education musings to G8 chiefs to mystify IT industry