Feeds

Stroustrup on next-gen C++: I didn't want to let go of my baby

Badly taught, over-used... better than ever

The essential guide to IT transformation

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.

Secure remote control for conventional and virtual desktops

Next page: Fuming frustration

More from The Register

next story
BBC: We're going to slip CODING into kids' TV
Pureed-carrot-in-ice cream C++ surprise
China: You, Microsoft. Office-Windows 'compatibility'. You have 20 days to explain
Told to cough up more details as antitrust probe goes deeper
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

Endpoint data privacy in the cloud is easier than you think
Innovations in encryption and storage resolve issues of data privacy and key requirements for companies to look for in a solution.
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.
Advanced data protection for your virtualized environments
Find a natural fit for optimizing protection for the often resource-constrained data protection process found in virtual environments.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.
Next gen security for virtualised datacentres
Legacy security solutions are inefficient due to the architectural differences between physical and virtual environments.