Learning Programming Part 3: C/C++ superiority

Previously, Part 1 and Part 2.

The other day, Marie pointed me to an interesting article where Jolie O’Dell decides to go back to school to get a computer science degree. She asked me what my thoughts were on some comments concerning the necessity of learning C/C++. I’ll paraphrase in order to avoid singling anyone out.

“Scripting languages create holes in proper programming. All a language, like PHP, will do is make you a PHP programmer, while a language like C or C++ will give you a fundamental understanding that can be applied to all languages and make you a better programmer no matter what the language. This is because these languages expose you to the way the computer really works (instead of abstraction): for instance, how a string is really created, or an array, or dynamic memory allocation. If you learn PHP, you will never bother to learn the low-level reality.”

The above is a munge of many commenters’ discussions.

What do you think of the above statement?

Here was my reply:

I don’t have a definitive answer to the claim since C was the third computer language I ever learned and C++ was the fifth. The first two were BASIC and Pascal. Back then, there were no interpreted (scripting) languages. So I never learned things “out of order” and don’t know how hard it is to learn them “backward.”

However, I feel the need to give some facts I do know.

First, this above is just another example of a common supposition of superiority that permeates the programming world as parodied by a friend:

The way to read this diagram is that that people belonging at one end of the arrow don’t consider you a “real programmer” if you know use language at the other end of the arrow.

Second, if it is true learning a high level language precludes learning a lower level one, then I could have never learned the language I learned between C and C++. It is easy to forget there is a language lower-level than C: assembly language programming, which is the language of the machine itself. Moreover, by the time I went to school, nearly every programmer my age who learned assembly, including a classmate who now makes a living coding in assembly language exclusively, learned it as a second language. According to that claim, they should not exist—or at least be very rare.

Third, C/C++ is not a single programming language but two that share nothing in common but syntax and the requirement to have a working knowledge of the former to use the latter. C a very low level language with a very simple syntax; C++ is not just an object-oriented version of the C, but can be—and often does—get complicated. Even at its simplest, the language is “overloaded” with features. Don’t believe me? The C book is 274 pages and hasn’t changed since around the time I learned it more than two decades ago, and the C++ book weighs in at 1050 pages and only glosses over some the libraries and frameworks you need under daily programming—themselves the subjects of books even larger in length. When talking about learning programming, it is hard to use C and C++ in the same breath and be referring to the same thing—we should talk about one or the other. When discussing them together, it becomes a moving target.

(Fourth, C and C++ have disappeared as primary “first languages for teaching programming to computer scientists” since about the mid 90’s. It has since been replaced with Java. Java is about as high-level as Python. So according to this theory, anyone who has matriculated in the last 15 years is pretty much fucked in the real world.)

My experience has been people know a low-level language like C (or C++ which means they learned C) find it very easy to pick up a higher level language like PHP. The reverse is less common, though not non-existent.

My suspicion is that it is not “easier” to go one particular direction, but rather that it is uncommon for a motivated student to go through a rigorous computer science program and not pick up C and C++ along the way—the same cannot be said of PHP (or Python). In other words, the fact that we see in industry a lot of C/C++ programmers tend to be better programmers overall and quicker learners is because they are more likely to have had a better programming education, not because the first language they picked up was C or C++. In fact, as I mentioned already Java is a more common language taught so there is a strong implication that they picked up C/C++ not as a first language, but as their second and third language! So C/C++ knowledge becomes a signal that the person had many years of formal education and the wherewithal to learn a second (and third) language. Know PHP programming? It probably means you wanted to install a counter on your Geocities homepage…or something.

(Wonder why so many Java programmers often seem incompetent compared to others with formal computer science education? My guess is that programmers who know Java aren’t incompetent per se, it’s just that a number thought they could get away with knowing only the language that they were taught in class. Programming Java often just serves up a signal as possibly someone who had no natural curiosity for programming and learned the minimum necessary to get their college diploma.)

Moreover, it is important to note that knowing any programming language makes it much easier to learn another one, so either course (C/C++ to PHP/Python or PHP/Python to C/C++) is an easier path than learning a first programming language (whether it be C, or C++, or PHP, or Python).

