Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Programming IT Technology

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."
This discussion has been archived. No new comments can be posted.

Stroustrup Says C++ Education Needs To Improve

Comments Filter:
  • by Anonymous Coward
    When I attended college back in 1998 (Purdue), they decided to blindside everyone by teaching Visual J++ instead--Microsoft having "generously" donated the college discs containing the software. I'll never forget those fateful words from the professor: "I don't know this language myself, so I'll be learning it with you as we go." Let's not forget my favorite: "Java is the future of everything."

    One semester later I dropped out and never looked back to computer science again as a career choice. In fact, thoug
    • by thetartanavenger ( 1052920 ) on Sunday March 30, 2008 @08:59AM (#22911468)
      Where are they teaching it actively again? I'm a student on computer science at the moment and all they teach in any depth is Java. The only reason I know c++ is my desire to learn it, despite the fact that various parts of my course have recently required a fairly in depth knowledge of c++.

      My favorite lecturer quote, "Oh, I don't really do any coding at all".
      • Re: (Score:3, Informative)

        by cbart387 ( 1192883 )

        Where are they teaching it actively again?

        My school is. In fact, C++ is the primary language you learn on. There's some Java classes to expose you to it and even brief exposures to some other misc. languages (ADA/LISP/PROLOG). We also program in C for some of the classes geared towards UNIX system programming. It's a nice balance because with Java EVERYTHING is an object and it's likely to confuse freshman. Heck, it first confused me with these static mains coming from a C/C++ background. At least with C++ you can start with just functional p

        • by mcvos ( 645701 )

          It's a nice balance because with Java EVERYTHING is an object and it's likely to confuse freshman.

          Actually, one of the problems with Java is that not everything is an object. That's why I think Java will eventually be replaced by something much more Ruby-like (but with a bit more performance, please). But Java was written to replace C++ at the application level, and as such it does a tremendous job.

          • Re: (Score:2, Insightful)

            by cbart387 ( 1192883 )
            I'm full of errors today. I wasn't thinking of the primitives (double,int,char etc). I should have said something like 'first-time programmers have to use objects whereas C++ you can get away with keeping a procedural-oriented mindset. Therefore, you can limit what is introduced. Is that better? ;)
        • Re: (Score:2, Informative)

          by GringoCroco ( 889095 )
          >> you can start with just functional programming to get the basis of what is variable/function/const
          That's imperative programming.
          You get functional programming with lisp, scheme, python, ocaml, haskell.
        • At least with C++ you can start with just functional programming

          I believe you mean to say "procedural or imperative". You can use this paradigm before you start true OO programming in C++. For a functional language, try ML.

      • by skroll82 ( 935998 ) on Sunday March 30, 2008 @10:07AM (#22911916)
        "My favorite lecturer quote, "Oh, I don't really do any coding at all"." That's not a big deal. Computer Science is not about coding in particular, but understanding the practices to design and implement solutions to a problem. Computer Science is more about applied math then writing in language X. I learned some of the most important concepts in a class that was all done in pseudocode. Understanding how to approach a problem and solve it efficiently is more important then learning a language. In fact, once you know how most things are working, with a few basic concepts such as pointers or how a computer interpret an instruction listing, you should be able to pick up almost any language fairly easily. If you are not capable of learning things on your own without being handheld through a set of power point lectures, even if you knew C++ instead of Java you aren't going to be worthwhile in the real world anyways. You are destined to be a code monkey.
      • Re: (Score:2, Informative)

        by RockoTDF ( 1042780 )
        Keep in mind that Computer Science is *not* coding. It's a subfield of mathematics that deals with the theory of computation. The lecturer might have been a theorist.
      • I'm still astounded that a Computer Science curriculum includes any in-depth teaching of a programming language. Does the physics curriculum include courses on car repair? Does the biology curriculum include courses for the female students on how to land a good husband? Does the Literature curriculum include an in-depth study of calligraphy?

        OK, I'm exaggerating a bit for effect, but seriously, most of computer science doesn't even require a computer, let alone an in-depth knowledge of any particular computer programming language. Some universities seem to have CS curriculum that would be more at home at DeVry's than at a university.

        When you read Knuth, are you sitting in front of a computer? Gack, I bet that's what the kids nowadays do. The right way to read and study Knuth is sitting in a very fine leather chair, in front of a fireplace with fire, with a large dog sleeping at your feet, a drink in one hand, and classical music playing softly--and it should take along walk across a moor to reach the nearest computer.

      • Re: (Score:3, Insightful)

        by dark404 ( 714846 )
        Where are they teaching it actively again? I'm a student on computer science at the moment and all they teach in any depth is Java. The only reason I know c++ is my desire to learn it, despite the fact that various parts of my course have recently required a fairly in depth knowledge of c++.
        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
    • by Latent Heat ( 558884 ) on Sunday March 30, 2008 @09:52AM (#22911786)
      Let me get this straight, that some wieners at Purdue decided to teach Java instead of C++ in their Intro to Programming course, and that you had a wiener of a prof who was teaching you Java without adequate experience, this all put you on the path to dropping school, dropping your CS major, and taking courses at community college without finishing a degree?

      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.

    • by mcvos ( 645701 )

      Let's not forget my favorite: "Java is the future of everything."

      Everything is an exaggeration (Java isn't very big on low-level system/OS programming as far as I know), but on the application level, Java is the biggest, most succesful language ever, so he wasn't far off.

      Visual J++ was an obvious dead end, however.

    • by Capt. Skinny ( 969540 ) on Sunday March 30, 2008 @12:18PM (#22913100)

      I'll never forget those fateful words from the professor: "I don't know this language myself, so I'll be learning it with you as we go."

      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."

  • I completely agree (Score:5, Insightful)

    by betterunixthanunix ( 980855 ) on Sunday March 30, 2008 @08:25AM (#22911278)
    I completely agree with Stroustrup. Too many people these days have little or no exposure to C++, and never learn how programming in the absence of garbage collection works. It is especially problematic in our research labs, where computationally complex problems must be solved with very fast code, but the people writing it get completely confused by pointers and memory management. Worse is when a proof-of-concept is distributed, with horrible bugs and completely incomprehensible code.
    • more to it (Score:5, Interesting)

      by g2devi ( 898503 ) on Sunday March 30, 2008 @08:41AM (#22911368)
      That may be so, but there's more to it. It's only been recently fully implemented and a few years ago Stroustrup himself commented that he's constantly surprised that some things (e.g. template recursion) are even possible in C++.

      The language is overly complex. The key advice any C++ expert is "restrict yourself to a specific subset of C++". That's the bulk of the difficulty. If C++ were simplified to include only that subset, you'd have a lot less need for training,
      • Re:more to it (Score:5, Informative)

        by JohnFluxx ( 413620 ) on Sunday March 30, 2008 @08:57AM (#22911456)
        Sometimes you need the more complicated parts of C++ - It would be a very bad idea to simplify c++ to the lowest common denominator.

        For example, most people don't use the SSE stuff or even know about it. You can, for example, make a vector with 4 numbers in it and multiply it with another vector with 4 numbers in it. The result is that the four multiplications are done simulatanously.
        Most people won't use this functionality and thus don't even need to learn it, but when you need an algorithm to run fast, it is essential.
      • Re:more to it (Score:5, Informative)

        by smilindog2000 ( 907665 ) <bill@billrocks.org> on Sunday March 30, 2008 @09:11AM (#22911554) Homepage
        I couldn't agree more! Much of the worst code I've ever had to deal with is C++ code written by smart guys who don't know what parts of C++ to use. How about mixing double inheritance from template classes, with smart pointers and garbage collection, when all you're writing is quicksort? Smart guys can take a 100 line problem and turn it into a 10,000 line C++ solution.

        I focus instead on restricting programmers to the tools they need, so they focus their creativity on algorithms instead of coding methodology. I've even codified it all, as an extension to C [sf.net], rather than C++. Works great for team programming. I had a guy last week write two IC placers: simulated annealing, and quadratic placement, in 5600 lines of hand written code, debugged and working. He did it in 6 days while supporting a difficult client, without working weekends or evenings. I'd estimate his productivity at 10X to 100X higher than average.
        • Re:more to it (Score:5, Interesting)

          by shutdown -p now ( 807394 ) on Sunday March 30, 2008 @10:01AM (#22911870) Journal
          Unfortunately, even if you keep away from the more advanced stuff such as template metaprogramming, there's still plenty of surprising (in a bad sense) behavior in the most basic C++ constructs (mostly inherited from C, but exacerbated by C++ pretense at high-levelness, and with some new stuff thrown in for good measure). Pointer arithmetic, unsigned types, silent implicit narrowing conversions, PODs vs non-PODs (which in turn separate into aggregate types and everything else) and the subtle differences in initialization of those, ability to delete void* and pointers to incomplete types (and the wonders of virtual destructors), etc... The language is a mess, really. It is very powerful, and the existing code generators are very good at optimizing stuff, but writing in C++, or any subset thereof, requires a very good understanding of subtle details.

          A simple example: given a vector of ints, calculate the average value, using standard idiomatic C++. Let's give it a try:

          #include <algorithm>
          #include <iomanip>
          #include <iostream>
          #include <istream>
          #include <iterator>
          #include <numeric>
          #include <ostream>
          #include <vector>

          int main()
          {
          std::vector<int> v;
          std::copy(std::istream_iterator<int>(std::cin), std::istream_iterator<int>(), std::back_inserter(v));
          int avg = std::accumulate(v.begin(), v.end(), 0) / v.size();
          std::cout << avg << std::endl;
          }
          A simple task, and a clean implementation, using the standard library as much as possible. No fancy language features used - no template metaprogramming, no pointers, no virtual inheritance. The kind of stuff a new C++ programmer might write after reading Stroustrop. And yet, it gives wrong result for certain input data. Now, who'll be the first one to spot and explain the problem here, preferrably without actually running it? Bonus points for explaining why we need "istream", "ostream" and "iomanip" headers here in addition to "iostream" (and we do, if we want this to be portable).
          • Re:more to it (Score:5, Interesting)

            by truedfx ( 802492 ) on Sunday March 30, 2008 @11:22AM (#22912580)
            I'll admit I had to run the program, and even then it took me a while to see it.

            v.size() has vector<int>::size_type as its return type. Depending on which specific type, either that type will be converted to int, and all is fine, or the result of std::accumulate(v.begin(), v.end(), 0) is converted to an unsigned type, then divided, and then converted back to int. In the latter case, when you have a negative sum, the division gives the wrong result.

            I think the <istream> and <ostream> headers are required because the types of std::cin and std::cout might otherwise be incomplete, meaning operator<< might be undeclared. I know the <ostream> header is also required to that std::endl is declared. I'm not seeing what could be in <iomanip> that's of interest of your program. Could you explain that last one?
            • Re:more to it (Score:5, Interesting)

              by shutdown -p now ( 807394 ) on Sunday March 30, 2008 @11:58AM (#22912926) Journal

              I know the header is also required to that std::endl is declared. I'm not seeing what could be in that's of interest of your program. Could you explain that last one?.
              Ironically, it's my mistake - std::endl is also a stream manipulator, so I figured it is properly supposed to be in "iomanip" as well, and didn't bother to double-check (let's face it, in real world we usually just include "iostream" or other stream header as needed, and that's it - the rest gets dragged in, even if the Standard doesn't guarantee that it will). But you're absolutely right, std::endl is in "ostream", shame on me. And I've been coding fancy C++ stuff (with templates, STL, and all that) for five years now... *sigh* I guess it sort of serves to reinforce the point I've originally made :)
          • I look at your example and think, Huh? I used to code C++ (about 4 years ago) and since then shifted completely to C# and Java. And if I need some low level code I will write it in C.

            I talked to another individual about C++ and what he hates with C++ is that you are taking too much time thinking about infrastructure and not solving problems. Whereas in Java you think more about solving problems and less about infrastructure.
      • Re: (Score:3, Insightful)

        by Zeinfeld ( 263942 )
        The key advice any C++ expert is "restrict yourself to a specific subset of C++".

        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 mea

        • Re:more to it (Score:5, Insightful)

          by gbjbaanb ( 229885 ) on Sunday March 30, 2008 @10:07AM (#22911910)

          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
          You don't need to tech (sic) kids to write in C# for them to learn how bad an idea of GC is. Just give them some existing code and tell them to chase memory leaks [ibm.com] and finalisation issues.

          There, fixed that for you.
        • Re: (Score:3, Insightful)

          by Chapter80 ( 926879 )
          I agree. C++ served its purpose in the language world. It was a great FIRST STEP toward object oriented programming, but it has outlived its usefulness. Stroustrup should take pride in his great contribution, and not be discouraged because C++ has been superseded by other, better languages. C++ provided a bridge from the world of no objects in C, to the world of objects. But now that there are languages that are designed with objects in mind from the ground up, it's only academically interesting (and o
      • Re: (Score:3, Interesting)

        The language is overly complex. The key advice any C++ expert is "restrict yourself to a specific subset of C++". That's the bulk of the difficulty. If C++ were simplified to include only that subset, you'd have a lot less need for training,

        Yeah. That subset could be called something then to distinguish it; say, "Java". And then you could have a slightly larger subset with more advanced stuff, like pointers and value types; let's call that something more C++-like to reflect it: hm, how about "C#"? And sure

      • Re:more to it (Score:5, Insightful)

        by johannesg ( 664142 ) on Sunday March 30, 2008 @10:35AM (#22912158)
        The "restrict yourself" stuff is stupid. It's like saying "tie one hand behind your back while programming". Can you think of *any* other profession where professionals are advised not to use their best tools?

        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".
    • by schmidt349 ( 690948 ) on Sunday March 30, 2008 @08:43AM (#22911380)
      Yeah, but that doesn't sound like the sort of problem that gets fixed by learning C++, which has a nasty habit of adding loads of complexity in all the wrong places. If you want tight, fast code and your project doesn't need OOP, use C.

      As for programming pedagogy, I think we'd do a lot better if the faculty of CS departments would migrate away from using Java/C++ as the introductory programming model because so much of what gets said initially just goes in one ear and out the other. I will admit to not remembering at all how typedefs or templates in C++ work, and I can't say it's harmed me much.

      Python would be a much better choice in my view for a variety of reasons (and I say this though I'm a Perl nut!), or hell, if you teach them Lisp they'll be horribly screwed up for the rest of their lives but at least they'll understand how registers and OOP work.

      In short, novice programmers are not going to learn anything useful if you use C++ as the prescriptive model for how a well-written computer program should look -- they're just going to hit the bottle earlier in life.
      • by lexarius ( 560925 ) on Sunday March 30, 2008 @08:57AM (#22911454)
        Agreed. Also emphasize that, while Python is not as efficient as compiled languages, you can come back later and rewrite important parts of it in C. Then you can teach C with an emphasis on high-performance computing, rather than the typical "here's how we ask for user input, here's how we copy strings" emphasis typically taught in C courses that I've seen. Eventually, you could then show them how to add in assembly code to get at special-purpose processor operations not exposed by C. Probably do this over the course of a few semesters though.

        Hell, who am I kidding. Just teach them to code in brainfuck. Or maybe INTERCAL. Normal languages will seem much nicer after that.
      • As for programming pedagogy, I think we'd do a lot better if the faculty of CS departments would migrate away from using Java/C++ as the introductory programming model because so much of what gets said initially just goes in one ear and out the other.

        Even better would be if they didn't get involved in ideological wars about languages, and focussed on the *concepts* they wanted to teach. If students really are coming out of these courses with certificates saying "computer science" which should read "Java forms design for data centers" then arguing the merits of Java,Lisp,C++ or Son Of The Return of the Bride of BASIC isn't going to fix anything. If you're gonna call the course "Computer Science" then students should come out knowing a decent wodge o

        • by mcvos ( 645701 )

          Real Programmers can do Object Oriented Programming in FORTRAN... Well, maybe not, but you can certainly lay out a (regular) C program using some of the basic OOP principles - its just up to you to "enforce" them (like everything in C).

          True, but Real Programmers also know not to use C for things it's not intended to. C is for high-performance systems programming, maintainable application programming is much easier and faster with a higher level language.

      • by Latent Heat ( 558884 ) on Sunday March 30, 2008 @10:26AM (#22912062)
        The trend we need to fight is not teaching programming using Java, C, or C++, but defaulting to Matlab as a programming language of choice. This is what is happening in Engineering colleges and other non-CS places at the U.

        Granted, Engineering always went for things that CS considered "brain dead" -- Basic, PC's, DOS, Windows. But Matlab is more brain dead than most.

        What happened is that a lot of the current generation of Engineering profs cut their teeth on FORTRAN -- their Intro to Programming was in FORTRAN, whatever industrial job they had before getting a PhD had them compute things in FORTRAN. Few of them were ever comfortable in it and most of them spent hours in the computing center debugging programs dumped to massive punch card decks.

        When Matlab came around, it was numerical Nirvana. It had this massive numeric library that you didn't have to write your own Q-R linear equation solver or SVD subroutine, and you didn't have to go searching for this stuff either, it was all there. It had a command prompt to performed immediate execution along with reasonably friendly error messages. And it acquired a thoroughly feature-full graphics package.

        Don't get me wrong, Matlab is a very capable numerical applications language and even turns out to be one of the better Java scripting languages of all things. But it really falls down in terms of extensibility of its type system, and as far as what Mathworks tacked on for object-oriented programming, fuggedaboutit. It is also the Swiss Army knife of software for a whole bunch of people, and forget about introducing them to a socket wrench and handle that can apply serious torque to a bolt when they think they can get by with the pliers tool.

        While people who know what they are doing can benefit from the convenience of the numeric and graphics libraries, the immediate mode, the verbose error handling and rare instances of complete crashes, if you don't know what you are doing (i.e. you are just learning), it can lead to as many hour-gobbling skull-cracking debug sessions as anything else. Our required Numerical Methods course is in CS, it uses Matlab, our faculty is complaining that the students are complaining that they hate the course because they are spinning their wheels trying to get programs to run (in Matlab of all things), and we have guys in our department we want to teach Numerical Methods (in Matlab, of course), in the context of a watered-down Intro to Engineering offering.

        What the community needs right now is a Python distro with enough of a numerics and graphics package rolled in to do 90 percent of what is in Matlab (Are the Python people still hashing out that Numerics/Numpy divide? Is there an engineering graphics library that is Numerics/Numpy compatible? 99 percent of what you do in Matlab is that you have a Leatherman Tool of a 2-D array type (Matlab, Matrix Lab) along with all of the libraries being compatible with that type.) CS departments could teach their Intro to Programming along with their Numerical Methods courses using that Python distro, and we can save a generation of engineers from brain damage.

        • by William Stein ( 259724 ) <wstein@gmail.com> on Sunday March 30, 2008 @12:01PM (#22912954) Homepage
          > What the community needs right now is a Python distro with enough of a
          > numerics and graphics package rolled in to do 90 percent of what is in
          > Matlab.

          Good idea. This is what both Sage [sagemath.org] and the Enthought Python Distribution [enthought.com] are
          shooting for.

          > (Are the Python people still hashing out that Numerics/Numpy divide?

          No that is done. And the lead developer of Numpy -- Travis Oliphant --
          now gets to work full time on Python scientific computing, as an
          employee of Enthought [enthought.com].

          > Is there an engineering graphics library that is Numerics/Numpy compatible?

          There is Matplotlib [sourceforge.net] for
          matlab like numpy graphics, and Chaco [enthought.com] for more dynamic 2d graphics. MayaVi [enthought.com] and Sage [sagemath.org] both provide powerful 3d graphics.
    • Comment removed based on user account deletion
      • by bsane ( 148894 ) on Sunday March 30, 2008 @09:11AM (#22911560)
        The O'Reilly books are an example of the problem here.... their C++ books are the worst O'Reilly books I've ever read. It wasn't until I picked up 'The C++ Programming Language' by Strousup that I realized my mistakes and what C++ was really capable of.

        I agree with the premise that C++ is a great language, that is poorly understood, and often mis-used. Education would seem to be the answer to that.
        • It wasn't until I picked up 'The C++ Programming Language' by Strousup that I realized my mistakes and what C++ was really capable of. - And if you pickup a similarly named book by this guy, named Stroustrup, your previous realizations will be dwarfed by the new set of information ;)
        • Re: (Score:3, Insightful)

          by laffer1 ( 701823 )
          I'm going to have to disagree. The C++ Programming Language is useless to actually learn the language and often times it fails as a reference. If all the ego was removed from the book, it might be useful for something. Compare it to K&R. You'll notice a difference in tone. I realize not everyone likes K&R, but aside from the chapter on pointers I feel it is a very concise book that allows one to pickup the basics of C very quickly.

          I am not alone in my opinion. Consider the difference in rank o
    • I completely agree with Stroustrup.

      I agree and I point the finger (I have to blame someone don't I?) at architects who don't understand what computer code is. Have you ever been presented the next amazing design for a solution and thinking, "am I a magician or a software developer?". If an architect has had some contact with code then the solutions tend to be a little more realistic. ;)
    • by gbjbaanb ( 229885 ) on Sunday March 30, 2008 @09:26AM (#22911630)
      I agree too, to quote TFA: "Conversely, there is now a generation who is firmly convinced that a program is only well-designed if just about everything is part of a class hierarchy and just about every decision is delayed to run-time."

      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.
    • by mcvos ( 645701 )

      Too many people these days have little or no exposure to C++, and never learn how programming in the absence of garbage collection works.

      Most people don't need exposure to C++, because most people don't do any systems programming. C++ is for operating systems and drivers, and was never intended for application programming. I think it makes most sense for people to start on something like Java (or Lisp, perhaps), and once they've figured out they want to do systems programming, teach them C and C++. If, instead, they want to go towards application programming, teach them a higher level language like Python or Ruby.

      It is especially problematic in our research labs, where computationally complex problems must be solved with very fast code, but the people writing it get completely confused by pointers and memory management. Worse is when a proof-of-concept is distributed, with horrible bugs and completely incomprehensible code.

      Sounds like they cho

  • by bfwebster ( 90513 ) on Sunday March 30, 2008 @08:38AM (#22911350) Homepage
    ...is that C++ is a rather complex and brittle language. :-) ..bruce..

    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.
    • Re: (Score:2, Interesting)

      "...is that C++ is a rather complex and brittle language. :-) ..bruce.." That's not so much a problem as it is the nature of computers. Computers and the logic that runs them is complex and brittle, thus why it is important that developers understand a lower-level language like C++. If you don't understand the underlying system for which you are developing, you won't be efficient or effective at doing what you're attempting to do.

      It reminds me of this: http://thedailywtf.com/Articles/It-Had-Too-Many- [thedailywtf.com]
      • by ubernostrum ( 219442 ) on Sunday March 30, 2008 @09:25AM (#22911624) Homepage

        Computers and the logic that runs them is complex and brittle, thus why it is important that developers understand a lower-level language like C++.

        ...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: (Score:3, Insightful)

          by wrook ( 134116 )
          I wish I had mod points. While I agree with the grand (grand?) parent post, it didn't really provide any information (not sure why it was modded +5 interesting...). This post really explains the issue faced by many would-be C++ programmers. It's a long learning curve to write modern style C++ code. Not only that, but many people don't even realize *why* they would want to program this way. The bash out some horrendous code that nobody on earth can maintain.

          C++ is also complex in and of itself, but ther
          • Re: (Score:3, Insightful)

            by bfwebster ( 90513 )
            To be honest, I would have been tempted to score my own post as flamebait, though it was not intended as such. Let me quote from myself back in 1995, in the Bibliography section of my book Pitfalls of Object-Oriented Development (M&T Books, 1995):

            The Design and Evolution of C++, Bjarne Stroustrup, Addison-Wesley, Reading, Mass., 1994. This is a good book to have when you reach a point in your C++ studies that you want to throw things through windows. In the first place, it allows Stroustrup to explain t

        • Re: (Score:3, Insightful)

          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.

          Absolutely. This is fairly easy to check, too; here [open-std.org]'s the most

      • by jellomizer ( 103300 ) on Sunday March 30, 2008 @09:48AM (#22911760)
        C++ is a process of reinventing the wheel over and over. The performance gains of doing things in C++ is usually lost because it wears down the programmer, and leads to sloppy coding. Higher Level Languages as part of the core language comes with many useful functions that are programs relatively good efficiency. Lets say Pythons List Data type where you can do a Sort on it or a concatenate, or get a sub list off of it, and more too. Yes you can do the same functionality with C++ but you need to make it yourself and build the Data Type and add the functions to do it, or get a library that may not work on an other platform or needs more libraries to work. But what will normally happen to a C++ Developer they will make a less efficient hack to the data type they actually want, just to save time. So unless you are really obsessed with performance in your code C++ will often lead to slower application and it will take much longer to code anyways. Higher Level Languages let you focus on getting what you need done and a degree of trust on what you are going to do will do it fast enough.

        It will take a lot of effort for someone to make good clean code, fast and efficient, easy to read, easy to update, well commented and bug free. C++ is only a good language if you have the tolerance to code that carefully over a long time.

        For real life upper level languages the the job done faster better and easier.

        For terms of Teaching Computer Science C++ isn't a good language at all. The problem is the students are focused more on getting the damn thing to compile finding where they missed the ";" vs. Understanding the logic and concepts being taught. I knew C before I started college so doing C++ wasn't much of a stretch, so I got more out of my education then some of the other students who didn't have the background their view is If it compiles then it is done.
        • Re: (Score:3, Informative)

          by jgrahn ( 181062 )

          C++ is a process of reinventing the wheel over and over. The performance gains of doing things in C++ is usually lost because it wears down the programmer, and leads to sloppy coding. Higher Level Languages as part of the core language comes with many useful functions that are programs relatively good efficiency. Lets say Pythons List Data type where you can do a Sort on it or a concatenate, or get a sub list off of it, and more too. Yes you can do the same functionality with C++ but you need to make it you

    • Re: (Score:3, Interesting)

      by pyrrhonist ( 701154 )

      ..is that C++ is a rather complex and brittle language.

      To fully understand what Bruce means, read this [yosefk.com]

  • by Lord Byron II ( 671689 ) on Sunday March 30, 2008 @08:48AM (#22911398)
    I'm continually amazed that the CS majors at my major US accredited university can't program using pointers, object oriented techniques, or parallelism. I think that there is an attitude among the professors that this material is difficult, so it shouldn't be worth a lot of points. As a result, the students don't bother to learn it.

    I work in another department and sadly, without formal CS experience, I'm a better programmer than many (if not most) of the CS department's graduates. I don't think, however, that this problem is unique to my school. I've visited other US universities where the situation is very similar.

    In fact, I recently took an informal survey of about a dozen CS seniors and found that none (yes, none) of them knew what K&R, the "white book", or the "Art of Computer Programming" were.
    • by IamTheRealMike ( 537420 ) on Sunday March 30, 2008 @08:58AM (#22911460)

      My university course spent about half an hour on pointers in a 3 year course. Most of that half hour was factually wrong: the slides were full of code samples that wouldn't compile or would always crash.

      They did, however, spend two terms teaching Hoare logic. Or rather, they spent one term teaching it, and then repeated the same material in another term with a different lecturer, because their communication was so poor they never realised they had duplicated their teching.

      Friends at other universities reported similar stupidities, though not always on the same scale.

      C++ is a rather complex language, but simplifying it won't help. The problem is that low quality education is rampant.

      • C++ is a rather complex language, but simplifying it won't help. The problem is that low quality education is rampant.

        I think you're having a "Tastes great / less filling" argument. Good education can somewhat prepare a person to learn and use an overly complex language. A bad education leaves a person less prepared to do so.

        Having programmed in C++ for many years, and having lived through its evolution to include its nightmarish template system with its nearly incomprehensible error messages even fo

    • Re: (Score:3, Insightful)

      In fact, I recently took an informal survey of about a dozen CS seniors and found that none (yes, none) of them knew what K&R, the "white book", or the "Art of Computer Programming" were.

      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

  • by Anonymous Coward on Sunday March 30, 2008 @08:49AM (#22911416)
    I think COBOL and Fortran education needs to improve. Nobody knows how to use it nowadays. These kids and their OO languages... HEY! Get off my lawn.
  • by Pinky's Brain ( 1158667 ) on Sunday March 30, 2008 @09:03AM (#22911496)
    "The standard will be finished in late 2008, but it takes forever to go through all the hoops of the ISO process."

    They have a solution for that ...
  • Disclaimer -- I'm a systems guy. I think I have a unique perspective though -- I get to deal with lousy software after it's been released.

    I came into IT through the back door. I was a science major in college, messed with computers all the time as I was growing up, and realized I could make a better living in IT than I could in science. So yes, I don't have a ton of programming experience. I have picked up a lot of information over the years on how operating systems actually work under the hood though.
    • Computers have gotten so fast and powerful that there's no need to optimize code anymore. This explains why everyone's programming in Java and .NET.

      I was with you up until the above. What? No, no. Java and .Net are popular because you get the power and flexibility of C++ and other compiled OO languages, but you get the increased productivity that managed code gives you. It is a *lot* easier to create an application in Java or .Net that is good enough, runs fast enough, and has no memory leaks, than it is to create the same application in C++.

      There is a bunch of stuff where C++ is a much, much better choice than Java or .Net, but for the majority of co

      • Teaching lisp, prolog, simula etc at university is an excellent idea. Make them think.

        As for .Net being better - tell the Princeton university DARPA team that C# doesn't have memory leaks. Read Chris Brumme's blog [msdn.com] for all the grubby hacks that MS made in the CLR to make things work.

        the thing is, if you tell a less-capable programmer that he doesn't have to worry about memory, he'll think christmas has come early and he will stop worrying about memory... as a result his code will become poorer, resource cons
  • There seems to be a direct relationship between level of abstraction meaning complexity required in application and the learning curve.

    A trade off of higher learning curve for faster programming with more complex abstractions vs. lower learning curve for less abstract complex language application.

    In the simplest example and using the basis of common computers:
    When you mark a switch with a symbol of a "0" and a "1" what does it mean? On/Off or a variation inbetween these like standby, sleep, or any other thi
  • by 192939495969798999 ( 58312 ) <info AT devinmoore DOT com> on Sunday March 30, 2008 @09:35AM (#22911686) Homepage Journal
    Profs. Einstein and Hawking are upset that people don't know more phyiscs, James Gosling is upset that people don't code better Java, and Picasso is upset that more kids don't take art class.
  • Does anyone still USE C++ any more? Seems the only ones around where I work who even know C++ are the old timers. Recently, the consulting company I work for had the opportunity to hire a number of C++ programmers for a legacy project - we had one guy on staff, and couldn't find ANYONE else with the necessary skills.
  • by MichaelCrawford ( 610140 ) on Sunday March 30, 2008 @10:01AM (#22911880) Homepage Journal
    They're at GoingWare's Bag of Programming Tricks [goingware.com], and are more in depth than most online tutorials.

    The articles are:

    • Sermon at the Soup Kitchen: On C++ Software Quality and Institutional Resistance to Change
    • Pointers, References and Values: Passing Parameters, Returning Results, and Storing Member Variables with Musings on Good C++ Style
    • On Refactoring C++ Code
    • Pointers to C++ Member Functions
    I'm no Stroustrup, but I've received quite a bit of praise for writing these.

    • by Scareduck ( 177470 ) on Sunday March 30, 2008 @11:12AM (#22912480) Homepage Journal
      After agonizing over a problem that in theory should have been made simpler by operator overloading (I'm trying to do some numerical integration using a multi-precision library), I typed "c++ sucks" into Google. Lo and behold, but Linus Torvalds agrees with that sentiment [gmane.org]:

      C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

      ...

      C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes:

      • infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny)
      • inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.
      In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.
      And the ridiculous thing is, this wasn't written ten years ago when C++ was still going through the ISO standardization process — it was written last year!

      For the record, I'm inclined to agree with Torvalds. The main problem with C++ is its insane levels of complexity and its unerring eye for adding subtle and difficult-to-diagnose problems once things like multiple inheritance get factored in.

  • Sadly... (Score:3, Funny)

    by Kingrames ( 858416 ) on Sunday March 30, 2008 @10:16AM (#22911968)
    When trying to point the blame, his pointers went everywhere, and his program terminated abruptly.
  • by Animats ( 122034 ) on Sunday March 30, 2008 @10:20AM (#22912000) Homepage

    The big problem with C++ is Strostrup. He's in denial about the fact that the language is fundamentally broken. But he's still influential in C++ circles. Thus, no one else can fix the mess at the bottom.

    The fundamental problem with C++ is that it has hiding ("abstraction") without memory safety. This is the cause of most of the world's buffer overflows. No other major language has that problem. C has neither hiding nor memory safety, so it is still vulnerable to buffer overflows, but they're to some extent visible at the place they occur. Pascal, Modula, Ada, Java, C#, and all the interpreted "scripting languages" have memory safety. C++ stands alone as a language where you can't see what's going on, and the compiler doesn't have enough information to check subscripts.

    The reaction of the C++ standards committee has been to try to paper over the problems at the bottom with a template layer. That didn't work. The template classes just hide the mess underneath; they don't make the language memory safe. There are too many places that raw pointers leak out and break any protection provided by the templates. The template language itself is deeply flawed, and attempts to fix it have resulted in a collection of "l33t features" understood and used by few, and too dangerous to use in production code.

    The fundamental cause of the trouble comes from C's "pointer=array" equivalence. That was a terrible mistake, borrowed from BCPL. The trouble is that the compiler knows neither which variables are arrays nor how big the arrays are. You can't even talk about arrays properly. I mean, of course,
    int read(int fd, char* buf, size_t len);
    That's just trouble waiting to happen. "read" has no information about how big "buf" is.

    C++ added references to C, and should have added syntax like
    int read(int fd, char& buf[len], size_t len);
    to go along with it, so that arrays became first-class objects with sizes. But it didn't. There are some other things that have to be done to the language to make this concept work, but this is the general idea. This is the elephant in the living room of C++, and Strostrup is in denial about it.

    Every time you have another crash from a buffer overflow, every time you install another patch to fix a buffer overflow, every time you have a security break-in from a buffer overflow, think of this.

    • Re: (Score:3, Insightful)

      by vectra14 ( 470008 )
      Wow, how were you modded "Troll"? I'd mod you up if I could.

      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
      • by Animats ( 122034 ) on Sunday March 30, 2008 @01:56PM (#22913810) Homepage

        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.

        Not really. I'm not asking for array descriptors. I'm not proposing to change the run-time representation of arrays. What I'm talking about is a generalization of array declaration syntax.

        Until C99, array declarations always had to have constant array sizes. C99 introduced on-stack arrays, so in C99 you can write:

        int fn(size_t n);
        { float tab[n]; /* on-stack array, sized based on fn parameter */
        ...}

        This was the first syntax which allowed a run-time variable in an array definition, and it was a big help, because it saved a malloc call inside of number-crunching libraries. (Numerical Recipes in C had this problem, and FORTRAN didn't.).

        The next logical step is to allow that syntax in more places, like function parameters. This doesn't require passing an array descriptor. The programmer gets to specify the expression that defines the array size. So there's now a way to talk about array size that the compiler understands. Checking becomes possible.

        Of course "sizeof" and "lengthof" should be extended to such arrays, so you can write:

        int status = read(infd, buf, sizeof(buf));

        Giving up pointer arithmetic is too much to ask C and C++ programmers, but restricting pointers to iterator syntax (valid values are NULL, a pointer to an element of the array, and one past the end of the array) makes them checkable. There are checking iterator implementations, so this is possible.

        Once the compiler knows what's going on with arrays, subscript checking can be optimized. This is well understood. In particular, subscript checks within for loops can usually be optimized ("hoisted" is the term compiler writers use) so that there's one check at the beginning of the loop, and often that check can be folded into the loop termination condition. So the checking cost in matrix-oriented number-crunching code is usually zero.

        There's more to this, and it isn't painless to remove this ambiguity, but if we had a "strict mode", where the checkable forms have to be used, there's a transition path.

        If all code running as root had to be in "strict mode", we'd be way ahead.

    • Re: (Score:3, Insightful)

      by ceroklis ( 1083863 )
      I think the main problem of C++ is that people who know C assume they automatically know C++ as well. They don't. You might want to read up on this std::vector thing.
  • Give it up Bjarne (Score:4, Interesting)

    by betelgeuse68 ( 230611 ) on Sunday March 30, 2008 @11:26AM (#22912622)
    I spent 2-1/2 years at MS and if it is one thing that disappointed me it is how indifferent most developers were about learning C++... which prevented them from writing great code. Afterwards, I worked with some *NIX snobs in a dotBomb and all they ever did was trash C++ (somehow Java was "great" though).

    Few could tell you why you necessarily want to make your destructors virtual, why not doing "delete [] array" is not necessarily a memory leak, where must references be initialized, why it's good practice to use (at the time) the new cast notation... the list went on.

    It's been a decade, I've started to forget all that material. I followed the ANSI committee, read most issues of "C++ Report" and wrote some of my best code during my days at MS. Unfortunately I can't say I found many people who could relate with verve for putting out great code. (All you trolls, this is about a programming language, not about any specific product or company, go outside, run 'til your heart feels like it's going to give out so your thoughts gravitate elsewhere... better yet, let it give out)

    Sayonara C++,
    -M

    PS: C++ has become niche Bjarne.
    • Re: (Score:3, Interesting)

      by Sweetshark ( 696449 )

      Few could tell you why you necessarily want to make your destructors virtual, why not doing "delete [] array" is not necessarily a memory leak, where must references be initialized, why it's good practice to use (at the time) the new cast notation... the list went on.

      This exactly highlights the problem of C++:
      Either you are doing low-level system programming in which case C++'s OOP abstractions wont help you anyway.
      Or you are doing high-level coding in which case C++ doesnt help you because its abstractions are so leaky, they arent making stuff easier but unfortunately even more complex (manual management of virtual/nonvirtuals, memory/resource management, etc.).

      C++ always was a kludge, its only raison d'etre was that many other languages weren't there yet and oth

  • by dwarfking ( 95773 ) on Sunday March 30, 2008 @12:09PM (#22913020) Homepage

    Reading the threads, many people are discussing the relative merits of the other programming languages/environments - Java/C#/Python/etc - but what do all of those have that C++ does not have?

    More complete environments.

    When you install a C++ compiler, you get a C++ compiler and the standard library. When you install Java or C# or Python you get libraries to support simplified Networking, IO, Database access, GUIs, Memory Management, Threading and more.

    Now it is possible to find all that for C++, but they are all separate components that the developer needs to decide on and download. And the number of choices for each is large. Do you use wxWidgets or FLTK or GTK+ for GUI, for example.

    The other environments actually reduce your options, and for projects on a timeline the less time you spend on determining what you need to accomplish the task, the sooner you finish. Yes you can bring in replacement libraries in Java or Python or C#, but few people do. The folks that wrote those libraries did a pretty reasonable job on them, and since they are bundled with the standard installers, unless there are really specific needs, there's rarely a reason to replace them.

    Look as an example of this at the Mono project. It is an attempt to provide the C#/.Net environment outside of Windows, but it does not have as much traction as .Net on Windows, why? in part because the .Net frameworks are more complete on Windows than in Mono. I not many .Net developers that use WindowsForms in every project. Without that piece of the eco-system already available, their project would take much longer. Mono basically provides C# for Linux, just another programming language.

    I've watched over the years as some folks tried to assemble Java-like libraries for C++, but they didn't really take off.

    This appears to me as why C++ has the reputation of being so hard to build applications in. The developer has to do so much extra work just to get to the point of assembling the program that the Java or Ruby or C# or Python crowd gets out of the box. Is this the fault of C++? Not the language, but perhaps it is something the steering committe should address. As someone pointed out in an earlier thread, the C++ standard group likes to make the comment that a particular given feature is not part of the language. Perhaps they should rethink that stand.

    As point of background, I started working with C++ when it first appeared as a pre-processor that created C code that was compiled by a C compiler (when you had to use the keyword Overload). I later moved into Java and have made a good living doing Java development. Recently though I have gotten deep into programming in 3D graphics with OpenGL. I'm doing it both in Java (using jogl) and C++ (direct gl calls as well as engines). This is one area where there is not a clear choice for any platform, but because in the Java world I have the Networking and Threading, I was able to put a system together much quicker than I could in C++. Of course the Java approach has it's own problems because of the sheer volume of objects created/destroyed (imagine a 3D model made of Vector3D objects), so I end up using C++ approaches using float[] arrays (also an object, but only one).

    Sorry for the ramble. Anyway, the point is, I personally think C++ would be more acceptable if it really was an eco-system and not just a programming language.

Genius is ten percent inspiration and fifty percent capital gains.

Working...