Why you need to know C++


I saw an interesting question on stack overflow wherein the questioner asks why everyone keeps telling him that he has to learn C++ to be a professional developer. Although it is true that most of these discussions are just launching pads for religious wars and I’m not alone in  my assertion that your language of choice is largely irrelevant , I do agree with the perhaps controversial notion that every working programmer should be at least conversant, if not fluent in C++.

Let me be entirely clear about this. I am not saying that C++ has to be your primary language or that you need to be a C++ guru to work in this business. However, it behooves you to be able to competently read and write basic code in this language.  That is, you should at the very least be able to implement the FizzBuzz program and the cliched example of a Zoo program to demonstrate polymorphism without lifting someone else’s code.

Before you dismiss me as a platform snob, consider the following six reasons that you need to know C++

1.      You should learn C++ for the same reasons that people study dead languages like Latin. The syntax and other memes in higher level languages were inspired by or directly stolen from C++. This is blatantly obvious for Java, C#, and JavaScript. Learning C++ is a quick way to grok the syntax for a several languages at once and better understand their origins.

2.      Understanding the details that are abstracted away from you in other languages (pointers, basic data structures, garbage collection, etc.) will ultimately make you more adept at solving problems when the abstractions innevitably leak or the stalwart underlying technology doesn’t live up to its stalwartitude.

Consider the real world example of anti-lock breaks, which allow you to maintain control of a car during an emergency stop. ABS has a completely idiot proof interface –Jam foot on pedal– that works just whether or not you understand that it will electronically pump the breaks to prevent the wheels from locking. However, during an attempt to thwart an impending moose collision it is certainly comforting to understand why the car is stopping in jerks instead of a smooth motion despite steady pressure on the pedal.

Also, this knowledge might have prevented my wife from listening to a shady mechanic who conned her into thinking that she had to pay his exorbitant rate to fix her ABS system since the truck wasn’t safe to drive without it to another mechanic for a second opinion.