As for Jolie O’Dell, the problem is obvious. I’ll bet she tried learning Python out of the poorly named Learning Python book. Besides having errors in the first chapters, like many introductory textbooks on scripting languages, the book pre-supposes you already know how to program! I know it sounds crazy, but most textbooks on learning a programming language assume you already know at least one other programming language. This is evident in how quickly the gloss over difficult to explain concepts like “typing”, “objects” or “inheritance”, and how how much time they front-load a book with such minutia like what language that was used to build the “virtual machine” or tables of information on useless operator precedence rules.

Schools know this, so the professors there rework the material to be learned as a first language instead of a second. Plus, the structure of assignments and the carrot/stick of actually having grades cannot hurt.

Let me bring up an anecdote from physics. When I was studying physics, people complained how my generation was “all computers and software” and we didn’t know how to repair a TV or build an oscilloscope from scratch. While it was true I couldn’t rely on instantly understanding a circuit diagram in lab like my predecessors, I could make Mathematica dance and almost all modern experiments (and theory) required making a computer tango with numbers well beyond the ability of the previous generation.

We build on the achievements of others.

I bet programmers from the 70’s looked at the ones learning C/C++ and proclaimed them weak sauce because they were not coding in machine language. Similarly C/C++ people look at scripters and say the same.

Given that, it makes me worry that maybe this discussion is about measuring penis size instead of getting where you want to go.

11 thoughts on “Learning Programming Part 3: C/C++ superiority

  1. Language learning order:
    – dBASE II (volunteer work)
    – Basic (Timex Sinclair then Commodore then Apple)
    – Pascal (SF City College main frame and Turbo Pascal on CPM card n Apple II+)
    – 8080 Assembly (SF State class)
    – C/C++ (SF City class and Dad's PC)
    – dBASE III (Dad's PC)
    – Visual Basic (my PC)
    – Java (my PCs and at .com)
    – .net C++ and Solaris C (at another .com)
    – ActionScript (2007 .com)
    – now coming up on Objective-C (MacBook Pro & iPhone)
    Where I've come to is Prototyping is as and perhaps more important than low level coding. And unit testing is important for code change.

  2. This is untrue…

    "(Fourth, C and C++ have disappeared as primary “first languages for teaching programming to computer scientists” since about the mid 90’s."

    I learned C and started learning C++ in the mid to late 90's. Although, I don't recall Fourth being required, Beginning, Intermediate, Advanced C, and C++ were required for a CS degree then. Pretty much, everyone I knew then took Beginning C as their first programming course.
    My recent post CSS Jelly Buttons

    1. Interesting. At my undergraduate school, C replaced Pascal as the introductory programming language (freshman introduction to computer science) in 1989. I don't know if they still use it. The type of C programming they were doing radically changed in 1994 (more algorithm focused instead of project-based), so they could have used any language to teach in that style at that point (though if a higher level language, something with pointers would be required). I don't remember C++ being taught at any level, though it was a very popular language many to learn on their own (as I did at the time, and I wasn’t even in CS).

      At my graduate school (University of Illinois), Java replaced C as the introductory language in 1998, at least when I asked undergraduates what courses they were taking.

      This lead me to believe that C may be taught but Java would replace C++ for an introduction to object-oriented programming. Personally, probably the best introductory language would actually be Python, for the same reason Pascal was popular before C’s ubiquity replaced it.

      As for Fourth, this is why I use the Oxford comma when I can.

  3. I started with Pascal, then VB in high school (96-00). College was almost exclusively c++ (00-04). After college, it was .net. They're all different. They all have their strengths.
    BTW – thought the comment in the diagram about people insisting on html being considered a programming language was hilarious.
    My recent post Top 10 Wedding Videographers

  4. Hi,
    I started with Pascal and then C, C++.
    Delphi,Java, PHP and ruby i've learned on my own.
    For Java and . NET we can get the most interesting jobs in term of payment and projects.
    Not everyone has the chance to work in for a major Web site without changing city or country.

    The worst companies were I live work with PHP and Ruby. It's not bad if you own one.
    Well, I would put PHP and Ruby at the bottom in terms of contract… for the my country.
    C++, .NET and Java are the platforms for good contract.

  5. I am a PHP programmer. You should learn a language for what you feel it gonna solve for you. Its funny when l hear other programmers critizing PHP, when almost all softwares and largest web sites on the web are backboned by PHP. Trust me, these programmers are no better in any way than PHP programmers, and they are loosing a lot for not purging their mind of jealousy and embrace PHP for their own enjoyment. A good programmer is known by his or her achievements.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.