Follow Slashdot stories on Twitter

 



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 on Sunday March 30, 2008 @09:30AM (#22911318)
    Last time Bjarne changed C++, he broke the I/O libraries which gave many of us the thrill of having to go back through old code and rewrite it for no other reason that Bjarne wanted to change something. We got no value out of the changes. They just wasted a lot of people's time.

    Bjarne: C++ should evolve, but there's a mass of C++ code already out there. Improve it please, but don't make us go back and rewrite existing code.
  • Re:more to it (Score:5, Informative)

    by JohnFluxx ( 413620 ) on Sunday March 30, 2008 @09: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.
  • by thetartanavenger ( 1052920 ) on Sunday March 30, 2008 @09: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:more to it (Score:5, Informative)

    by smilindog2000 ( 907665 ) <bill@billrocks.org> on Sunday March 30, 2008 @10: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.
  • by bsane ( 148894 ) on Sunday March 30, 2008 @10: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.
  • by cbart387 ( 1192883 ) on Sunday March 30, 2008 @10:14AM (#22911582)

    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 programming to get the basis of what is variable/function/const etc and save objects till the second semester. From my experience that seems to work pretty well.
  • by GringoCroco ( 889095 ) on Sunday March 30, 2008 @10:55AM (#22911818)
    >> 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.
  • by MichaelCrawford ( 610140 ) on Sunday March 30, 2008 @11: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 RockoTDF ( 1042780 ) on Sunday March 30, 2008 @11:15AM (#22911962) Homepage
    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.
  • by William Stein ( 259724 ) <wstein@gmail.com> on Sunday March 30, 2008 @01: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.
  • Re:more to it (Score:3, Informative)

    by shutdown -p now ( 807394 ) on Sunday March 30, 2008 @01:09PM (#22913022) Journal
    No, my concern was with Standard compliance. If you merely want this code to run on any existing C++ compiler, half of those includes could be safely removed - just "iostream" would suffice. There's just no guarantee it won't suddenly stop compiling tomorrow on gcc 4.5 ;)
  • Re:Right on (Score:2, Informative)

    by mollymoo ( 202721 ) * on Sunday March 30, 2008 @01:11PM (#22913034) Journal
    Most coding in the real world isn't writing performance critical distributed applications which are the cornerstone of multi-billion-dollar corporations. It's writing business apps and websites. For those, Java and C# shit all over C++, because they make not fucking up much, much easier.
  • Re:more to it (Score:3, Informative)

    by shutdown -p now ( 807394 ) on Sunday March 30, 2008 @01:26PM (#22913150) Journal

    Did I mention using the right tool for the job? Use perl for this example.
    Why would one in a sane mind want to use a language explicitly designed around string processing for number crunching?
  • by jgrahn ( 181062 ) on Sunday March 30, 2008 @01:56PM (#22913378)

    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.

    Have you ever used C++? Python's lists correspond (roughly) to C++'s std::vector, and the Python list sort() method corresponds to C++'s std::sort(). No need to reinvent any wheels here.

    In case you just meant that there is no exact match for the Python list class in C++, then that's true. But that is true for all languages but Python. Also keep in mind that Python (which I like and use regularly) buys its incredible powerfulness and simplicity by being one of the slowest languages around. One of C++'s design goals was to never be so slow that the user has to resort to another language, and that prevents it from having much of Python's convenience.

  • by mcvos ( 645701 ) on Sunday March 30, 2008 @05:12PM (#22915024)

    I've been a professional Java programmer for 2 years now, and the more I use it, the less I like it. Java behaves like an advanced scripting language, and it's great as long as the programming tasks stay reasonably simple. But beyond some hard-to-define point, where I'm right now, Java just doesn't cut it. Too many pitfalls, too many workarounds.

    In my experience there's no language that's more suitable for gigantic software projects with millions of dependencies than Java. Admittedly I don't have much experience with Python and Ruby yet, and while I see those two as advanced scripting languages, other people keep using them to build large software projects in less time than it takes in Java. But compared to C++, maintaining very large projects is much easier in Java.

    If you can try to define your point, pitfalls and workarounds, perhaps someone here can give you some advice. On the other hand, all large, complex projects have their pittfalls and occasionally require workarounds. It simply comes with the software engineering territory.

  • Re:myth (Score:3, Informative)

    by Pseudonym ( 62607 ) on Sunday March 30, 2008 @07:43PM (#22916126)

    The difference between C++ and most OOP languages is that C++ is basically a procedural programming language which has support for classes and objects integrated into it.

    Wrong.

    C++, like every sufficiently useful programming language, is a multi-paradigm language. It is dominantly procedural, this is true, but it also has language support for OOAD (which is not the same thing as OOP, as you correctly pointed out), generic programming, generative programming and facilities for adding embedding different kinds of of DSELs in convenient library form.

    Anyone who says "C++ is object-oriented" are, much like those who refer to the non-existent language "C/C++", probably using C++ incorrectly.

  • Re:more to it (Score:2, Informative)

    by maxwell demon ( 590494 ) on Sunday March 30, 2008 @11:08PM (#22917402) Journal

    And yet, it gives wrong result for certain input data.

    Well, the first problem I see with this code is that it uses integer division. The fact that "/" on integers gives an integer division isn't just a problem of C++, but of many languages (Pascal did get it right by using a separate operator, div, for integer division, and reserving / for float division). Thus if you enter the numbers "1" and "2", instead of the correct answer 1.5 you'll get 1. To get floating point division, you must have at least one of the types be a floating point type. This could e.g. be done by replacing v.size() with double(v.size()) or (preferrably, because it avoids a type cast) (v.size() + 0.0). Of course, the variable avg shouldn't be int either, but a floating point type.

    Another problem of the code is related to the fact that v.size() is an unsigned type, which will give unexpected results if the sum on the left is negative (but then, this problem wouldn't occur if the correct floating point division was used). This is due to the rule inherited from C that mixing signed and unsigned in arithmetics will cause the signed value be converted to unsigned. This can also give other surprising results; e.g. v.size() > -1 will always evaluate to false.

    The code also has other problems, like missing error handling for I/O errors and for empty sequence (i.e. no numbers given at all, which will result in division by zero). But that's hardly a language problem.

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

    We don't. Only "iostream" (for std::cin and std::cout) and "ostream" (for operator>, but istream_iterator for input (the fact that istream_iterator internally uses operator>> is irrelevant here; it's the job of the "iterator" header to make sure everything needed in the implementation of the iterator is included; indeed, on a compiler implementing export, might only be included in the corresponding .cc file of "iterator" (and thus not even indirectly in your own translation unit). Moreover "iomanip" isn't needed because you don't use any of the manipulators defined there (you need "iomanip" only for iterators which take arguments).

The hardest part of climbing the ladder of success is getting through the crowd at the bottom.

Working...