3.      Like it or not, C++ is the lingua franca of programming. Some would argue for Java, or even JavaScript, which may appear true in much the same way that the ocean appears to contain water because of all the wet swimmers who frequent it. It’s best just to accept this, but if you need reinforcement all you need to know is that Software Jesus (Joel Spolskyagrees with me * on this, case closed.  

4.     Programmers and programming books that need to address programmers who speak an unknown or different language often use C++ for the same reasons noted in point #3. Learning this language will open access to more learning material and help you communicate with the programming community more easily.

5.     One day you are going to need sully yourself and interface directly to a C API from the lofty perch of your high level language. In my experience a lot of tool developers avoid the hassle of maintaining separate COM, .NET, and Java API’s by just providing a a C API that will appease all the peasants who are not as privileged as they to “work in a real language.”

6.     C++ on your resume can often lead to Salary++. I’ve found this is true even if the job doesn’t require any C++ programming.  It is just respected as a more hardcore language and the credibility rubs off on those who use it. That credibility makes you more valuable.

 * Update: As noted by a commenter (BTW: Thanks for the correction), Joel did make a definite distinction that new programmers should be learning C and not necessarily C++.  Apologies for misstating his position. While it is true that for just many of the points I made, you could easily substitute C for C++ and get the same bang for your buck, I contend that C++ is a stronger foundational language for the points detailed in 1,3, and 4.  Using a language that can’t talk about objects (C) to communicate with other programmers in an overwhelmingly OOP world isn’t gonna cut it.

About these ads

10 Responses

  1. I’ll be pedantic and point out that for (3), Software Jesus is talking about *C*, not C++, and even makes an effort to reinforce this:

    Learn C before graduating.
    Part two: C. Notice I didn’t say C++.

  2. C, not C++!

    C is a small, low-level language. There is a certain elegance to its simplicity.

    C++ is a monstrous language that no one really understands.

    It’s important to know the difference, especially if you’re advocating learning one of them.

    • I’m quite sure that I know the difference. I have programmed in both of them at one time or another. However, I think the assertion that C++ is a monstrous language that no one understands is a bit of an exaggeration.

      In any event, I think that’s a moot point. I am advocating only a basic competency in the language, not a memorization of the entire STL. I am just raising the bar a little by specifying C++ because I think that understanding OOP syntax is a critical skill for today’s programmers.

      PS: I appreciate your input, even if we might disagree. A key reasons I started this blog was to create some meaningful discussion on some core aspects of programming.

      • C++ is a lot more than C with OOP, though. What are your opinions on template meta-programming?

        I would think that a “competency in C++” (as opposed to a competency in a subset of C++) would require at least having a reasonable understanding of the concepts behind such meta-programming, such as how one constructs “empty” types and then uses them to pass information for making (arbitrarily complicated) compile-time decisions. But this is not even mentioned in Stroustrop’s big book on C++; one needs to get to specialized books on C++ template programming to get any explanation of it.

        • Technically I said “basic competency”, but I’d be willing to retreat back to “VERY basic competency”, although I thought that I had implied that by fundamentally saying that you just needed to be conversant enough to solve FizzBuzz implement a very simple example of OOP using polymorphism.

          Of course you’d need to be better versed in the more advanced features of C++ beyond OOP if you are going to work in it on a regular basis. My message here is essentially “Even if you plan to be a VB, C#, Java Programmer it will help you to be a better programmer if you aren’t completely C++ illiterate.”

          That said, your points are very well taken, thanks for your response.

        • Indeed — and, to be clear, I do agree with the message.

          Mostly I was defending the assertion that nobody really understands C++ — which I think is arguably true of the whole language, for most practical versions of “nobody”. (I think there are a good number more people who can understand any given part of it with a minute or two of memory-refresher reading, though.) The idea of what constitutes “basic competency” in a language with that many dark corners is a quite fuzzy one, and we could have an entertaining and entirely meaningless argument over a beer about it!

          (Meanwhile, it occurs to me that FizzBuzz would be a really good practice problem for template metaprogramming. Thank you for the implicit suggestion there!)

  3. I completely DISAGREE with the notion that either C++ or C should be learned first before moving to other languages….I mean, if you start out learning those languages, fine.

    But, I believe that in 10 years C and C++ will not be languages what will be an asset in the toolbox of developers….why>? Because I believe that these languages MAY be viewed in the future as having too much flexibility that thwarts simplicity in design.

    The languages I believe will be prevalent for developing with in the future are C#, F#, Matlab and VB.Net……and also oddly enough, VBA…..which I believe will be the new Cobol in 25 years……

    I develop small-scale applications using VB.Net and VBA and the last thing I want to have to deal with is deeply profound memory issues……in my mind, I am glad to have an automated memory process for working with objects and variables…..which is the Garbage Collector……I don’t want to have to deal with these issues……when the PARALLEL methods come out in the next version of VB/C# multithreading will be much easier to deal with as well……

    If the CLR can be constructed to assist my programming efforts in these areas, why on earth should I be bothered with learning languages where I have to add another level of abstraction to the programming process by understanding memory constructs and multi-threading?

    I think it comes with the evolution of a language…..as programming languages evolve, so too will the need to be less involved with the intimate processes that occur “in the background” of computer processing which are handled in an automated way…or at least in a way that requires MUCH LESS intervention by the developer.

    • I can see where you are coming from with this statement, however, keep in mind that C++ is not meant for you to learn and then in turn go work for IBM, Microsoft, or Sun Microsystems. It is very, very important for one to know the concepts of the language in order to better understand the free flow of information. I posed the exact same reluctance…buck up and learn it. Once you are on the other side, you will see why C++ plays an important part in today’s programming languages and programmers. In counterpoint, I thought that I would never need to know the concepts of MS Excel but now that I have had to take Advanced Technical Physics and had to make charts and line graphs, I wish that I had paid as much attention to the concepts and flow as what I did in OOP class and Structured Programming classes. So as a final point, keep this in mind. You as well as all of us had to learn the MLA style of writing and doing essays. Microsoft Word is awesome at correcting me still, however, it cannot think for me and this is why I still need what I learned in English..High School through Collegiate English. Learn C++ front to back then tell us how much you hate it. Thanks for making a good point. Wish you well with your studies.

  4. [...] Why you need to know C++ [...]

  5. I totally agree with you. I learned c and c++ initially and still mastering c++ cos its my fav. It lets you get down and dirty with coding. It helps when you move to Java as well. Im telling this from first hand experience. Its easier when you know c or c++. They are the base for many languages and have great support online.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 130 other followers

%d bloggers like this: