Single-core eaten up
Sutter firmly believes that C++ must go concurrent, as the free lunch of single-core is over.
Sutter says that now is the time to establish concurrency in the standard, to make sure C++ runs efficiently and consistently everywhere. "You can [do], and people have done, just about anything in C++. The question in the standard is: 'What are you able to do that's portable?'" he says.
"The question is how have [data center and web] environments become standardized and formalized that it's time to standardize one common way of speaking to them and express those programs. Have things quieted down enough that now is the time to say: 'Here is the way'?"
The memory model means that C++ code now has a standardized library to call regardless of who made the compiler and on what platform it's running. There's a standard way to control how different threads talk to the processor's memory.
"When you are talking about splitting [code] across different cores that's in the standard, we are talking about the memory model. We are going to optimize it without breaking the following assumptions people are going to make in the code," Sutter said.
It's a small world, and more of it
Those assumptions? "It's a contact between the programmer and the optimizer of the system, to run across cores and different memories as long as we make the following assumptions the programmer makes," he says, "and on the programmer side, as long as he uses features in the right places, he's guaranteed not to tell the difference that the optimization has not changed the meaning of the program. That's what you need to have a usable programming language and still be fast and optimize."
Multi-core comes in chips, big and small, and is starting to make inroads into smartphones and tablets for the mainstream consumer. The iPad 2 in March was the first iOS device to use a multi-core processor – the dual-core 1GHz Apple A5. For systems built on Android – the fastest growing smartphone operating system, according to analysts – Texas Instruments, Qualcomm, and Motorola have gone dual-core, as well.
One factor that's helped C++ is its performance: as a native language, C++ talks to the CPU without going through an interpreter, unlike Java or even Microsoft's .NET, so it's generally considered fast – and performance is vital on devices such as tablets and smartphones.
According to Google, C++ is the fastest runtime language when compared to Java, Scala, and Go, although it does require more extensive tuning and more expertise to achieve such results.
No guns, knives, or clubs: Gosling's take on C++ versus Java
The rise in mobile devices means new opportunities for the new C++. For example, Google introduced the Android Native Development Kit (NDK) for use with the SDK to build "performance-critical portions of your apps in native code" – meaning C and C++.
An NDK update introduced in March 2010 supports OpenGL ES 2.0 and 3D elements, meaning Google threw open graphics for things like games to native C++. Apple's iOS for the iPhone and iPad, meanwhile, runs Objective C in addition to C++ and C.
According to Sutter, the combination of multi-core and native code like C++ will let devs squeeze the most out of the next generation of hand-held devices. "Managed languages like Java and .Net are still great, but the performance you give up when you use them is more important," he says. "Look at smartphones – almost every first release says 'managed only', but version two says 'native is important'. We want to wring the performance out of them."
The language may be fast, but the discussions that created the new C++ haven't been. Work on C++0x began in 2003, and took eight years to complete. You might ask how the standard can be relevant for both web-scale operations such as Facebook and palm-sized multi-function computing such as the iPhone, seeing as how work began on C++0x a year before the first Facebook page and four years before Jobs & Co. birthed the first iPhone.
Sutter answers that doubt by saying that the changes in C++0x are timeless, and part of an evolution affecting all languages, not just C++. "A lot of these [changes] are related to things that aren't moving targets," he says. "The 2003 proposals have been, and will be, useful for another 20 years."
He also reckons that the new C++ is ahead of the game because today's generation of C++ compilers lack the features needed to thoroughly milk what's in the new spec. In many ways this is a repeat of what happened when the standard was set in 1998. "We did nothing in the language to let compliers catch up, because [C++ in 1998] was ahead of where most compilers were. In 2003 we started again. Eight years later, we have a standard that most compliers don't support yet, but it's much closer," he says.
That said, Sutter believes that the version of the spec that will come after the one published this summer will be delivered more quickly. There won't be a quiet period of several years, he promises, saying that those attending the final C++0x meeting in March have begun pushing to start work on the next version.
"It'll be sooner rather than later," he says a little enigmatically.
Quicker, cleaner, Java-ier
And there could be more features from the world of Java added. Sutter expects garbage collection to be proposed – it was dropped from C++0x due to a lack of time. The Java Virtual Machine has had garbage collection for years. C++ fans can be touchy on this subject, saying there are lots of different ways to do garbage collection – but that's the problem.
In Sutter's world, the time has come to update the official standard to make sure that C++ software runs as efficiently as possible and in the same way on different platforms and chips. With a fresh proliferation of smartphones and tablets running a new wave of operating systems and chips on different form factors, that focus would seem to be right.
Interestingly, C++ was ratified as an ISO standard just as Java failed to get ISO pick-up after a campaign by Sun. Sun came up with the Java Community Process (JCP), to police compatibility as a step towards realizing the dream of "write once, run anywhere".
"C++ has for 13 years been an ISO and ANSI standard language – that defined the portable part," Sutter says. "Now it's time to extend that. ... You wouldn't add to the standard to extend it further if the language isn't used. That's the only reason you wouldn't want to make it stronger."
But as we know, C++ is far from unused. The world is programmed on it. ®