Is C++ an Elitist Language?

Recently I made a post about some things in Java that I find to be a bit of an issue. The artcle was reposted on Javalobby and it started an interesting discussion in the comments section. Among other things, one comment in particular struck me as disconcerting:

When you use a language you should ask yourself what is the feeling of it. C++ is an elitist language with strong roots in the procedural C (that should compile in C++), and a big focus on performance. Java  is a full Object Oriented langage inspired mainly by C++ and smalltalk, which was for a long time pretty slow, and focus on writing big maintainable programs via simplicity and strong typing. ( A comment by Raphael_Lemaire @ )

Specifically the part about C++ being elitist. Now, I love C++, so of course I am biased. However, I never thought of it as being elitist. The funny thing is that the syntax of C++ is very close to that of Java, does that mean Java is elitist? As far as I see it the real difference is that Java: offers you loads of libraries, memory management, and it allows the coder to not have to think about pointers. Lets look at each of these issues.

The first issue, of libraries, I don’t really consider much of an issue. Especially if you use open source libraries there are hundreds of libraries which are readily available. Certainly the Java libraries are nice, and most, if not all, are guaranteed to be cross platform. However, many of the C++ ones are as well so I also consider that argument to be a moot point. The fact that you have to compile them for each  different platform can be a problem at times, but I consider it a minor problem especially given the speed of modern computers.

The second issue of memory management is something that goes to Java’s favor. I think, however, that it is a minor issue in the scheme of things. Once you understand the basic idea of memory management, and as long as you use a good programming style which favors allocating and freeing memory in the same place, this isn’t as big of a deal. I have written that you can leak memory in Java too, so Java is not free of this nuisance either! Therefore Java coders who think that are impervious to problems with memory are just kidding themselves.

Third is the fact that in Java you don’t deal with pointers. Or, rather, you don’t have to think about them even though you deal with them all the time. This is more personal opinion than anything, but I never found pointers to be that difficult of a thing to deal with. Once you get an understanding of them it’s really a trivial matter. I know that some people make a fuss because you have to always be thinking ‘is this a pointer to an object, or the object’, but that consideration has never slowed me down. You make note of it once and then it stays the same throughout.

So what is it about C++ that makes it elitist? Is it the people that write code so convoluted that only an experienced pro can read it? I think this could be a big part of it. No matter what language you use people can always write unnecessarily confusing code. Languages like Java try to help prevent this, but I’m sure it can still be done. Having access to pointers can lead to code that is difficult to read, but I think the problem there has more to do with the coders than the language. Programmers should be wise enough to write readable code, and not blame the language.

Do you blame English when you can’t spell a word? I mean… silent letters, what is up with that? No, you probably blame yourself for not having put in enough time to learn the proper spelling. So why should we blame C++ for people that write obfuscated code? At the end of the day it all comes down to the coder, and whether they want to write good code or not.

The bottom line is that I don’t consider C++ an elitist language,  but rather a language that with some extra consideration can be just as easy to code in as Java.


5 Responses to Is C++ an Elitist Language?

  1. Frosty840 says:

    Well, the thing that I’ve found, being a .net programmer on the North side of the office, with the C-guys sitting over on the South side of the office, is that my applications are written (A) so that I can write them quickly (B) so that I can change them quickly (C)with the largest amount of operational time spent waiting for user input.
    The C-guys, on the other hand, write (A) for speed of execution.
    There’s no (B) or (C) to their code. It’s all about the speed.

    As a result, while, as you correctly point out, C and by extension, C++ can be written as easily as the popular memory-managed languages, for the situations where you’re going for raw, eye-watering speed-of-execution over any and all other considerations, you can’t write like that. And because the overhead you pay for the automatic memory management, etc, in Java, .net, et. al., you simply can’t get that raw speed out of the managed languages, and so they aren’t the language you use when you need to write to that condition.

    As a result, the all-out-speed guys tend to only work in C and C++ or assembler and machine code,because certainly some of our C-guys do (and yes, a bunch of other languages I don’t know about, I admit my ignorance, please don’t eat me.)

    Those guys are the ones you’re referring to as “the elite” and they certainly do exist, but they’re not coding the easily-maintainable code that I code, and that I judge that you’re referring to with your “C++… can be just as easy to code in as Java”. They’re coding the crazy, optimized stuff that can’t easily be read, because it’s deliberately not flowing and descriptive, it’s raw, confusing and built for the task not for the maintenance programmer.

    Different, not necessarily better, if you will.

  2. jintoreedwine says:

    @Frosty840 – Hmmm, that is interesting. I guess I tend to think that not too many people write the ‘crazy, optimized stuff’ as it seems there are few applications that need that, given how fast computers are these days. Though, I must admit, I love optimizing code even if it may not be necessary 🙂 So I secretly hope that ‘art’ never dies.

  3. scaryreasoner says:

    As a C programmer recently learning C++, I don’t find C++ to be performance oriented AT ALL. I find it both a) unnecessarly complex — in fact it seems to encourage and almost enforce excessive complexity, is horrible to debug, and is not particularly efficient precisely because of the sorts of design decisions it encourages which build up over time into a tower of overly complicated interfaces. I’m not alone in this conclusion, I think most long-time C programmers are almost certain to arrive at this conclusion.

  4. jintoreedwine says:

    @ scaryreasoner – I actually learned C++ first and then C at a later date. I have not found C++ to be overly complex per se. I think it is just a different mindset. Ultimately the advantage of having objects, when used correctly, makes code more maintainable (IMO) . That is not to say that you can’t have maintainable C code, because you certainly can, but I think for a fair amount of programmers, organizing code into objects is easier than structs and function calls. Again, I know this doesn’t apply to everyone and I, personally, appreciate procedural languages just as much as OO ones.

  5. Mathew Duafala says:

    While I don’t think C++ is an elitist language (I’m not even sure what that phrase is supposed to mean), I do think that the programmers who are very proficient in it are looking at things in a different way than Java programmers, and that differing perspective could easily be viewed as ‘elitist’.

    When Java programmers are asking questions on newsgroups, they are looking for which library can get their project done the fastests, while the C++ guys will go on long diatribes about the theoretical correctness of casting away const’ness or whether the standard should allow threading.

    In defense of C++ though, it has to be compilable on almost every platform in existence (some embedded systems use a subset of C++, or just stay with C). Java on the other hand only has to compile for one platform, the JVM it was written for. Sun takes care of making sure that JVM is portable across OS’s.

    When you start requiring the language to be portable to systems that may not have a threading model, or may be little endian, etc, it necessarily changes the way you have to look at your code and the design choices you make.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: