Why your next language better be C++
Written by Mike James   
Wednesday, 29 June 2011

C++ has a lot going for it at the moment. Here's a strong case for making it your language of choice.

 

Which computer language you use is a matter of personal choice only up to a point. There are good reasons for choosing a language that go beyond issues of what you prefer to use. At the moment the language landscape is in a process of reshaping that makes it difficult to know where to put your trust.

First of all we have the takeover of Java by Oracle and the instability that followed. While it is unthinkable that Java could disappear from the scene it is worrying that Java isn't open source and isn't free from control by big companies.

Second we have the recent pronouncements and actions of Microsoft seeming to threaten the .NET infrastructure so that languages like C# and the technologies that surround them have been destabilized.

Currently if you are faced with the start of a new project, one that might have a long life span, it is difficult to decide which language to choose.

If you go through the list then there is one language that stands out and the reasons for using it are getting stronger not weaker.

That language is C++ and I am about to tell you the reasons why you should look at it again.

The first reason has been one of the most compelling reasons for using C++ since it was introduced - it's what the systems programmers use.

A firm foundation

If you have a "serious" program to implement, one that has to work with the underlying hardware or work closely with the operating system, then C++ is an obvious choice. Generally operating systems are written in C or C++ and using the language of the OS means you get to work with it and the hardware on an almost equal footing.

The point is that C/C++ is the language that provides the foundations that all the other languages rest on.

In the Windows world the situation is even more polarized. When .NET was introduced it was supposed to be a replacement for the core Windows API which was and still is a set of C language functions packaged into modules called DLLs. Most of the more modern subsystems that had been built to extend Windows used interfaces based on COM and the only language that could use COM in a natively was, and is, C++. Other languages had COM interfaces built to let them play the same game but there was always something that was difficult or impossible to achieve.

So when .NET came along Windows was evolving into  something that was strongly C++ oriented. While application programmers got used to assemblies and manifests, the Windows systems programmers simply ignored everything and carried on using C++ and creating COM interfaces on anything new.

It really did look as if the systems guys didn't care. Look a little closer and you could see that only the language guys were backing C# and .NET. The only major Windows application to use .NET is Visual Studio - the rest stuck with C++ and COM.

It looks as if the war between C++ and C# is over and C++ has won.

I say "looks as if" because there is no final word from Microsoft about what is to happen with WIndow 8 but there has been a lot of activity from the Visual C++ team and even the suggestion that VC++ will be reinvented as WinC++ or something similar.

Whatever eventually happens there is no doubt that at Microsoft C++ is back in fashion and when you look at the alternatives on offer it looks more atractive than ever.

If I was asked to write an advertising poster for C++ it would go something like:

Do you want to write applications that run directly on the CPU without interpreters or VMs getting in the way?

Do you want make use of the operating system interfaces as if you owned them?

Do you want to use a language that isn't going to be crippled by an evil proprietor?

Then you need C++

Modern C++

Outside the Microsoft realm C++ has also just received a boost from the finalization of the C++0x standard which finally drags C++ into the modern era. The new C++ has features such as lambdas, initializer lists, a for each style construct, delegating constructors and so on. It is a big improvement. At the same time that standard C++ is getting a makeover it is being extended into a toolkit for parallel programming. There are C++ frameworks like the Parallel Patterns Library (PPL) and language extension like C++ AMP that make it easier to build reliable parallel programs. After all if you are looking into making use of multiple processors then you must be interested in speed. If you are interested in speed you must put C++ high on your list of possible languages.

It's not alien

The final thing to say about C++ is that it is a lot like Java and it is a lot like C# - because Java and C# were based on C++. What this means is that C++ is easy to learn and you can write it in a style that is Java-like or C#-like. It is a very flexible language that can be used in sophisticated ways but doesn't lose touch with the underlying hardware. Yes C++ does have some elements of the primitive about it - for example no built in garbage collection and the use of non-object primitive data - but this is to the good when you are trying to squeeze the last drop of performance out of the system.

This is the reason why C/C++ make a good choice for mobile systems. Apple has Objective C on iOS and now Google is promoting native C++ code on Android. It's a shame about iOS, so near and yet so far, but this is a closed world with nothing that is non-Apple allowed. It's not as if iOS programmers actually have a choice.

The same sort of return to C++ is happening in the browser with Chrome adding a native code API. Currently this supports C/C++ but promises other native code languages - of course the problem will be finding any!

The reason for this return to native code is efficiency. Long gone are the days when it was possible to say "don't worry about how fast your language runs - next years hardware will make it faster." Hardware speed increases stalled some time ago and now all we have to look forward too is more cores that we really don't know how to make use of. Perhaps C++ solves both the efficiency and the parallelism problem in one language.

 

So the future is clear

    there will be JavaScript in the browser

    and C++ will rule the rest.

Further Reading 

Making sense of Microsoft .NET and HTML5

HTML5 added to Visual Studio by "rogue faction"

Microsoft tells C# developers to learn JavaScript!?

Silverlight out of the MIX spotlight

C++ goes parallel

Modern C++ - a language with a bright future

<ASIN:0132673266>

<ASIN:0672333317>

<ASIN:0071634665>

<ASIN:0321543726>

<ASIN:0201700735>

<ASIN:0123850037>

Last Updated ( Wednesday, 29 June 2011 )