C++ 11 is “far better than previous versions”, says the inventor of the language Bjarne Stroustrup. He was speaking at an online event marking the launch of Embarcadero's C++ Builder XE3, a rapid application tool targeting Windows and Mac OS X.
C++ Builder XE3 is a promising but curious product. Delphi and C++ Builder were successful because the tools offered fast native code performance and high productivity on Windows. Embarcadero is now striving to make them cross-platform tools, via a new framework called FireMonkey that supports Windows and OS X, with iOS and Android promised in 2013. To keep pace with C++ changes, Embarcadero has adopted a new 64-bit compiler front-end for XE3, based on the open source compiler front end Clang.
C++ is an ISO standard, first ratified in 1998 with C++ 11 completed in 2011, but Stroustrup revealed he was initially resistant to standardisation efforts.
“It took some arm-twisting to get me to realise that it was time to start a standards effort," he said. "People pointed out that you couldn’t have a language used by millions controlled by a single guy in a single company. Even if you could trust the guy, you can’t trust the corporation. I was a bit sad, because the things I wanted to do would take years instead of months, because you have to build up consensus, and then you have to wait for five compilers to catch up.
“On the other hand the fundamental argument is correct. If you want something that is really widely used, you need some kind of standard. As languages grow, if they’re owned by a single organisation, sooner or later they start taking on peculiar twists to support that organisation’s business plan. The allies of that corporation are favoured.
“A lot of the languages that are seen as competitors to C++ are owned by a single corporation, but they do tend to fight with all the other corporations, and portability is a really hard thing to achieve. It has always been difficult, but it is not getting any easier, and I think portability across platforms is a very big deal.
“When people get into these stupid language wars like what’s best C++ or Java, I can’t be that rude, since most of the major Java implementations are C++. Same with C#. Same with the browsers and such. It’s a big world and many languages are useful.”
Despite its wide usage, C++ is among the most complex programming languages and hard to learn. Stroustrup says the solution is not to attempt to learn everything, and that C++ 11 is easier than before.
“A lot of people look at C++ and want to understand every dark corner. This is what you do if you want to be a compiler writer, but most people should look at what is the easiest way to write a good solution for their problem," said Stroustrup.
“I try to focus on things that lead to correct programs fairly easily. I emphasise the use of constructors to establish invariance, to acquire resources, destructors for cleaning up, copy operations, and the new [C++ 11] move semantics that allow you to move an object out of one scope and into another one very cheaply," he added.
"One of the things that was limiting C++ 98 [the previous standard] was that you could build really good resource handles - like vector, or istream, or thread - but they are hard to move around because this is computers and everybody knows that you copy things. In the real world you don’t copy things.
"If I lend you my phone, I don’t make a copy of my phone, I move it. We can do the same in C++ now. If I make a 10,000 by 10,000 matrix in a function, I can hand it over to you at the cost of two pointer assignments. We are talking picoseconds. That is a huge difference in the way I can write code today.”
Stroustrup does not favour a "dumbing down" of the language. “People always want to simplify the language to do exactly what they want, but to be part of a huge global and multi-industry community the language has to support things you would never do in your field. I see the language as a general purpose tool, and coding standards as specifying what you can do in a specific domain,” he says.