Computerworld is undertaking a series of investigations into the most widely-used programming languages. Previously they have spoken to Alfred v. Aho of AWK fame, S. Tucker Taft on the Ada 1995 and 2005 revisions, Microsoft about its server-side script engine ASP, and Chet Ramey about his experience maintaining Bash. In the latest interview Computerworld chats with Bjarne Stroustrup of C++ fame about the design and development of C++, garbage collection and the role of facial hair in successful programming languages.
C++ is so powerful that whole new C++ coding paradigms were discovered years after the language was designed. For example:
http://en.wikipedia.org/wiki/Template_metaprogramming
http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Expression…
Sure, there are many object-oriented languages allowing the same things in theory, but C++ allows that while retaining all the low-level aspects, without any compromise on performance and with a great deal of control of the generated binary code. Very, very few languages even try to do that…
The new coding paradigms such as the two listed above in turn motivated improvements to the core c++ language and the C++09 draft,
http://en.wikipedia.org/wiki/C%2B%2B0x
clearly is designed to ease and improve the implementation of these paradigms.
As to the real-life power of these, my interest in them is that I am writing a math library and that generic programming and expression templates allowed me to reduce the number of loops in the whole library to a handful, while achieving great API expressiveness… and after having reduced the number of loops we were able to add template logic to vectorize/unroll/peel them all, with rather little effort and few lines of code! Clear example of how very-high and very-low programming mix together in c++ to produce high-performance generic code.
The only downside to all this is that it makes the initial learning curve to C++ really steep. But once you become proficient in it, there is no programming language that comes close to providing the balance of expressiveness and performance that C++ does.
What about D?
What about it? My take after writing some trivial stuff to test D a bit: it’s what C++ could have been if it didn’t have to carry backward compatibility with it. The work on pure functions, etc. in D2 is very nice as well.
Of course, C++ has a lot of industry support, and a host of libraries. D does not have that (yet), so it needs more momentum in that respect to be a serious candidate for many projects.
Additionally, I think it is better to wait until D 2.0 is ready, and until the standard library problem is solved (there are two competing libraries, the official Phobos, and Tango). In the meanwhile C++ is doing a terrific job .
What about it?
It has no real standard, its core library appears to be in flux with a major movement rewriting it entirely, it requires you to go through extra steps to integrate with C libraries (and God help you if you need to integrate with one that needs heavy macro usage in your user code)…
D is a neat toy language. End.
You said loops. ๐ You must be a real programmer. Most developers don’t care about complexity. “Why care? Computers are powerful enough today, and I know bubble sort.” is a typical statement.
“C++ is so powerful that whole new C++ coding paradigms were discovered years after the language was designed.”
Is that a feature or a bug ?
๐
More seriously, Template macros are nice, but I still miss plain procedural macros.
Ya know, Lisp…
If C++ wasn’t so much linked with C, the language could have a much saner syntax.
If C++ wasn’t so much linked with C, it would be now completely forgotten.
This is a very good interview; Strousroup has a number of fascinating observations about the development of C++. Something that surprised me is his remark that there was never a big marketing agency behind C++ unlike some other languages.
I’ve tended to avoid C++ for some of the (bad) reasons that he mentions (copy constructors always irritated me, for example) but I have to admit that he’s right about this at least: The alternative is beautiful languages for which you have to rewrite your code every five years. I’ve seen or read of that happening quite a bit over the last decade. I was surprised to read his claim that C++ code he wrote 20 years ago still works today, and should still work in 20 years.
That’s something that the Winforms/WPF/Cocoa crowd will never get. Well written code is code that will get reused for years to come. The code base I’m working on has code that was written in 1985. 23 years baby and that code still works here today and it’s not going to go away anytime soon. The GUI frontend is based on MFC (the new bits are in WTL) and that has its roots in the early 90s.
Writing long lasting code is something that the Raymond Chen camp in Microsoft understands. Hence they always strove for backward compatibility. It’s a shame that the other camp (what Joel Spolsky calls the MSDN magazine camp) has taken over and that’s reflected by the way MS designs and changes it’s APIs these days.
There is so much good quality code written in C++ that is has become entrenched, similar to how COBOL is entrenched in certain areas. However, unlike COBOL that’s a dead end, C++ is still evolving and a lot of work is being done everyday in C++.
Cocoa is largely based on NeXTStep, first released in 1989, and was itself released in 2000. Hint, what does the “NS” at the beginning of the Cocoa API functions stand for? (Answer: NeXTStep.)
By the way, Raymond Chen didn’t invent long-lasting APIs. I’ve written Unix command-line code that would run in Version 7 Unix, from the 1970s, and have written code in Unix personally in the early 90s in System V that will run fine in the latest Linux, or in OS X, which also is Unix, to the point of being certified Unix, unlike Linux, though Linux really could be certified Unix easily if Linus were so motivated.
Don’t get me wrong, I have nothing against Windows, or the points you’ve made in favor of it.
Don’t bash Cocoa though, it too has backwards compatibility, and can run CLI apps from Unix that are as old as your cli example, and GUI apps that are as old as your GUI front-end in Windows. The difference is, Apple does add lots of new features in each OS release. Because of the abrupt transition to OS X at Apple in 2000, Apple continues to have a reputation as a company that doesn’t honor backwards compatibility anymore. The fact is, the transition occured at Apple, Cocoa has old APIs in it (NeXTStep and Unix, plus Carbon for old classic Mac OS apps to be easily ported to) and is not particularly a platform that’s incapable of running old code, especially the Unix code, though NeXT, although less common, dates back pretty far in computer terms.
C++ may have some syntactical and library annoyances, but when used intelligently it is an incredibly effective and elegant (yes, elegant) language. It carries over C’s major strength of being wonderfully cohesive with the von Neumann architecture and memory model.
C++ goes further than C in natively supporting a number of programming paradigms that, in skilled hands, can produce code that is minimal, understandable, correct and fast. But in that is its weakness. It is not Basic, it is not COBOL, and it is not JAVA. To use C++ really effectively requires many years of experience working with good people, not just in coding, but in design, in order to recognize and to optimally choose the mix of implementation paradigms that best suit the problem domain.
An understanding of the commonality and variability, both within the problem domain and in the implementation domain does not come easily, and if you are working with a single-paradigm language, your thinking itself is constrained. C++ helps out in this area by being a mature multi-paradigm language, although nowhere near to the extent of something like Oz. Thinking about things such as structural commonality and type variability, type commonality and structural variability, safe deterministic resource management, compile-time metaprogramming, etc. in C++ is now quite natural.
C++ is not a static language, it is evolving intelligently albeit slowly. However, C++ is not a language that enables you to deal easily or safely with the a numbers of CPU cores, yet this is the direction the hardware world is heading towards. It will be interesting to see if C++ can evolve and survive as a major language when thousands of cores become the norm.
Edited 2008-06-27 03:54 UTC