Wednesday, April 27, 2005 12:26 AM triplez

Comments on the future of C++

C++ creator upbeat on its future
I was just reading this article on the future of C++, about there are as many as 3 million developers using C++. It got me thinking. C++ will always be around. C++ is what I'd call the "low-middle-high" level language, where it covers a wide range of possilities. C++ is a language with limitless potential, and C++ will have to be around to create Java, C#, VB languages, and the .NET Framework.

I asked a question today at the Longhorn presentation @ the Asia MVP Summit, about whether win32 api will still be around in Longhorn, or will it be totally replaced with managed code, aka WinFX. Win32 API is there to stay. Win32 API is based on C/C++, and offers more flexibility and power than the other .NET languages.

I'd like to give a few examples of C++'s limitless potential. Templates are the best thing that ever happened to C++, and the worst (which I won't talk about today).

But first, let me try to explain what Templates and Generics are. I was trying to explain what they are actually all about to some MVPs today @ the summit. Here's my two cents worth. Object Oriented Programming is like an abstraction of data and its behaviors and reuseability, where classes and objects come in play. Templates, or Generics (in .NET sense) Programming, is like an abstraction of those very classes and objects, into a higher level of abstraction, to create behavior and reuseability of those classes themselves. Data has information and behaviour on how to make this information be useful. Classes take these data and abstract and encapsulate them to form something that can put these data behaviors together. Classes have all these behaviors, but templates further abstract all these behaviors to form something that can create different classes out of a "schema", so to say.

Now with that explanation of what Generic Programming is, let me give a few examples of C++'s limitless potential.

Originally, when templates came out, it was really just to do exactly what I just mentioned above. After a few years, someone (I can't remember his name) was researching and playing around with C++ templates, and discovered something called "Meta-Programming". The original ideas for templates have branched out into something different. For those who don't quite understand what meta-programming is, it's actually making use of templates and the compiler to generate numbers (or information) (disclaimer: I didn't really research much on meta-programming) during compile-time. It's actually very useful in the field of mathematics and optimisation where you generate, for example, the answer of cosine 62 degrees during compile-time, and not during run-time, which saves quite a lot of calculation and cpu cycles.

Another example I'd like to point out is Policy-Based Programming. Who'd ever think of that?? But yes, it's also a spin off from templates. It's basically creating a template that accepts policies(which are light-weight classes) to generate a different type of class altogether. It's basically like "Aggregation" of classes. Combining the policy of using malloc to assign your memory instead of new. And you can switch and swap to generate lots of different classes that behave differently just with 1 class, and many small and light-weight classes called policies.

And there are many more examples to explore new ways to doing things on C++. This gives you untapped power for those who knows how to use it, but with power comes great responsibilities. And most people can't handle that kind of responsibilities, thus they get their leg blown off. But that's really the majority of the developers here. That's why Java, C#, VB languages have to exist. These languages are what I'd like to call "logic-abstraction" languages. They basically define what you can and cannot do with the language, which restricts any potential in growing the language outside the box without modifications to the language itself. It's like a "sandbox" language, where you can't really destroy your entire leg even if you do something wrong.

Productivity wise, I feel that Java, C#, VB, and other similar languages will have to be around. They promote productivity, and do things faster, and neater, and cleaner, and understandable. That's why those languages catch on really well. It takes everything that you don't need to bother, and gives you more time to think about the architecture of the solution.

But C++?? It will be around to create innovation. And it will never die out. It is essential for people to know how to create and make life easier for developers, like creating a RAD-driven programming language like VB. But then again, the implementation of C# in mono has gone into a cyclic compilation stage (I don't quite know what's that exact word they use), which means that they are using their own C# compiler to compile the C# compiler itself. Much like GCC, (4.0 was just released yesterday), where they actually have multiple bootstrapping to create stages of the compiler to compile itself. Confusing? Yeah. :)

But coming back to its future of C++, it's staying for good definitely, but is it actually growing (the language itself)? From what I know, the new specifications for the new standards for C/C++ should be somewhat finalized already. Does anyone know anything about it? I've stopped keeping track of the C++ guys already. They just do things too slowly. That's one of the problems of C/C++ standards. Another problem is adoption of the standards itself. How many compilers do you know that can say they are 100% compliant to the current C++ standards (I think it's the C99 standards, can't remember)? It's been what, 5-6 years already? So how long will the new standards take to get finalized and released, AND get adopted by the industry leaders? Another 5 to 10 years? Come on, technology is moving so much faster than C++ is. Unless they do something about it, C++ is going stale, though it's NOT that bad to go stale, but nevertheless, stale.

Why do I say that it's not bad to go stale? Because stability of the particular "technology" will bring about assurance that today's technology will not become tomorrow's garbage, which is really what's happening now in the industry. Right? Another MVP was telling me today that technology moves so fast, it's difficult to catch up, and recommend the current technologies to their clients. C++ stays the same. Even with the new standards, there isn't many changes to the language itself. The changes are mostly STL changes, to update it. And one of the advantages of C++? It works everywhere, any platform.

So I've written alot already. And now I'll stop.

Filed under: