C++ Hating

I need some help in compiling best programming books of all time. Please send your emails to guywhosteals@gmail.com or just comment anywhere on the site. I will get my hands on the book and try to include it. :)

I got a chance to read an interesting, well-written, but badly inaccurate and almost exclusively provocative piece of writing over at TechRepublic. The article — like countless articles on the web already — try to predict the demise of C++, this time in favor of other programming languages that are not as powerful. I, as a C++ developer who loves the C++ programming language for all the warts and moles it has despite what other (lesser mortals? :P ) may say, articles like these are really a very bad indication of what kind of (clueless?) technical bloggers there are out there.

I’ll spare you the details of the post, but if you want to go ahead and check it out for yourself, you can follow this link. Here’s an excerpt that I would like to react to in a longer form than that which I can put in the comment fields over at Tech Republic.

One might think C++’s days are numbered, now. Alternatives that seem significantly better suited to the same jobs litter the landscape, and the obvious direct competitor — Objective-C — is in some ways the least of them. Objective Caml is regularly held up as an example of a high performance language, frequently outperforming C++ by a significant margin in benchmark tests, offering more succinct and well-organized source code, and providing developers with far cleaner and more interesting development models, and it is not even derived from the same family of programming languages. D aims to compete in the same space, though its proprietary roots may hinder its widespread adoption. Google’s Go language presents controversial trade-offs, but there is no doubt that its design offers huge advantages for certain types of software development, including concurrency.
Judging by the lessons of history, however, I am inclined to believe that C++ will have a long, stable tenure in its niche for some time to come. It has even been sneaking into operating system kernel development for years, as horrifying a thought as that might be for people who care about things like OS reliability. There is no doubt that it offers some advantages over C for certain types of performance-critical programming, and that its library support is extensive — even legendary. Despite this, at least some of the strength of its hold on developers seems to be based on ignorance of the alternatives, and that is not a characteristic that will easily be pushed aside by a would-be competitor.

If there was ever a yellow journalism on the web, I’d say this article is a good example of yellow bloggerism. It’s sensationalized and appealing to emotion, without pointing out the facts for which an argument is made. If you read through the article it is littered with anecdotes from which the author tries to make a case for the demise of C++. In the end, he practically gives up and says that C++ will stay for a while but suggests that ignorance of the alternatives is something the would-be competitors can address.

So let’s examine what he’s really saying here, and let me try to read between the lines of what he’s actually written.

One might think C++’s days are numbered, now. Alternatives that seem significantly better suited to the same jobs litter the landscape, and the obvious direct competitor — Objective-C — is in some ways the least of them. …

Unfortunately he doesn’t point out which “jobs” he’s referring to. He made examples of browsers, so let’s bring that into context here.

He’s saying that there are a lot of alternatives to C++ for programming browsers, high performance software, desktop applications, and high-throughput server systems. Let’s mention a few of the successful products out in the market that are using C++ and why they’re using C++ to get a better idea of what the other programming languages are competing against when trying to displace C++ as the programming language:

  • Google Chrome — it’s cross-platform, using the Qt GUI framework, and offers a premium on speed and performance. If you want to displace the programming language in which a Google Chrome is written in you’re going to have to use a programming language that is portable over a myriad of platforms. I’m not just talking about Mac OS X, Windows, and Linux — I’m also talking about Android (if you check out Google TV, it’s Android with Chrome ported over).
  • Adobe Creative Suite — it’s very demanding working with video, audio, and graphics. If you’re going to port all the Adobe products to a different programming language, then you’re going to have to use one that can use the least amount of computer resources to do the most trivial creative/editing tasks, be able to handle projects no matter what size, and leave enough computing resources for the user to be able to do other things with the computer. Oh, and you have to port the application to both Mac OS X and Windows too.
  • Microsoft Office — it’s ubiquitous, extensible, embeddable, and feature-rich. If you’re going to port Microsoft Office to a different programming language, it should reduce bloat, enable the application to be responsive, and you should make sure that writing extensions for that system will be seamless and powerful enough to allow real extensions to be developed to look like it’s part of the application. You’re also going to make sure that it’s responsive to input and powerful enough to handle large enough documents.
  • World of Warcraft — And I’m not just talking about the desktop app where it has to deal with the deluge of input/output events, and the myriad rules it follows when it comes to game logic, rendering, and all that jazz that comes with game development. Think about the server-side too. Need I say more about this great piece of software?
I challenge you to name one programming language other than C++ to which to write applications similar to these, and be able to deliver the same level of functionality, stability, extensibility, portability, and ubiquity that these applications are written in. Before you mention C, I tell you that C is a subset of C++, and if you mean pure C, good luck with keeping yourself sane without the abstraction that C++ provides.

Objective Caml is regularly held up as an example of a high performance language, frequently outperforming C++ by a significant margin in benchmark tests, offering more succinct and well-organized source code, and providing developers with far cleaner and more interesting development models, and it is not even derived from the same family of programming languages. …

Have you really thought about what C++ offers in reality before you corner it as simply an object-oriented programming language? C++’s strength is not its object oriented programming support — it’s the fact that you can write in many different paradigms in C++ that makes it its strength. Also, if you’re doing benchmarks, then everyone knows that micro-benchmarks are meant to highlight one aspect of the system/solution you’re benchmarking. A true benchmark is one that accounts for real-life conditions and usage patterns.

Talking about high performance code, this is largely a matter of the compiler being used, and not the high level language you use to write the program in. This is true for all compiled programming languages. It’s all too easy to say that a programming language is better than another if the tools you use are better, but in reality the performance of the product is mostly a matter of many moving parts — the machine, the compilers, and the solution. A big part of the reason why some programs have bad performance is because the solution is badly written — using a sub-par algorithm, not tuning the implementation to account for the usual case, etc. If you’re comparing a bubble sort in C++ with a radix sort in OCaml, then maybe the OCaml will have a better performance profile depending on the inputs.

Also, when you talk about aesthetics, this is a matter of taste and familiarity. A poem written in French is not any good to me because I don’t read/speak/write in French — so no matter how beautiful you think that poem is, I wouldn’t care much because it’s not my native language. This is the same case for C++ — I have read (and would like to think, have written) beautiful C++ code, but a Java programmer or a C programmer wouldn’t care for it the same way I do, because they don’t use C++ natively.

A large part of efficiency and proficiency is mainly attributed to familiarity with not only the technical matters, but also the idioms and shared understanding between/among a group of practitioners. You cannot say you are proficient in C++ if you haven’t been with peers that do C++ and agree with the statement that you are of a certain level of proficiency. It’s all too often that people think reading C++ books will give you a good enough level of proficiency to be productive with it, but like in the case of any programming language, proficiency and efficiency comes at the cost of practice and improvement.

D aims to compete in the same space, though its proprietary roots may hinder its widespread adoption. Google’s Go language presents controversial trade-offs, but there is no doubt that its design offers huge advantages for certain types of software development, including concurrency. …

Borrowing from the great John Dvorak, I’d say “this is baloney!”. If you think being proprietary may hinder its widespread adoption, take a look at Java which the enterprise world is treating as the new Cobol. Think the x86 assembly language, that’s proprietary. There are a lot of proprietary programming languages that have enjoyed widespread adoption, but being proprietary is not a hindrance: what matters really is technical merit. Unlike in the world of social interactions where investing in politics has an effect, this is not so true when it comes to hackers choosing the tools they use. If you’re trying to sell a better mousetrap, your mousetrap better be a lot better than what I have for me to even start considering buying it.

As far as concurrency is concerned, the real problem is that the general population of programmers don’t know how to write effective concurrent programs. That’s really the problem. It doesn’t matter what programming language they use, lack of knowledge of the issues in concurrent programming along with varying machine architectures and different data access patterns along with resource constraints is what’s really making concurrent programming “hard”. Even if you’re using Erlang or Go, it’s not trivial writing an effective concurrent application if you don’t do it right and know the idioms and patterns involved with developing effective concurrent applications.

Despite this, at least some of the strength of its hold on developers seems to be based on ignorance of the alternatives, and that is not a characteristic that will easily be pushed aside by a would-be competitor. …

Again, this is baloney.
Developers who use C++ day in and day out do not live in a vacuum. We know about Ruby, Python, Haskell, Lisp, JavaScript, Java, and even new fangled programming languages like Erlang, Go, Lua, etc. The reason organizations still use C++ to develop great applications is because C++ works, and C++ allows you to do things with it that very little other programming languages allow. I will be the first to admit that C++ is not as powerful as Lisp when it comes to the things you can do with Lisp, but if you know your Lisp you can approximate these with modern C++ — and some even might say “voodoo” with C++ template metaprogramming. Also, Lisp is a non-starter when it comes to performance, at least unless you’re prepared to tune your Lisp implementation for the specific workload you’re encountering.

Conclusion
I’m watching the word count on this article and I’m nearing 2000 words. This kind of C++ hating gets me fired up and defensive, but let me try to put a little perspective here for a moment. The reason I think C++ is powerful is not because I’ve invested a lot of time and effort into learning it and using it on a daily basis. Far from it — it’s actually the other way around. It is because I thought it was powerful that I invested so much time and effort to get to where I am now when it comes to C++ programming.

I’ve heard all possible criticisms about C++ from all kinds of people. CEO’s, HR managers, developers, business partners, and even C++ developers. But the reason C++ is an ISO standard, and the reason it continues to have a thriving marketplace of vendors, developers, solutions providers, tool builders, and journalists is because its power was not incorporated by design — it just so happened that the language was designed to support the good and the occasional bad parts of programming languages past to provide a flexible multi-faceted tool for developers to create great applications with. There’s a lot you can do with C++, far more than what you can do with other programming languages that touch the bare metal.

If there’s one criticism I’ll make about C++ is that it’s largely misunderstood. If everyone took the same amount of effort learning Ruby/Python/JavaScript as they did learning and using C++, I’m pretty sure they would change their minds about what they think C++ really is. Admittedly, there aren’t a lot of well-written books about C++ programming for beginners — the one I can point to is Programming: Principles and Practice using C++. Before you knock on C++ again, read this book first then tell me how not powerful C++ is — it’s alright, you can thank me afterward.

Check out the list of Windows' failed rivals. Its longer than you think. Click here.
News on Mozilla's new programming language Rust. Full article here.
To subscribe to the "Guy WhoSteals" feed, click here.
You can add yourself to the GuyWhoSteals fanpage on Facebook or follow GuyWhoSteals on Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
top
Share