Stroustrup Says C++ Education Needs To Improve 567
simoniker writes "Over at Dr. Dobb's, C++ creator Bjarne Stroustrup has given an in-depth interview dealing with, among other things, the upcoming C++0x programming standard, as well as his views on the past and future of C++. He comments in particular on some of the difficulties in educating people on C++: 'In the early days of C++, I worried a lot about "not being able to teach teachers fast enough." I had reason to worry because much of the obvious poor use of C++ can be traced to fundamental misunderstandings among educators. I obviously failed to articulate my ideals and principles sufficiently.' Stroustrup also notes, 'Given that the problems are not restricted to C++, I'm not alone in that. As far as I can see, every large programming community suffers, so the problem is one of scale.' We've discussed Stroustrup's views on C++ in the past."
I completely agree (Score:5, Insightful)
Maybe the real problem... (Score:3, Insightful)
P.S. Feel free to flame away at me, but not only have I developed professionally in C++, I've actually rescued a C++ project by (among other things) drafting C++ coding standards and guidelines for the 30 or so developers working on it.
C++ needs to improve (Score:1, Insightful)
Re:I completely agree (Score:4, Insightful)
Hell, who am I kidding. Just teach them to code in brainfuck. Or maybe INTERCAL. Normal languages will seem much nicer after that.
Re:C++ has issues (Score:5, Insightful)
Re:Maybe the real problem... (Score:5, Insightful)
...and several previous generations of programmes roll over in their graves at the thought that C++ is a "lower-level language".
The thing is, C++ is huge. Just to have a solid working knowledge of the core language, you need to master whole rafts of things that have nothing whatsoever to do with the low-level operation of the machine, because even the core is a labyrinth of obscure corner cases that make language lawyers drool, and which, if expressed in pseudo-code, would be a bunch of gigantic switch statements with a couple dozen levels of ifs nested inside each case. Now, add the STL on top of that, and add common third-party bits like Boost on top of that, and you're left with a monstrosity. To really understand programming at a lower level, you need at best only a small subset of C++, and unfortunately for C++ that subset is properly called "C".
Re:I completely agree (Score:4, Insightful)
I'm not sure if the problem is bad education or the lazy coders who expect everything to be easy (ie done for them) so they don't have to really think about what they're doing.
Even MS's clever chaps have this problem - "lets have C# and GC so no-one need think about memeory ever again" they cried. Then they realised that objects are more than just memory so you do have to worry about destruction of the non-memory resources held by an object (eg file handle, etc). Then they realised they were getting problems writing code that interacted with the OS, so they introduced reference counting objects [msdn.com] that they could put in their "deterministic" finalisation objects that they could put in their Garbage-collected objects.
Re:more to it (Score:3, Insightful)
Yes, that subset is called C.
Seriously, at this point it is time to call a halt to C++ education. Treat it like COBOL, Fortran or any other legacy language that still has demand for programmers but is long since past utility. It is a good idea for students to understand that they have to keep current with programming languages and not expect to be employed as a programmer if they can only code in one. But that does not mean we should start by teaching an obsolete language.
You don't need to tech kids to write in C++ for them to learn how bad an idea lack of GC is. Just give them some existing code and tell them to chase buffer overruns and memory leaks.
I would not code in any language that does not have a garbage collection feature, period. When I coded C in the 90s I wrote my own garbage collector using macros and some extensions to the memory allocation routines. More importantly I would not allow anyone else to write code without GC because none of them were capable of doing it right.
Second, do not use the null terminated string handling. This was one of the key coding requirements that Tim Berners-Lee set out in libwww. All string catenation was checked. It is one of the reasons libwww was so widely used, it was buffer-overun error proof.
I would certainly specify C for use in a low level O/S platform project, but not C++. I think the language is Algol 68 to Algol 60, worse than the original.
Above that point I would use either C#, Java or objective C. From an education point of view they are interchangeable.
C# is at least as fast as equivalent C++ code. The code generator used is identical. You can switch in your own GC if you choose.
Re:Maybe the real problem... (Score:3, Insightful)
C++ is also complex in and of itself, but there are good reasons for almost every piece of complexity in the language. Though severely dated the ARM is still a useful place to learn why the language is like it is. Despite it's complexity, I still think C++ is a very handy tool to have in my toolchest for certain types of problems. However I find myself turning to it less and less over the years.
Java put you on Skid Row? (Score:5, Insightful)
I will grant you that if you or the parents are shelling out the Purdue tuition, maybe their CS department should find a better professor for their intro course. I am sorry to hear that this experience dissuaded you from completing a CS degree, and there is probably a lot more to your personal story than can be shared on Slashdot.
But I would like to communicate to others out there that you will have a few good teachers in your educational career who are really inspiring, a vast group of average teachers, and a number of who you consider to be really, really bad teachers. The "bad" teachers are that way (in your opinion) for a number of reasons -- they may be "nice guys or gals" who don't have enough preparation or smarts to teach, they may have admitted to you gaps in their preparation that you have taken upon yourself to hold them in disrespect for, or maybe they assign too much HW and work you too hard.
If one is going to take a passive approach, show up to class and demand, "Here, educate me", that is a good way to fail at getting a degree and also to fail at every other opportunity that presents itself down the road. If one is going to take an active approach, working as hard as one can at learning from all teachers, the good and the bad, supplementing gaps in instruction with self-study, working coding jobs, group study, one is going to be successful at college and everything else.
To suggest that a person can have one "bad" prof means that they are on the street drinking methyl antifreeze out of a jar wrapped in a paper bag, this suggests a very passive approach to not just education but life in all its aspects.
Re:I'm just glad they're teaching C++ actively aga (Score:2, Insightful)
Re:more to it (Score:5, Insightful)
There, fixed that for you.
Re:I'm just glad they're teaching C++ actively aga (Score:5, Insightful)
Re:Maybe the real problem... (Score:3, Insightful)
Re:more to it (Score:3, Insightful)
Re:more to it (Score:5, Insightful)
The correct advice would be, "use precisely what you need and no more".
I have been programming in C++ for a very long time, and I have needed *every single tool* that some of you nay-sayers would say was unnecessary. And that's needed in the sense of "the best solution was achieved using these tools", not "I padded my CV by adding unnecesary complexity".
Re:I completely agree (Score:3, Insightful)
I am not alone in my opinion. Consider the difference in rank on amazon. Many third party C++ books have better ratings. In fact, I'd argue C++ is such a large language that one needs more than one book to provide adequate information. I don't think The C++ Programming language should be anyone's first book on C++, but it could be an extra backup reference.
As for the O'reilly book, I agree it is not complete but there are a few useful items for reference. Absolute C++ is a better book. Even the deitel C++ how to program book is better and I don't think much of deitel books after having to use three as text books.
Re:I'm just glad they're teaching C++ actively aga (Score:4, Insightful)
Yes, the lack of top-level functions in Java is well-known criticism (at least from the Python/Ruby crowd), but personally I've never had any problems with that, mostly because I don't use Java for quick scripts. The constant need to cast everything is a much bigger problem, IMO.
Re:Maybe the real problem... (Score:2, Insightful)
Re:more to it (Score:5, Insightful)
Did I mention using the right tool for the job? Use perl for this example.
You guys are weird. Someone gave incorrect, convoluted code (in C++) for doing something, and you criticize C++ for this???
Re:I'm just glad they're teaching C++ actively aga (Score:3, Insightful)
Err, are you saying that you *have* to use an IDE to generate a class to run a Java app? The equivalent of your C++ main would be:
public class Test {
// ...
public static void main(String[] args) {
}
}
Why do you need an IDE to write that?
Re:Strostrup is the problem (Score:3, Insightful)
Yeah, array/pointer ambiguity is a key "broken" feature of C++, although at the same time it's exactly the kind of thing that makes it possible to use the same language for code running on a microcontroller and for a full-blown GUI. But yes, for most things it would be incredibly useful to have proper arrays with index checking and so on. Most templated solutions that I've seen (Boost?) are just butt-ugly and make the code that much more difficult to understand.
I think anyone that's used C++ a lot (this is probably a truism for all things) develops a strong love/hate feeling towards it. So it goes.
Re:Why I quit using C++ (Score:2, Insightful)
Computer science is about concepts, not syntax (Score:5, Insightful)
Isn't the whole idea of a Computer Science education to learn the underlying concepts of programming, not just the syntax or semantics of a particular language? The programming language used is merely a vehicle for conveying those concepts. The professor who was "learning [J++] with you as we go" was referring to the specifics of the new programming language, not the concepts that he was going to teach in the course. Presumably (unless he was unfit for his position), he knew those concepts well and was able to convey them to the class using whatever syntax and semantics were thrown in front of him.
The quote I'll never forget came from one of my professors during an advising session: "I'll often get calls from IT managers asking if we have any graduating students who know COBOL. I always tell them that ANY of our graduates could know COBOL - and ask if they are hiring someone for their intellect and understanding of programming concepts, or for their knowledge of a particular language."
Re:Strostrup is the problem (Score:3, Insightful)
Re:Maintainability (Score:2, Insightful)
It's hemorrhage (US spelling) or haemorrhage (UK spelling) BTW.
Re:I'm just glad they're teaching C++ actively aga (Score:2, Insightful)
That is BS
It is ok for, I dunno, a discrete math prof., or maybe an algorythms professor not to code. It is NOT OK for a C++/JAVA/etc teacher NOT TO code.
It is ok if a cellular biology professor is not a practicing MD. It is NOT OK for a surgery professor to not know how to open people up and not to work with that (with the rare exception of 'I can't operate anymore with a bionic hand' kind of stuff).
Re:Maybe the real problem... (Score:3, Insightful)
Re:Ruby? (Score:3, Insightful)
You can still use the === operator, or the kind_of? method. And I'm fairly certain metaprogramming is supported.
I've just found that static type checking is about all that's missing, and it isn't incredibly useful, especially when you're doing unit tests.
I'd assumed they did? After all, Ruby is from Japan...
It is nice that it really only uses ASCII for the language itself, though. I should add that to my list.
I'm feeling a bit lost in this jargon... Can you give me some specific examples?
When these are done for me, via things like Eclipse plugins, I don't worry too much about how complex they are under the hood, so long as they work.
For what, though?
The existing constants are difficult enough to override without at least a warning, and I think that's really all you need. The same could be said of the private/protected methods -- there is a bit of a mess with the usage of 'send', but in a language which truly supports reflection and metaprogramming, private/protected is effectively only a warning anyway, as there's always a way around it.
Ruby is at least as strong as C++, I'd think, due to how easy lambdas are. This seems to be about DSLs again, right?
The syntax for calling functions, and for passing them blocks, is simple and clean enough that it almost feels like defining your own language directives. Yet it's all still valid Ruby, which means it's usually readable by anyone who understands Ruby, and it's easy to mix and match.
In other words, LISP.
I'd argue that the sanest way to do this is to just make the typing implicit.
Which still means that you have to put everything (somehow) into the type system, in order for the template to match, if I understand it. It also means that you have that extra template syntax in order to give you something that I think should be on by default.
Why don't you like that requirement?
In the simplest case, I suppose you can define such a function explicitly:
But I suspect that's not what you want. I suspect you're talking about bind variables, which Ruby can do. (Even JavaScript can do those.)
That is, you want something like:
And this can be
C++ is an ugly hack (Score:2, Insightful)
Having 25+ years of experience in the field my opinion is C++ is aweful. No amount of hacking around the edges of it is ever going to fix that. Due to the very nature of the language defect rates are exceedingly high. Even with modern development, test, and debugging tools building software in C++ is an endeavor which requires an inordinate amount of expertise, mostly in how to avoid doing most of the things the language allows you to do because 99% of them are bad ideas. Instead of learning to program well, most instruction in C++ has to be focused on how to work around its hodgepodge of misfeatures. Personally I wouldn't even consider allowing anyone with less than 5+ years of experience touch a commercial C++ application.
The whole stankin' mess should be retired. The sooner the better.
Re:I'm just glad they're teaching C++ actively aga (Score:3, Insightful)
As background, I have worked with Java, C, and C++. I've also dealt with functional languages (Lisp, Haskell), scripting languages (perl, php, python), and a bunch of other stuff. In all my experiences, my response to C++ is pfft, I can live without it. If I want to get into the guts of the operating system, muck with the kernel, or do something nasty by hand in memory, I'll use C, if I want to write an application I'll use Java. C++ is a terrible language for application development, it combines all the worst aspects of OOP with all the worst aspects of C style memory handling, but brings no advantage to the table!
I'm tired of all this chest beating of wanabe's complaining oh they teach me java, but I am such an uber geek I want to learn C++! Computer Science education doesn't teach you to program in JAVA, it teaches you computer science, in the course of that you learn to program, not to program in X, but to program. Any computer scientist worth their salt can program just as easily in one language as another, and can pick up any other language just as easily.
The only big mental shifts come between procedural languages vs oop languages vs functional languages, etc. Everything else is syntactic sugar. Choose the language which best fits the problem at hand.
Re:C++ has issues (Score:3, Insightful)
Re:Sad... (Score:3, Insightful)
And anyone who is saying 'learn to use the leak detection tool', testing programs for correctness is a total lose. You can never test every state of anything but the simplest programs. A good GC will guarantee that there are no memory leaks without needing to test. Better code safety and better performance as well, memory leaks are the most common cause of performance problems that I see.
Re:Maybe the real problem... (Score:3, Insightful)
Elegance is that term of art in software engineering that we use to describe a piece of architecture, design, and/or coding that accomplishes what it needs to (and often a good deal more) with a minimum of complexity and a maximum of clarity. In all my years of dealing with C++, I have never heard anyone call it "elegant", and with good reason.
Re:Education, even at Universities, needs to Impro (Score:3, Insightful)
Why the hell should they? Is knowing the title of a C book that's out of date (OK, the second edition is better, but K&R usually refers to the original edition) important?
Perhaps you don't understand what CS is. CS isn't about C - in fact, it's not even about programming at all. CS is about the theory of computation. Things like programming language theory and computational complexity theory are subsets of CS.
CS doesn't include coding practices, use of source control, project/time management, or software testing. All of that is part of software engineering.
The problem is that people expect CS programs to produce functional software engineers. And while functional software engineers certainly need a strong grasp of theoretical concepts (such as a basic computational complexity theory and common algorithms), what they really need is software and systems engineering experience.