I’m going to take a stab at explaining why I think some RIT students just don’t get C++. These things may be more widely applicable, but I’m not going to assert that – I only know what I see with the students I am grading, and some of it is rather painful.
So, here’s the short list. If you feel like you are in one of these categories, then please stop and think about it before you take the typical (and expected) knee-jerk reaction. That reaction would too fitting to be funny, as you’ll see here:
- Java is the Way, the Truth, and the Light – Java has become the new Jesus for thousands upon thousands of “programmers” (note the quotes). The problem isn’t really Java as a language, it is Java as a culture. I don’t think anybody truly sits up at night thinking about how horrible Java is, but I do think that people sit up at night and think about how the Bible was written in Java. Evangelical anything, be it C++, Java, Python, Ruby, whatever, is unhealthy. Every language is a tool – every language has its uses, its domain, its appropriate methodologies; every language allows for some things and prohibits others. But no language is perfect for every application. Stroustrup said it best in The Design and Evolution of C++ :
I find it hard to imagine an application area for which one couldn’t construct a specialized language better than C++ – and better than any other general-purpose language. Thus, the most a general-purpose language can hope for is to be “everybody’s second choice.” [pg. 201]
On top of this, it seems that most Java evangelists only know the C++ that is spoonfed to them as being “so much worse than Java.” Strout is interrupted every five minutes in class when someone says, “Java does that better, you know.” Java generics are better, Java syntax is better, everything is an Object is better. C++ sucks because it doesn’t have a garbage collector and it doesn’t have try-catch-finally. These are the people who can find the time to explain to everyone within shouting distance that Java is soooo much better, but can’t take the week of their life to actually research and understand what it is they are criticizing, or even read Stroustrup’s FAQ and technical FAQ, where he answers these questions and more.
- Low level programming is out – Many of the CS4 students dismiss C++ because of the low-level concepts it inherits from C. Somewhat in continuation of point (1), the fact that C++ has pointers makes the students balk. Also, many students see the lack of the garbage collector as being a huge drawback. Unfortunately, these are the students who never really understand RAII, scoping, stack allocation, and smart pointers. Like before, nobody took the time to learn anything about the subject. Stroustrup’s FAQ contains a very good question about memory leaks where he points out that good C++ code either avoids concepts (like C-style casting, macros, explicit size limits) or wraps them in safer containers (explicity memory management, resources, pointers).
- It compiles, so it must be good – Just because code compiles (with copious amounts of warnings) does not mean it is “well-written”. Many students are applying Java design methodologies to C++, and end up with poorly designed code. These are the same people who complain that a language without finally is stupid, without ever stopping to learn what a destructor is and how it is useful. The same goes for garbage collection: “What, C++ isn’t going to manage my memory? Fine, I won’t manage it either. It’s the fault of the language if I have memory leaks.” To these people, RAII, smart pointers, and concept wrapping are alien vocabulary. The point is that if you are writing code in a language, you write code for that language. Another example of this would be a certain CS professor who writes everything in LISP, regardless of what language he is using. The moral? Don’t write Java programs in C++: it isn’t pretty, it isn’t efficient, and it isn’t good design.
I’m sure I am being overly pessimistic about these students, and I’m sure that the projects will continue to improve. It’s just that I hear some disturbing things, like a recap of a conversation between a CS professor and an SE professor that was told to me (by the CS professor):
CS: “So, I understand that the curriculum for SE is changing so that your students will never have to learn C++. In fact, they will never have to learn any language with pointers. So, when will the students be taught the concepts of indirection?”
SE: “They won’t. You don’t need to understand indirection, because real programmers don’t use pointers. They use languages that do it for them.”
CS: “That may be fine for new code you are going to write, but what about existing code that you need to work on? At some point in time, a student will probably need to work on a system written in C or C++. What then?”
SE: “If a program is written in a language with pointers, it was badly designed, and should be rewritten in a better language.”
Yeah, I shit you not. This is the same professor who told me (personally):
- “real” programmers use Java and Visual Basic
- all open source software is crap (based off his browsing of Sourceforge)
- for a tool to be good, you have to pay money for it
- “real” programmers use IDEs, not editors like emacs and vi
- everything, and I mean everything, should be modeled in UML
And I’m spent. I don’t think I need to continue.