Slashdot Mirror


Bjarne Stroustrup Reveals All On C++

An anonymous reader writes "Bjarne Stroustrup, the creative force behind one of the most widely used and successful programming languages — C++ — is featured in an in-depth 8-page interview where he reveals everything programmers and software engineers should know about C++; its history, what it was intended to do, where it is at now, and of course what all good code-writers should think about when using the language he created."

371 comments

  1. Oh... my... god... by Anonymous Coward · · Score: 3, Funny

    C++ is a woman?! I didn't see this coming.

    1. Re:Oh... my... god... by damn_registrars · · Score: 1

      C++ is a woman?! I didn't see this coming.
      Sorry, but we're talking about C++ here. You may have this confused with an earlier slashdot story.
      --
      Damn_registrars has no butt-hole. Damn_registrars has no use for a butt-hole.
    2. Re:Oh... my... god... by Anonymous Coward · · Score: 5, Funny

      It shouldn't be that surprising. The new operator should have given it away. After all, in C++ you can create objects (children) that consume resources and don't clean up their garbage. The secret to how it works is that C is a man.

    3. Re:Oh... my... god... by valentingalea · · Score: 0

      A really hot one I might add!

    4. Re:Oh... my... god... by PPH · · Score: 2, Funny

      Is that you, Verity Stob?

      --
      Have gnu, will travel.
    5. Re:Oh... my... god... by omnipresentbob · · Score: 1

      And here I thought he was going to reveal the C++ was gay...

      http://www.sfgate.com/cgi-bin/article.cgi?f=/n/a/2007/10/19/entertainment/e190351D69.DTL

    6. Re:Oh... my... god... by mav[LAG] · · Score: 4, Funny

      C++'s social life is a bit weird as well: I hear that friends have access to your privates.

      --
      --- Hot Shot City is particularly good.
    7. Re:Oh... my... god... by zaphle · · Score: 1

      that's why I always define the macro

      #define girlfriend friend

      because I only want girlfriends to touch my privates.

      --
      And what if there's nothing behind the door until it is being opened?
    8. Re:Oh... my... god... by mstrange · · Score: 1

      This is the funniest comment I've read in months. Nicely done.

      --
      Matt Strange, Autograph Systems
    9. Re:Oh... my... god... by Anonymous Coward · · Score: 0

      Are you 12 years old?

    10. Re:Oh... my... god... by mrriver · · Score: 1

      Yes. A friend can access any private member and do anything with it. But it is a project choice. It is very useful when you want to give access to a members to a other code but this access rights aren't spread to all classes like public members. It's good because it follows the "need to know principle". A piece of code must to know just whay it need to know. Nothing more. Just the class itself and it's friends has that rights. Ok. You can do something like that with, for instance, packages in Java. But in C++ there is no packages. It's about the language philosophy.

    11. Re:Oh... my... god... by mav[LAG] · · Score: 1

      Yes. A friend can access any private member and do anything with it.

      Just as long as they realise they're going to be in punching range if they want to try anything.

      It's good because it follows the "need to know principle"

      Yep. And my friends don't need to know anything about my private member.

      It's about the language philosophy.

      And trust I imagine. Lots of trust.

      --
      --- Hot Shot City is particularly good.
  2. Normal Read by MoonlightSeraphim · · Score: 5, Informative
    1. Re:Normal Read by Anonymous Coward · · Score: 3, Funny

      Where is the printf() version?

    2. Re:Normal Read by Anonymous Coward · · Score: 1, Funny

      don't you mean (the) cout version;

    3. Re:Normal Read by Chris+Mattern · · Score: 3, Funny

      You mean the cout version, noob!

  3. Printer Friendly by linal · · Score: 1, Redundant
    1. Re:Printer Friendly by Anonymous Coward · · Score: 0

      Two people post the same message within a minute of each other (more likely seconds that span the change in minute). The first one gets +5 Informative. The second gets -1 redundant. At the time of the redundant post there wasn't another post, so it wasn't redundant.....it was just "slow". The cruel reality of mods.

      Go ahead and mod me Offtopic like I deserve. That's why I posted as AC.

    2. Re:Printer Friendly by Anonymous Coward · · Score: 2, Insightful

      If the messages are the same, no one has any reason to see both, so scoring one out of the default view is the Right Thing. If you're pathetic enough to care about karma and this happens so often that it even matters, complain to the admins that the author of a redundant comment hasn't done anything wrong.

    3. Re:Printer Friendly by MoonlightSeraphim · · Score: 1

      the amusing part is that we were both modded informative at first -_-

    4. Re:Printer Friendly by hesiod · · Score: 1

      >complain to the admins that the author of a redundant comment hasn't done anything wrong.

      I think that's what he's doing.

    5. Re:Printer Friendly by Anonymous Coward · · Score: 0

      The worst part about it? There were actually three posts of the exact same link all within a minute of each other. Post one, just the link, is +5. The second one (the GP), also just the link, -1. The third one, the link with some additional text, +5 (additional text was not +5 worthy.....maybe +3, but not +5).

      Same AC that was complaining above.

    6. Re:Printer Friendly by Anonymous Coward · · Score: 0

      Quit bitching and learn to stop caring about mod points. You're wasting everyone's time with this drivelish bullshit. Thank you, good day.

      (Hypocrisy noted, thanks for that too)

    7. Re:Printer Friendly by Anonymous Coward · · Score: 0

      Something similar happened to you. You got modded -1 Offtopic, whereas AC, who posted the same comment, gets no negative mods, and people respond to him. It looks like you posted first, because your post is on top, but you both posted the same minute.

  4. Interesting Read by dreamchaser · · Score: 5, Informative

    It's always cool to see this kind of interview. It's even cooler when you can read it all on one page rather than 8.

    I suggest that anyone who uses C++ or is interested in the history of programming read this. Some of it is a bit banal, like how they chose the name, but some of it is really intersting. RTFA for once, you lazy clods!

    1. Re:Interesting Read by morgan_greywolf · · Score: 5, Funny

      RTFA for once, you lazy clods!
      Hey! I'm illiterate, you insensitive clod!
    2. Re:Interesting Read by afidel · · Score: 5, Interesting

      I was kind of interested in the comment that C++ required a proper compiler rather than just a pre-processor macro package. From the fog of my memory I remember many of the early commercial C++ offerings being mostly a pre-processor package, were those really just C with Classes compilers rather than true C++ ones?

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    3. Re:Interesting Read by Anonymous Coward · · Score: 1, Informative

      You're thinking of CFront, the original implementation, which was just a front end. But the C++ language itself has been developed further and that's no longer possible.

    4. Re:Interesting Read by Anonymous Coward · · Score: 0

      I've never worked heavily in the C++ world, but from what I've heard of its early days, that's exactly right. Almost all the old school pre-processor powered C++ compilers were incapable of doing the things the language demanded. And they were really bad at what little they could do.

    5. Re:Interesting Read by Anonymous Coward · · Score: 0

      BTW, you know it all is a joke, along with UNIX and X, don't you?

    6. Re:Interesting Read by Anonymous Coward · · Score: 0

      Well I'm not illiterate - I know who my parents are.

    7. Re:Interesting Read by c · · Score: 3, Informative

      Early C++ "compilers" usually did more than just macro processing, but only just; most of them were implemented in terms of translating C++ to equivalent C code and then compiling the resulting C. Not so elegant, but it allowed compiler vendors to pick the low-hanging fruit and get something on the market ASAP.

      It wasn't just commercial compilers, either. g++ worked that way.

      Of course, it goes without saying that these early C++ compilers sucked hard.

      c.

      --
      Log in or piss off.
    8. Re:Interesting Read by LiquidCoooled · · Score: 1

      Aren't you just a bit biased?

      by c (8461) [blah] on 15:25 25th June, 2008 (#23935449)

      I have returned to c this year after a few years in higher level languages and am seriously considering a couple of basic additions to c which would require similar principles as original cfront.
      There is no point in reinventing the whole wheel and c++ -> c is no different than [anylanguage] -> asm compilers that exist all around.

      --
      liqbase :: faster than paper
    9. Re:Interesting Read by hey! · · Score: 1

      From the fog of my memory I remember many of the early commercial C++ offerings being mostly a pre-processor package, were those really just C with Classes compilers rather than true C++ ones?

      I don't know about many, but I used at least one that was C++ implemented mainly with the preprocessor -- if I recall, it even did templates using name mangling. It worked, but it made debugging a challenge because the debugger was basically an OK C debugger that wasn't completely up to speed on unmangling C++ symbol names.

      Simply cross compiling from one language to another is not much of a technical trick, but I'd guess that it complicates making decent debugger, so that may be one of the reasons a language like C++ "needs" a native compiler.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    10. Re:Interesting Read by Anonymous Coward · · Score: 0

      Misconception--it was never that way. The early versions compiled C++ into C--this was a compilation, not a translation. The reasoning for compiling into C instead of assembly was for portability. See Bjarne's "Design and Evolution of C++" if you're interested.

    11. Re:Interesting Read by Hatta · · Score: 1

      The early versions compiled C++ into C--this was a compilation, not a translation.

      What's the difference?

      --
      Give me Classic Slashdot or give me death!
    12. Re:Interesting Read by rbanffy · · Score: 2, Interesting

      "that's no longer possible."

      Remember... This is Slashdot. Comments like these may have unintended consequences when made here.

      It's, of course, possible to build a CFront-like preprocessor that converts current C++ code into C. It's not easy and the C code would probably be even less readable than what CFront wrote. It's not practical either. Or wise.

      But it's certainly possible.

    13. Re:Interesting Read by c · · Score: 3, Interesting

      > Aren't you just a bit biased?

      If you're gonna be pedantic, it's a lower-case 'c'.

      But I'll freely admit to being biased. I've spent my time in the C++ trenches. C isn't a terribly good language, but when you shoot yourself in the foot it's usually a clean wound.

      c.

      --
      Log in or piss off.
    14. Re:Interesting Read by Mikkeles · · Score: 4, Funny

      Hey! I'm illiterate, you insensitive clod!

      As are most c++ programmers.

      --
      Great minds think alike; fools seldom differ.
    15. Re:Interesting Read by shutdown+-p+now · · Score: 2, Informative

      For the record, the first C++ compiler that compiled directly to native code was Zortech C++ (which beget Symantec C++, which beget Digital Mars C++). Its author, Walter Bright, is the guy behind D programming language.

    16. Re:Interesting Read by Anonymous Coward · · Score: 0

      Hey! I'm illiterate, you insensitive clod! Oh yeah? I never learned how to type!
    17. Re:Interesting Read by thedrx · · Score: 1

      I don't know if your question was serious or not, but compilation involves tokenizing everything, etc., while translation would probably involve only some kind of string replacement. It all depends on the terminology you choose, I guess.

    18. Re:Interesting Read by Profane+MuthaFucka · · Score: 0, Flamebait

      Where do you kids get these wrongheaded ideas?

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    19. Re:Interesting Read by afidel · · Score: 1

      Of course it's possible because C is Turing complete, it's just not very practical as you point out =)

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    20. Re:Interesting Read by hitchhacker · · Score: 2, Informative

      C isn't a terribly good language, but when you shoot yourself in the foot it's usually a clean wound. From TFA:

      "C++ makes it harder to shoot yourself in the foot; but when you do, it takes off the whole leg" is sometimes quoted in a manner hostile to C++. That just shows immaturity. Every powerful tool can cause trouble if you misuse it and you have to be more careful with a powerful tool than with a less powerful one: You can do more harm (to yourself or others) with a car than with a bicycle, with a power saw than with a hand saw, etc. What I said in that quote is also true for other modern languages; for example, it is trivial to cause memory exhaustion in a Java program. Modern languages are power tools. That's a reason to treat them with respect and for programmers to approach their tasks with a professional attitude. It is not a reason to avoid them, because the low-level alternatives are worse still.
      -metric
    21. Re:Interesting Read by Anonymous+Brave+Guy · · Score: 2, Funny

      Oh know were not.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    22. Re:Interesting Read by Javagator · · Score: 1
      CFront ... just a front end. But the C++ language itself has been developed further and that's no longer possible.


      If it's no longer possible to process it into C, then it is no longer possible to compile it into machine language.

    23. Re:Interesting Read by c · · Score: 1

      > "C++ makes it harder to shoot yourself in the foot; but when you do, it takes off the whole leg"
      > is sometimes quoted in a manner hostile to C++. That just shows immaturity.

      I fully agree. Anyone who says that C++ makes it harder to shoot yourself in the foot obviously doesn't have a clue what they're talking about.

      I also agree with the point about powerful tools being potentially dangerous. The problem with C++ is an absurdly high power-to-danger ratio. It's not the difference between a bicycle and a car, it's the difference between a car and a car with a jet engine welded to the roof. Both of them are pretty dangerous, but one of them has quite a bit more power than its control mechanisms can safely handle.

      c.

      --
      Log in or piss off.
  5. Humour by morgan_greywolf · · Score: 2, Funny

    I needed a tool for designing and implementing a distributed version of the Unix kernel. At the time, 1979, no such tool existed. I needed something that could express the structure of a program, deal directly with hardware, and be sufficiently efficient and sufficiently portable for serious systems programming.
    I take it Bjarne hasn't used KDE.

    (C'mon KDE guys, it's funny. Laugh.)

    1. Re:Humour by X0563511 · · Score: 1

      It's not funny. Either that, or I'm missing something (which is probably the case.)

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    2. Re:Humour by Rob+Kaper · · Score: 3, Insightful

      The pun seems to be that KDE isn't structured, efficient, portable or serious, despite being written in C++. I can't blame you for missing it, or finding it not funny.

    3. Re:Humour by chad.koehler · · Score: 1

      I took it as KDE has all the abilities needed based on the meme that KDE reinvents the wheel for EVERY application out there (KOffice, etc.) I may be WAY off on what was meant, but in any case it made me chuckle.

    4. Re:Humour by voxner · · Score: 1

      I just updated to kubuntu and I couldn't agree with you more.

  6. useful but oh so flawed by speedtux · · Score: 1, Flamebait

    what all good code-writers should think about when using the language he created."

    Mostly, I try to meditate on being calm when writing C++ code, because the language is so full of infuriating and avoidable design problems.

    1. Re:useful but oh so flawed by Anonymous Coward · · Score: 0

      ... and of course what all good code-writers should think about when using the language he created.

      Sick.

    2. Re:useful but oh so flawed by pclminion · · Score: 2, Insightful

      Back that statement up, buddy.

    3. Re:useful but oh so flawed by hey! · · Score: 5, Insightful

      Well, there's no doubt in my mind that C++ is a language design tour de force. The question is whether its design objectives are the right ones.

      They were probably the right objectives for the place (Bell Labs) and time (1979) it was conceived.

      At the time, computers were inconceivably slow by today's standards. I worked at a small developer that had a very nice AT&T 3B2-400, which had a WE32000 microprocessor, which probably ran at about 10-15MHz; a half dozen programmers shared it.

      As for the place, well, it was crawling with C programmers and C libraries, doing rather complex and important systems programming. Compatibility with C and proven C libraries would have been a huge thing.

      So, an efficient, object oriented version of C was probably exactly what was needed.

      I think that if there was any fault, it was the attempt to meet the goals of efficiency and compatibility with a language that implemented everything that (at the time was thought to be) necessary for programming in an object oriented style. Multiple inheritance carries too much baggage when all you want to do is to guarantee objects have a certain interface. Likewise, I think operator overloading is another example of trying to do too much. Yes, it makes programmer classes "first class citizens", but it really has no demonstrable practical benefit in my opinion. In situations where you need a special purpose language, it's probably better just to create one.

      Still, that's hindsight. If you really understand all the things Stroustrup was trying to do, C++ is quite awe inspiring.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    4. Re:useful but oh so flawed by everphilski · · Score: 3, Insightful

      Likewise, I think operator overloading is another example of trying to do too much. Yes, it makes programmer classes "first class citizens", but it really has no demonstrable practical benefit in my opinion.

      I write math codes for fun and for a living. I have this discussion on an infrequent basis with a Java buddy of mine. Now granted I'm a dumb mechanical engineer and he's a smart CS major, but when I need some custom math classes that aren't provided by the language (tensors, vectors, Jacobians, Quaternions, etc.) and evaluating long math expressions, it is so much easier to view it using the native math symbols than to nest it all in member functions .add(), .subtract(), .multiply(), etc. Once I transliterated a piece of C++ code I had wrote for him and it consumed three times the space and was much less readable due to the nesting of the member functions... being able to use natural math symbols and natural parenthesis makes the math so much more readable, and when 90% of your code is math, you come to appreciate it. I wouldn't have it any other way, at this point.

    5. Re:useful but oh so flawed by croftj · · Score: 0, Flamebait

      Unlike the wonderful world of Java eh?

      I love not having overloaded operators in Java (or at least how nobody makes use of them). I also like how anal folks are that in the member functions which throw exceptions which must be caught for every little shit thing that could go wrong. So what is wrong with returning an error code when a file can't be closed? Must an exception be thrown?

      Yep, java had a lot more thought put into how to make the programmer do as much work prepping to call a function as he would to write the function in the first place.

      Or maybe you're talking about VB or C#...

      --
      -- Many men would appreciate a woman's mind more if they could fondle it
    6. Re:useful but oh so flawed by toriver · · Score: 1

      Go read "Effective C++", it mentions a bunch of them (like how you can shoot yourself in the foot when using references, the dangers of overloaded =/new/delete etc).

    7. Re:useful but oh so flawed by speedtux · · Score: 1

      They were probably the right objectives for the place (Bell Labs) and time (1979) it was conceived.

      I don't think so. There were efficient, high-level languages around at the time. Simula-67 itself was one of them.

      So, an efficient, object oriented version of C was probably exactly what was needed.

      What was needed was an efficient object oriented systems programming language. The mistake was tying it so closely to C.

      Likewise, I think operator overloading is another example of trying to do too much.

      Without operator overloading, C++ wouldn't have been used for scientific computing, and it would probably not be around at all anymore.

    8. Re:useful but oh so flawed by hey! · · Score: 1

      Well, that's certainly the strongest kind of pro-operator overloading example there is, when the operator is being overloaded as a natural extension of its fundamental meaning. It makes perfect sense to do this, in the way it makes sense to overload plus for integers and reals.

      On the other hand, that's not the only natural way to handle the situation you are talking about. Another way is to create a new language. Altogether, I'd rather do the kind of work you're talking about in Matlab or Octave. Or you could do something like Beanshell -- have an interpreted language that is closely tied to the underlying language and its libraries.

      It's really a very narrow range of applications where extending something like C in this way is really the best approach.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    9. Re:useful but oh so flawed by Anonymous Coward · · Score: 0

      What about using Maple to write the math, and then generating C code from that? better than hacking the language.

    10. Re:useful but oh so flawed by speedtux · · Score: 1

      Unlike the wonderful world of Java eh?

      No, unlike the wonderful world of non-C systems programming languages, of which there were quite a few: Cedar, Mesa, Modula, etc.

      Or maybe you're talking about VB or C#...

      Well, thank you for being such a good representative of the industry and illustrating why we keep getting stuck with lousy choices like C++, Java, DOS, Windows, etc.

    11. Re:useful but oh so flawed by everphilski · · Score: 3, Insightful

      On the other hand, that's not the only natural way to handle the situation you are talking about. Another way is to create a new language. Altogether, I'd rather do the kind of work you're talking about in Matlab or Octave.

      I write code for clusters, now specifically CFD. Lots of math, lots of parallel processing. Matlab and Octave isn't gonna cut it, and you really desire the close to the metal aspects of c++.

      It may be a narrow range, but there's a lot of people in this narrow range. Specifically, (mechanical/aerospace/etc.) engineers. C++ isn't sexy like Java or Python, but we do a lot of things you just can't do in Python, and can't do fast in Java.

    12. Re:useful but oh so flawed by pclminion · · Score: 3, Informative

      Good book, but I don't see how some minor nuances translate to insurmountable design flaws. It's true that proper use of C++ requires a level of expertise beyond what's required for many other languages. IMHO, that just makes real C++ programmers more valuable.

    13. Re:useful but oh so flawed by toriver · · Score: 3, Insightful

      Basically when you have rules you ought to (or "must" unless you want magical bugs) follow that are not enforced by the compiler, the language is flawed. Like when you oveload new but not delete and thus have incompatible memory management. Or you return a reference to a method-local (auto) string object.

      It does however give rise to a market for code analysis tools that checks all the stuff the compiler will let you get away with.

      But you can save the cost of these tools (or the alternative manual hunt for bugs) by using more modern and productive languages like Java or Ruby, leaving C++ for operating systems and games. And the latter is moving into other lanbguages as well, i.e. Microsofts push for C# in game development, and the widespread use of Python in e.g. EVE Online, ToonTown, Civ IV and other games.

    14. Re:useful but oh so flawed by jstott · · Score: 1

      ... being able to use natural math symbols and natural parenthesis makes the math so much more readable, and when 90% of your code is math, you come to appreciate it. I wouldn't have it any other way, at this point.

      That's why God invented Fortran!

      -JS

      --
      Vanity of vanities, all is vanity...
    15. Re:useful but oh so flawed by TheLink · · Score: 2, Interesting

      If 90% of your code is math, how about Lisp or Fortran?

      Of course that might depend on what the 10% is.

      --
    16. Re:useful but oh so flawed by EsbenMoseHansen · · Score: 1

      Likewise, I think operator overloading is another example of trying to do too much. Yes, it makes programmer classes "first class citizens", but it really has no demonstrable practical benefit in my opinion.

      Really? I have lost count of the number of errors in Java code I find because someone wrote either something like string_a=="cheese" (which is only the right thing to do in a few cases) or string_a.equals("cheese") (which is also likely to crash). In C++, you get to do string_a=="cheese", and it will also work with any other class. Oh, and it will correctly fail at compile-time if you make a non-sensical comparison. You get all this free from operator overloading.

      Then there is the map-like classes, the array-like classes, and as others already have mentioned, all the classes that acts more or less like numbers. In short, almost all C++-programs ends up using operator overloading in a positive way. A programming language that does not provide operator overloading is either a toy (nothing wrong with that), dumped down (likewise) or lacking (worse).

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    17. Re:useful but oh so flawed by Eponymous+Bastard · · Score: 1

      Operator overloading is one of those things you should avoid doing, and if you do, try to follow the standard meaning. I've seen many people get turned off by C++ because the first example they see is changing the shift operators to do I/O.

      Anyway, The other good example of overloading and what you can do with it is the STL. Being able to overload ->, *, (), ++ and -- allows people to write container libraries that work very well and look familiar to any C programmer. But This is one of those things you shouldn't try for yourself.

    18. Re:useful but oh so flawed by pclminion · · Score: 1

      Basically when you have rules you ought to (or "must" unless you want magical bugs) follow that are not enforced by the compiler, the language is flawed. Like when you oveload new but not delete and thus have incompatible memory management. Or you return a reference to a method-local (auto) string object.

      These things could be addressed by the standard. Strict modes exist in other languages, I don't see why we couldn't have one in C++. I realize this sort of "in the sky" argument doesn't help anybody right now. But it's not as if the language is unfixable.

      I think C# made a few good steps in the right direction, but I still hate garbage collection. Some people see RAII in C++ as a hack to get around the lack of GC, I tend to see it the opposite way. What the language needs is stronger enforcement of some of these basic principles. C# would be a great deal more attractive to me if it provided the same power in generics as C++ templates give you.

    19. Re:useful but oh so flawed by neonsignal · · Score: 2, Funny

      the bloke was complaining about function nesting and you suggested Lisp?

    20. Re:useful but oh so flawed by Kartoffel · · Score: 1

      +1. Where I work, some of the old C greybeards are playing with C++ and enjoying operator overloading.
      Meanwhile, the Fortran gurus are like "So what? We've had overloading since F90 and we still don't use it. Get off my lawn!"

    21. Re:useful but oh so flawed by twistedcubic · · Score: 2, Insightful

      Altogether, I'd rather do the kind of work you're talking about in Matlab or Octave. Or you could do something like Beanshell -- have an interpreted language that is closely tied to the underlying language and its libraries. Matlab (and its clones) are mostly useless in the numerous areas of math outside of a standard undergrad curriculum, even for "profiling" since the data structures aren't even in the language. It's a zillion times easier to write these in C++. This never gets mentioned on forums like this, but C++ provides the right balance of power and flexibility (especially with memory managament) for people who do specialized math/science. And even in not-so-specialized areas, sometimes objects in Matlab clones are represented in a way which is cumbersome to use. Writing a representation in C++ might save hours.
    22. Re:useful but oh so flawed by twistedcubic · · Score: 2, Insightful

      If 90% of your code is math, how about Lisp or Fortran? Maybe Lisp is too slow and it's hard to represent objects in Fortran. Imagine how you would represent a multivariate polynomial with rational coefficients in Fortran.
    23. Re:useful but oh so flawed by tjb · · Score: 1

      This signal processing engineer and his hundreds of Matlab scripts would like to politely diagree with your assessment of Matlab:)

    24. Re:useful but oh so flawed by waveclaw · · Score: 1

      Getting the objectives right then, and revising them to fit the objectives now are two very different things. It's easy to write hack code, but very hard to maintain it. It still impresses me that compilers can output binaries from some of the C++ they get fed. (To be honest, it impresses me more that debuggers can handle the resulting binary output.)

      I do have one big nitpick:

      So, an efficient, object oriented version of C was probably exactly what was need

      C++ is neither an object-oriented language nor C with objects. Java isn't object-oriented. Javascript is. Even Bjarne Stroustrup is clear on this matter:

      FTA:

      Where does the name C++ come from?

      As "C with Classes" (my ancestor to C++) became popular within Bell Labs, some people found that name too much of a mouthful and started to call it C.

      You write and design classes that your running program implements as objects. This extra bit of indirection has huge consequences for the language and code written into it. For one, programming in C++ is the job of telling the computer how to define a memory store that objects can be used on. This is no different a difficult than defining a complex structure in C.

      FTA:

      These days, object-oriented programming is just about everywhere,

      but not in C++. It's still turtles (class architecture) all the way down. Language theorists can talk about 'message passing' and 'behaviors.' Bleh, Syntax sugar for programmers with diabetes. They are just procedural programming functions that get an extra pre-allocated pointer passed in like a global variable and suspect to the same kinds of bugs. I love side effects, don't you?

      As an aside, I am sick of dealing with novice code from people who are desperately trying to write object-oriented programs in a class-oriented language. The quality of the resulting code sucks (yes, I'm looking at you random video game programmer. Just put the global singleton pattern down and walk away, slowly.) Eventually they will get it or fail, even if they will continue to call it object-oriented programming while they carefully assemble their classes.

      So, yes, I see C++ used for many things that I had not predicted and used in many ways that I had not anticipated, but usually I'm not completely stunned. I expected to be surprised, I designed for it. For example, I was very surprised by the structure of the STL and the look of code using it - I thought I knew what good container uses looked like

      For what it's worth, STL and template metaprograming equals job security, if you can get the damn thing to compile. To paraphrase a famous quote: "Dear Stroustrup, I have no problem with you, but your followers are another matter." And don't get me started about the abuses of composition and inheritance.

      I know this is a typo in the article, or a really funny Freudian slip, but it's going in my scrapbook:

      C++ inherited the weaknesses and the strengths of C++, and I think that we have done a decent job at compensating for the weaknesses without compromising the strengths.
      -- Bjarne Stroustrup
      --

      "You cannot have a General Will unless you have shared experiences. You cannot be fair to people you don't know."
    25. Re:useful but oh so flawed by twistedcubic · · Score: 1

      I know, but that's my point. People who don't find Matlab useful never post here. I never claimed that Matlab was useless.

    26. Re:useful but oh so flawed by zaphle · · Score: 2, Insightful

      Multiple inheritance carries too much baggage (...) but it really has no demonstrable practical benefit in my opinion. This is basically heresay. Most people who *think* multiple inheritance is not needed have never gotten into programming deep enough to understand that it actually *is* necessary if you want a clean object model. Sure C# and the like give you interfaces, but they require you to implement the code behind them over and over again, resulting in most programmers to just start copy-paste code. Then one day, a bug or change request comes up for that particular copy-pasted code and hell starts: you can start updating all that copy-pasted code and make sure you don't forget any of it. With multiple inheritance, the shared code is actually where it should be: in one class. I dare people to actually show an example of where multiple inheritance is flawed that can't be solved with virtual inheritance or dynamic_cast. The problem is that most programmers who *think* they are C++ programmers are actually enhanced C programmers (at best) who never even heard of dynamic_cast or virtual inheritance, not to mention partial template specialization. Here's a link if you want to know more: http://en.wikipedia.org/wiki/Modern_C%2B%2B_Design

      I also like to remind that generics as now widely used in languages such as Java and C# initially started as templates in C++, only the latter has far better support.

      For those who think that garbage collection is the holy grail against leaks in a program, think again. While it may solve memory leaks, it doesn't solve resource leaks (like open connections, file locks, ...) who on the other hand can be nicely solved in C++ by implementing their release in the destructor. The use of garbage collectors inherently prevents the destructor paradigm (since one can never be sure when or even IF the Finalize method will be called - yes the GC of .NET doesn't guarantee that it will be called even when the program terminates, so freeing up a resource in a Finalize is a no-no since it may still leave you with locked resources), so basically, you're required to manually clean up your resources instead of having your object deal with the cleanup automatically. Makes garbage collection quite controversial if you ask me.

      If you want to know more, I'm always in for a discussion on the subject. Happy to inform.
      --
      And what if there's nothing behind the door until it is being opened?
    27. Re:useful but oh so flawed by Anonymous+Brave+Guy · · Score: 1

      I'm generally in the "C++ isn't so bad" camp, but I feel obliged to play devil's advocate a bit here, because I do think you're overstating the case in places.

      Most people who *think* multiple inheritance is not needed have never gotten into programming deep enough to understand that it actually *is* necessary if you want a clean object model.

      Is that really true, though? It may be necessary if you want a clean object model like C++'s, but the C++ object model is not the only way to do OO. In many ways, it's a step removed from the original idea of independent objects communicating via message passing with late binding. One could make a reasonable argument that it is the projection of the original concept onto the C++ implementation that causes the lack of cleanliness, and that while multiple and virtual inheritance can compensate for that to some extent, they also introduce problems of their own.

      Personally, I think it's a bit of a cheap shot to make that argument but then implement a half-baked version of C++'s object model anyway rather than a more faithful representation of the original, simple and elegant concept of OO. This is why I don't have much time for the Java and C# designers who criticised C++ for supporting multiple inheritance, but then went ahead and used classes and virtual functions essentially the same way anyway.

      I also like to remind that generics as now widely used in languages such as Java and C# initially started as templates in C++, only the latter has far better support.

      I think that's rather flattering to C++. Generic code, in the parameterised type/function sense, is effectively the default in many functional languages. The compile-time meta-programming side of C++ templates... Well, Lisp, 'nuff said.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    28. Re:useful but oh so flawed by CBravo · · Score: 1

      I have to point you to the argus codewatch eclipse plugin: http://arguscodewatch.sourceforge.net/

      (which is the one I know, there may be more)

      --
      nosig today
    29. Re:useful but oh so flawed by EsbenMoseHansen · · Score: 1

      I have to point you to the argus codewatch eclipse plugin: http://arguscodewatch.sourceforge.net/

      (which is the one I know, there may be more)

      Of course, linters help, but really, a decently designed language would not have this problem at all. Object::clone, equals, hash at least are flawed design. Object should only have functions that *any* conceivable class can implement at no cost.

      The reason while these flaws are there is that Java supports neither mix-in classes nor static polymorphism nor operator overloading.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    30. Re:useful but oh so flawed by Anonymous Coward · · Score: 0

      ... not enforced by the compiler, the language is flawed So ... how fixing the language would fix the compiler? Shouldn't you say the compiler is flawed? There are many things the language specs leave to the compiler to decide, if it is decided for the worst, than the compiler should be to blame.
    31. Re:useful but oh so flawed by zaphle · · Score: 1

      ... but the C++ object model is not the only way to do OO. In many ways, it's a step removed from the original idea of independent objects communicating via message passing with late binding.

      Could you specify exactly what step is removed from the original idea? In what way is C++ violating the principle of "independent objects communicating via message passing with late binding"? (examples?)

      One could make a reasonable argument that it is the projection of the original concept onto the C++ implementation that causes the lack of cleanliness

      What you refer to as a lack of cleanliness is basically a way to allow for optimizations. Very strict concepts cause a lot of overhead that is just not acceptable in situations that require high performance.

      ... and that while multiple and virtual inheritance can compensate for that to some extent, they also introduce problems of their own.

      Please give an example of these problems they supposedly introduce. I'm sure I'll be able to size them down to either (1) a conceptual flaw in the way the programmer designed the classes or (2) a misuse or lack of knowledge of syntax (such as not using virtual inheritance or dynamic_cast)

      Personally, I think it's a bit of a cheap shot to make that argument but then implement a half-baked version of C++'s object model anyway rather than a more faithful representation of the original, simple and elegant concept of OO.

      One solution does not fit all. That's why C++ gives the programmer the freedom to choose a different paradigm and allow him to not strictly use OO where the overhead would just not be acceptable. Let me ask you this: what is a better tool: one that can be used in many different ways to fit different purposes or one that enforces you to use it in one way only? I'd go for the first and that's what C++ is.

      Saying that the OO model of C++ is half-baked is quite an ironic statement. You probably think that C# en Java have a better model while they don't allow multiple inheritance, to me *that* is half-baked; it forces me to use static methods if I want to centralize logic whereas C++ would allow me to inherit from multiple bases that contain code for each different aspect of the resulting class. I find this far more elegant than having to implement the same interfaces over and over again. (read Andrei Alexandrescu)

      C++ is not half baked, it is a large toolbox that has many features, but apparently the average programmer is not capable of chosing what tool is fit for what purpose. This results in them choosing a reduced toolbox that requires less learning (other languages). If such a programmer is then confronted with C++, he choses the wrong feature of C++ to solve certain problems and cuts of his fingers with a knife way to sharp. If someone cuts his fingers with a sharp knife, does that mean that we should no longer use sharp knifes? Or does it mean that this person is incompetent and should either get an education or stay away from sharp knives to begin with?

      This is why I don't have much time for the Java and C# designers who criticised C++ for supporting multiple inheritance, but then went ahead and used classes and virtual functions essentially the same way anyway.

      I don't see how C# and Java could be used the same way if it comes to multiple inheritance.

      I also like to remind that generics as now widely used in languages such as Java and C# initially started as templates in C++, only the latter has far better support.

      I think that's rather flattering to C++. Generic code, in the parameterised type/function sense, is effectively the default in many functional languages. The compile-time meta-programming side of C++ templates... Well, Lisp, 'nuff said.

      OK, other languages have it as well, but my point was that it's undoubtedly the C++ co

      --
      And what if there's nothing behind the door until it is being opened?
    32. Re:useful but oh so flawed by Anonymous+Brave+Guy · · Score: 1

      I'm happy to debate these points with you, but first, I invite you to reread my post (particularly the comments about how the model in C++ compares to Java and C#) and decide whether you stand by everything in your last post. I suspect you misread a key sentence, and in doing so understood completely the reverse of the position I actually stated.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    33. Re:useful but oh so flawed by Anonymous Coward · · Score: 0

      C++ is a toolbox full of broken glass. Almost any mistake will lead to a massive effort diagnosing your platform's tendencies in undefined behavior. Even if you're one of the few with the patience and paranoia to write a (vanishingly rare) strictly conforming program, there are far better uses for your time than to fight a language that wants you to fail.

    34. Re:useful but oh so flawed by zaphle · · Score: 1

      I just re-read your comment and realized that I indeed misinterpreted a key sentence. I'm so used to people being against C++ and its features that I somehow got conditioned into interpreting things that way by default.

      That said, if you find the time to continue this debate, I'm still curious to see in what situations multiple inheritance can introduce problems of its own.

      --
      And what if there's nothing behind the door until it is being opened?
    35. Re:useful but oh so flawed by zaphle · · Score: 1
      Let me first say that I know how you feel. I've been there too, but this is the steep part of the learning curve of C++ that you just need to get past.

      there are far better uses for your time than to fight a language that wants you to fail.

      Learning a language like C++ trains you as a programmer in better understanding how things work "under the hood" so to speak. It makes me a better C# programmer, so it's well worth the time and the effort. Even when programming C# in situations where performance matters, your experience with C++ will help you understand which classes and methods to use and which to avoid on what occasions. You may feel that the language has let you down, but on such occasions it is best to call in the help of a mentor. Eventually, you'll be able to find the answers on your own.

      --
      And what if there's nothing behind the door until it is being opened?
    36. Re:useful but oh so flawed by Anonymous Coward · · Score: 0

      I started professionally in 1992. I've rolled my own DLL support in MS-DOS (by reading in unlinked object files and passing interfaces). I've read and used Alexandrescu's ideas. It's not the learning curve.

      I do believe we benefit from studying assembly, and pointer arithmetic, and memory barriers, and locality, and pipeline stalls. I just don't believe it's worth the risk of constantly being just one static_cast<> or bounds check away from catastrophe. So learn it if you like, but holy crap don't rely on it.

    37. Re:useful but oh so flawed by zaphle · · Score: 1

      I just don't believe it's worth the risk of constantly being just one static_cast<> or bounds check away from catastrophe. So learn it if you like, but holy crap don't rely on it.

      Well, what can I say, tons of applications do rely on C++. In fact, the Joint Strike Fighter's software will be written in C++ and we're talking about life support here; if the software fails, lives depend on it.

      I mean, you could easily introduce a bug in an application no matter what language you're going to use. Using a good architecture is what makes the quality of software, not per se the language, only C++ has a richer toolset for designing your program's architecture while (and this is important) not having to trade in performance.

      Personally, I wouldn't like to be the pilot in a plane that makes intense real-time calculations where suddenly the garbage collector freezes all the threads because he feels it's time to see if any memory needs to be cleaned up. So yes, I'd rather rely on C++ than on any garbage collected language for that sort of applications.

      Now to go a bit deeper into the examples you state: The use of static cast is deprecated. If you find yourself using it, there's something wrong with the architecture of your application. The few cases where you do need it, you can write extensive checks and unit tests around that particular piece of code. And as for bounds checking: if you read or write outside the bounds of an array in C#, you will get a range exception, I don't see what the difference is with C++.

      I feel that there's a lot of FUD created around C++. Feel free to post some real code samples that demonstrate how C++ is supposedly broken. Challenge me.

      --
      And what if there's nothing behind the door until it is being opened?
    38. Re:useful but oh so flawed by Anonymous Coward · · Score: 0

      if you read or write outside the bounds of an array in C#, you will get a range exception, I don't see what the difference is with C++

      "Exception" is precisely the difference. Writing past an array in C++ might cause a signal from the MMU, or it might damage an unrelated object causing mysterious failures much later. Likewise for dangling references, iterator invalidation, placement and array new, exceptions during destructors, dispatch to pure virtual functions, static initialization order ... In fact the phrase "undefined behavior" appears dozens of times in the Standard, and our profession is littered with insecure, flaky, and unusable software from people who thought they were smart enough to avoid every one of these traps 100.0% of the time. If you really want the list, try any of the 297,000 Google results for C++ pitfalls.

    39. Re:useful but oh so flawed by zaphle · · Score: 1

      Writing past an array in C++ might cause a signal from the MMU, or it might damage an unrelated object causing mysterious failures much later.

      This basically means that if other languages have additional bounds checking before writing to arrays which comes at a cost. C++ gives you the same possibilities though: you can overload operator[] of your collection class and add additional checks in it.

      As for the rest:

      - dangling references: I assume you are familiar with the concept of smart pointers

      - iterator invalidation: add a reference counter in your collection classes, increment them each time you create an iterator for it, decrement it when you destroy the iterator, don't destroy the collection unless the reference count is 0

      - placement new should only be used in a wrapper that does the necessary checking

      - I never use array new, only use vectors

      - exceptions during destructors: this is a true pitfall, watch out for this, but at least C++ provides destructors where other languages let you do the cleaning yourself by having to call dispose explicitly. Nobody ever calls that a pitfall.

      - dispatch to pure virtual functions can only happen when you call a pure abstract method from the destructor of the abstract class, I mean, come on, it's only obvious that when the destructors get called in reverse order and at the time the pointer to the virtual functions table is set to the one of the abstract class that you will end up calling a function on a null pointer

      - Don't use static initialization unless you know that there aren't dependencies on other static initializations. Instead, use the singleton design pattern.

      It basically boils down to following good practice guidelines, programming your software in layers, programming your software in layers, programming your software in layers (can't repeat that one often enough), all of which if you don't follow them in any other language, you will end up shooting yourself in the foot as well.

      There are pitfalls in C++. There's undefined behaviour in dozens of places. This is all very true, but what you are asking for is this: "give me a razor-sharp knife with which it is impossible to cut me in the fingers." It's all a matter of trade-offs. For any C++ program, you can choose any 3 of the following:

      - fast software

      - reliable software

      - complex software

      - easy to build software

      Many other languages do not give you the choice of this trade-off, e.g. there's no way to turn off garbage collection.

      But let me tell you this: the undefined behaviour is also true for many other popular languages:

      - C# doesn't guarantee that the finalize method gets called when the program finishes

      - No language can guarantee at what times the garbage collector will run nor how long the collection phase will take

      - all threads are frozen during GC

      If you want to believe you have more safety with other languages, be my guest, but IMHO, it depends more on who's driving the car than the type of car and yes, the faster the car, the higher the required skills for the driver.

      --
      And what if there's nothing behind the door until it is being opened?
  7. Content by RalphLeon · · Score: 0, Offtopic

    I can't believe how small they made the content on these pages ... it's 1/4th of the page! The rest is 3/4 crap with a dash of navigation.

  8. yawn by Anonymous Coward · · Score: 4, Insightful

    C++ is a language of a million gotchas. The moment I start having to think about implementation detail and I'm not writing an operating system or compiler, I know I'm using the wrong language.

    1. Re:yawn by sibte · · Score: 1

      You forgot to add high performance server side and real time applications to the list!

    2. Re:yawn by gbjbaanb · · Score: 2, Insightful

      then you're going to have a hard time of programming, perhaps you'd be happier being the Boss.

      All languages have "implementation details" and various gotchas. Look on any programming forum for any language and you'll see tips and tricks in using it. I think you're in the wrong job.

    3. Re:yawn by Chemisor · · Score: 3, Insightful

      > C++ is a language of a million gotchas.

      Whenever you want to use a language, you must learn it first. That's true even of Visual Basic. The reason you see those problems of yours as "gotchas" is that you don't understand how the language (and, in the case of C++, the computer) works. If you let the language shape your thoughts instead of trying to cram your crummy thoughts into C++, it would have been much easier and simpler for you.

      > The moment I start having to think about implementation detail, I know I'm using the wrong language.

      In other words, you don't want to know how your program really works. A fine attitude for a PHB. I suggest you switch to english.

    4. Re:yawn by techwizrd · · Score: 1

      Lisp implementations are very good. I have been programming for a while in many languages. My favorite implementation is Arc (or the community version Anarki). Lisp is inherently simple so the programmer spends more time planning and designing good code than working around the inefficiencies and design problems of the language itself.

    5. Re:yawn by tepples · · Score: 1

      The moment I start having to think about implementation detail and I'm not writing an operating system or compiler, I know I'm using the wrong language. Is C++ "the wrong language" for, say, a video game's graphics engine? Or would that be close enough to the GUI components of "an operating system"?
    6. Re:yawn by Anonymous Coward · · Score: 2, Insightful

      You evidently either (A) don't know thing one about C++ or (B) FAR FAR FAR worse, you do think you know about it.

      Next time you're in a bookstore, browse through Scott Meyer's "Effective C++" books.

      They're basically a huge list of comments to the effect of, "Gee, you THINK you can do X because it's perfectly legal syntax and it makes sense because you do X in other object-oriented languages, but in C++ it either fails outright or its undefined behavior in the language, so it will fail at the worst possible time in the worst possible way".

      For example, if you declare even one virtual member function, you HAVE to declare your destructor virtual. Ummm, what? Don't I get some help from the compiler?

      This, most emphatically, is not "you let the language shape your thoughts", this is psychosis.

    7. Re:yawn by Anonymous Coward · · Score: 1, Informative

      So just what is a protected abstract virtual base pure virtual private destuctor, and when was the last time you needed one?

    8. Re:yawn by Anonymous Coward · · Score: 0

      C++ is often complicated for performance and flexibility, but often it is complicated because no one will make a hard line decision in the standard. Even the syntax allows far too flexible; programming languages should not have dialects.
       
      If I need a mnemonic to remember were to put static, or frankly anything else, there is room for improvement.

    9. Re:yawn by Penguinisto · · Score: 1

      Dude... what? Any computer language (and pretty much most operating systems written in any language for that matter) have a million gotchas.


      The trick is to fit the best tools to the job at hand. If C++ can't do it, find a language that does - it's not like there's a shortage of 'em or anything.

      /P

      --
      Quo usque tandem abutere, Nimbus, patientia nostra?
    10. Re:yawn by clickety6 · · Score: 2, Insightful

      >> The moment I start having to think about implementation detail, I know I'm using the wrong language.

      > In other words, you don't want to know how your program really works. A fine attitude for a PHB. I suggest you switch to english.

      When I'm driving my car and I turn the steering wheel right, I expect the car to run right, without having to think about exactly how all the rods and pinions and bearings and whatever are making the car turn right. Sure, I need to know that the more I turn the steering wheel, the tighter I turn, but that should be it. Why should a programming language force me to think about low level implementation details that are nothing to do with the algorithm I'm trying to write?

      --
      ----------------------------------- My Other Sig Is Hilarious -----------------------------------
    11. Re:yawn by Anonymous Coward · · Score: 0

      > The moment I start having to think about implementation detail, I know I'm using the wrong language.

      In other words, you don't want to know how your program really works. A fine attitude for a PHB. I suggest you switch to english.

      Still need that idiotic space in nested template declarations?

      Dictionary<Pair<int, int>, Tree<double> > myDict;

      Note the space between the last two chevrons (> >). Note also that it is this way because '>>' is the right-shift operator.

      *That* is an implementation detail that has nothing to do with how knowing how your program really works. And it's those myriad idiotic implementation details for why Java and Python are today's preferred OO languages instead of C++, outside of applications where you need system-level access or have no choice in language due to legacy and/or political reasons.

    12. Re:yawn by Tweenk · · Score: 1

      It is used to solve the diamond problem in singletons where the base class is abstract (pure virtual), though making the base protected isn't too useful. DOM implementations with multiple inheritance where each node is created by the document object come to mind. This kind of design is used e.g. in Inkscape's Inkscape::XML::Node class.

      --
      Those who would give up liberty to obtain working drivers, deserve neither liberty nor working drivers.
    13. Re:yawn by professionalfurryele · · Score: 1

      "You evidently either (A) don't know thing one about C++"

      I think you mean thing zero.

      But seriously, C++ is fine for what it is. It is a little old and in places it is showing it's age, but the alternatives all have problems (although I have to say Java is looking nicer and nicer).

      There are certainly a few features C++ could do with, but I cant think what kind of problems you must have had to illicit this response. My compiler only spits out a warning if I declare a member function virtual without a virtual destructor. Of course it is bad practice not to complete a class anyway and if you have virtual functions the destructor should be virtual too.

      C++ suffers largely because it is the language that is "good enough" to solve most problems. Sure python might be better for something, but why would I bother with getting good at python when C++ is good enough and I already know C++.

      End of the day it is horses for courses and C++ is popular for a reason. That reason has very little (although sadly not nothing) to do with geek pissing contests.

    14. Re:yawn by iMaple · · Score: 2, Insightful

      When I'm driving my car and I turn the steering wheel right, I expect the car to run right, without having to think about exactly how all the rods and pinions and bearings and whatever are making the car turn right. Sure, I need to know that the more I turn the steering wheel, the tighter I turn, but that should be it. Why should a programming language force me to think about low level implementation details that are nothing to do with the algorithm I'm trying to write? It is nice to know when you are driving the car that if there is snow or an oil slick or a flat your turning response would be different. You don't have to know how the steering works, but know a few things more than just rotate the wheel right are useful when you want to do anything non-trivial. And just like programming you will learn these things by experience (if u don't get into any serious crashes).
    15. Re:yawn by larry+bagina · · Score: 4, Funny

      Why don't you ride the bus? You wouldn't need to even think about steering at all!

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    16. Re:yawn by Rocky · · Score: 2, Funny

      Be careful - you should Turn Left. Turning right may make you dissolve into little fat monsters.

      --
      "I'm an old-fashioned type of guy. I worship the Sun and Moon as gods. And fear them."
    17. Re:yawn by khchung · · Score: 2, Insightful

      Whenever you want to use a language, you must learn it first. That's true even of Visual Basic. The reason you see those problems of yours as "gotchas" is that you don't understand how the language (and, in the case of C++, the computer) works. If you let the language shape your thoughts instead of trying to cram your crummy thoughts into C++, it would have been much easier and simpler for you. I used to think like that when was still a C++ programmer, until one day I read an FAQ somewhere that details the possible differences between "f(a++)" and "f(a); a++;". That's when I saw the light and seriously switched to Java. I think when a normal person looking at a normal piece of code cannot know what it will do, there is something wrong with the programming language.

      Quick question (which I always used to interview candidates claiming familiarity with C++):

      What, if any, are the differences between 2 programs, one using "f(a++)" and the other "f(a); a++;"? For added fun, also compare "f(++a)" and "++a; f(a);".

      Hint: If you answer "no difference" you don't know enough about C++.

      More hint: there are at least 2-3 ways where the result of the program can differ significantly, depending on the signature of f(), the actual type of a, how is operator ++ defined for that type, etc.

      --
      Oliver.
    18. Re:yawn by everphilski · · Score: 1

      Why should a programming language force me to think about low level implementation details that are nothing to do with the algorithm I'm trying to write?

      When you are writing either a video game or cluster software where you are interested in milking out those last few percentile optimizations, and are willing to spend the time and effort thinking about those low-level implementation details to do so. Beyond some of the syntactical advantages C++ has over, say, Java.

    19. Re:yawn by VegeBrain · · Score: 1

      > In other words, you don't want to know how your program really works. A fine attitude for a PHB. I suggest you switch to english. Switching to English won't help because it's full of gotchas also. For example, whoever would have thought that "ph" and "f" have the same sound?

    20. Re:yawn by everphilski · · Score: 1

      Still need that idiotic space in nested template declarations?

      Depends on the compiler. Does not even register as a warning in VC++ (2008). I think it's a warning in GCC 4.2.0. with -Wall. For style reasons I try and leave a space, but it's not necessary.

      And it's those myriad idiotic implementation details for why Java and Python

      Right, because I really want my code blocks, loops, etc to be defined by space indentation (Python). No choice in style, style is enforced by the programming language. Wait, isn't that the same issue as you were suggesting with C++?

    21. Re:yawn by Samrobb · · Score: 2, Informative

      For example, if you declare even one virtual member function, you HAVE to declare your destructor virtual.

      I don't know where you got this idea. If you have virtual member functions, you probably want a virtual destructor, but it's neither a requirement, nor a given.

      From the C++ FAQ lite, read [20.7] When should my destructor be virtual?

      --
      "Great men are not always wise: neither do the aged understand judgement." Job 32:9
    22. Re:yawn by Anonymous Coward · · Score: 1, Funny

      > When I'm driving my car and I turn the steering wheel right, I expect the car to run right,

      Stay out of boats then.

    23. Re:yawn by Poltras · · Score: 1

      You forgot to add high performance server side and real time applications to the list! Yeah, because Objective-C, .Net, python and perl aren't fast... /sarcasm

      1999 called, and he wants his preconceptions back.
    24. Re:yawn by Anonymous Coward · · Score: 0

      The next version of C++ does not require the extra space. VC++ already figures it out for you, and I think g++ does too these days.

      Seriously, is that the worst you've got?

      And it's those myriad idiotic implementation details for why Java and Python are today's preferred OO languages instead of C++,

      Yeah, look at all those browsers and games written in Python.

    25. Re:yawn by Anonymous Coward · · Score: 0

      If the operator++ for a throws an exception, then f(a++) will, depending on the compiler, call f(a) or not. That might be one of the things you are referring to "implementation details". However they are not, they are a symptom of the programmer trying to bee too clever. You should know that exceptions can change your program normal flow, and that is a feature, they are intended to do that.

      If you are worried about your operator++ throwing an exception, or you don't know, and you just absolutely need f() to be called at all times, just simply, dont try to be cheap on code and write the full f(a); a++.

      And this is exactly the same kind of things you have to be careful about in C when writing macros, i.e.:

      #define MAX(a, b) ((a) > (b) ? (a) : (b)

      and then MAX(a++, b) will, sometimes, increment a twice...

      Just simply, don't try to be too clever, or try to show everyone how compact you can code (leave that to the obfuscated C contest).

    26. Re:yawn by Tychon · · Score: 1

      Never, and I never will. No one ever will, because it's a logically absurd pattern. It's just an attempt at stringing as many modifiers together as possible, which while confusing from the perspective of English, is quite simple to express in C++:

      class base { virtual ~base() = 0; };
      class child : protected virtual base {};

      The problem with this contrived example is that marking the base class as virtual is unnecessary. The only time you'll need to inherit as virtual is when you have something like a diamond-shaped hierarchy, which in itself typically suggests a design flaw.

      Also, the only way to make this actually compile (assuming you try to instantiate child) is with something like so:

      class child;
      class base { friend class child; virtual ~base() = 0; };
      base::~base() {}
      class child : protected virtual base {};

      There may be more convoluted ways to use this pattern, but I still can't say I've ever seen one that was actually useful and not solvable with something simpler and more idiomatic.

    27. Re:yawn by Anonymous Coward · · Score: 0

      So Stepanov was wrong when he decided to torture the C++ language to cram its ideas into code.

      Now I agree with your first part.

    28. Re:yawn by serviscope_minor · · Score: 1

      I used to think like that when was still a C++ programmer, until one day I read an FAQ somewhere that details the possible differences between "f(a++)" and "f(a); a++;"

      Well, then you're an idiot, frankly. I have little patience with comments like this. So, OK, since java is so great*, what does this do:

      f(foo(a)) and f(a);foo(a)

      Oh, java must be crap because you can't tell, right? No, of course not. In c++, ++ is just a function with a different syntax. Therefore your straw-man example is equivalent to the example I gave. Hopefully you can now see how silly your complaint is. Yeah, I know. IHBT.

      *I have nothing against java, but it does not have the magic properties you ascribe to it.

      --
      SJW n. One who posts facts.
    29. Re:yawn by beej · · Score: 1

      I have to agree to a certain extent. It's a large language to wrap your head around. Compare it to the D language, for example, especially before D 2.0. (No language wars intended. I don't program in D.)

      To better understand C++ and know what you're getting into, I recommend the book "Inside the C++ Object Model". Also, "C++ FAQs".

      Since the FAQ book weighs in at 566 pages, I think you might have a case.

      One of the replies to your post said you'd have these problems in any language if you didn't understand it. This is true, but some languages are easier to understand than others. Look at the online C FAQ. Look at the C++ book compared to K&R2. C and C++ are not in the same complexity class. Therefore, I would argue, it's easier to avoid these types of problems in C than in C++.

      That being said, I worked on a major project with a half-dozen other engineers that consisted of about 1 MLOC of C++. It worked absolutely fine, and being OO was great for the application. I can't remember any of us being bitten by C++isms, but we used basic C++, e.g. no templates, no multiple inheritance, and so on. Kept it simple because that's all that was needed.

      Don't be afraid of C++. But most definitely read the entire FAQ Book. "Practice, prrractice!"

    30. Re:yawn by master_p · · Score: 1

      1 million LOC and you did not use templates?

      You did not use collections? nothing from the STL?

      I don't understand what kind of application can have 1 MLOC and not use templates at all. You didn't even need the STL once? what kind of app was that? where did you store your data in memory? didn't you use lists, vectors, maps etc?

      I really doubt your statement is true. I can't imagine a C++ program without at least one template in use.

    31. Re:yawn by beej · · Score: 1

      Well, I admit it might have had a few; I didn't go over all the code. But by LOC, the lion's share didn't.

      It was on a specialized piece of hardware running a half-inhouse-built OS. Everything was resident all the time and we were very conscious about when objects were created and destroyed (preferably rarely.) Memory limits were a serious issue.

      didn't you use lists, vectors, maps etc?


      Not the STL variety, no.

      I can't imagine a C++ program without at least one template in use.


      It's not that far-fetched. Lots of languages get by just fine without using them. (Though they definitely have a use.) In some situations, it's not such a heinous crime to not use STL.

    32. Re:yawn by sibte · · Score: 1

      Absolutely right! None of them are as fast as C or C++

    33. Re:yawn by shutdown+-p+now · · Score: 3, Informative

      All languages have "implementation details" and various gotchas.
      It's true, but some have more, and others have less, and C++ is on the "a fucking lot" end of the spectrum. Of all the languages I know, the only one that has more (mostly because it covers a lot more ground) is Common Lisp.
    34. Re:yawn by shutdown+-p+now · · Score: 1

      For example, if you declare even one virtual member function, you HAVE to declare your destructor virtual.
      Not really. You only have to do that if you want to access (to be more precise, delete) objects of classes derived from yours via a pointer or reference to your class. Granted, if you have a class with virtual functions, pointers/references will almost certainly be involved, but still, it is possible to code like that.
    35. Re:yawn by shutdown+-p+now · · Score: 1
      Have a look at wxWidgets. I don't know how large their codebase is, but it's pretty large, and they don't use templates at all. They hate them so much they've replaced them with macros...

      Of course, while this might have had some sense in 1998, it's sheer idiocy in 2008, when all mainstream C++ compilers have been handling moderately complicated templates for several years already.

    36. Re:yawn by Abcd1234 · · Score: 1

      You're right about the scripting languages, but Objective-C isn't as fast as C or C++? Huh, news to me...

    37. Re:yawn by bigstrat2003 · · Score: 2, Insightful

      Oh, java must be crap because you can't tell, right? It's pretty damned easy to tell what should happen. f(foo(a)); should run f on the return value of foo(a). f(a); foo(a); will depend on the specific functions involved (and whether a is passed by reference or value), so it isn't the language's fault if your example is bad. In the c++ example, the expected behavior is clear: f(a++) should be the same as f(a); a++; because it's a postfix increment. If the actual behavior doesn't match that, that's C++'s fault. Likewise, if the Java behavior doesn't match what's logical, that's Java's fault.

      Also, saying "Java sucks too so that makes C++ not suck" doesn't hold any water. If C++ sucks, and Java sucks too, they both suck, C++ doesn't magically become ok. It's not like C++ sucking depends on Java not sucking.

      --
      "16MB (fuck off, MiB fascists)" - The Mighty Buzzard
    38. Re:yawn by Chemisor · · Score: 2, Insightful

      > When I'm driving my car and I turn the steering wheel right, I expect the car to run right, without having to think

      That's what I would expect when using your software, because that is the proper analogy to driving the car. Programming is more like designing the car, and yes, you do want to know what the steering wheel does. What if car designers just had little modules described as "this thingy makes the car turn right"? Then they would just snap the parts together and secure them with duct tape. Would you drive a car designed in this manner? I thought not.

    39. Re:yawn by Chemisor · · Score: 1

      > Gee, you THINK you can do X because it's perfectly legal syntax and it makes sense because
      > you do X in other object-oriented languages, but in C++ it either fails outright or its
      > undefined behavior in the language

      This is precisely my point. You learn some "object-oriented language" and then come here bashing C++ when it fails to conform to your academic ideas on how a language ought to behave. Well, don't do that! C++ is not an "object-oriented" language in the academic sense. You need to get out of your ivory tower more.

      > For example, if you declare even one virtual member function, you HAVE to declare your destructor virtual.

      No you don't. The reason you declare a virtual function is to use an object through a pointer. The reason you declare a virtual destructor is to delete an object through a base pointer. Just because you do one, doesn't mean you do the other. C++ gives you control over how you use your objects, and it is a good thing. If you learn the C++ concepts in the C++ way, instead of through the lens of some other language, you will not be suffering from delusions.

      > This, most emphatically, is not "you let the language shape your thoughts", this is psychosis.

      Yes, when you try to combine your ideology with the C++ way, psychosis is precisely what will result. Give in! Surrender! The C++ way is the one true way! :)

    40. Re:yawn by orzetto · · Score: 1

      For example, if you declare even one virtual member function, you HAVE to declare your destructor virtual. Ummm, what? Don't I get some help from the compiler?

      You get a warning from the compiler. If you choose not to heed the warning, well you get what you deserve, mister.

      --
      Victims of 9/11: <3000. Traffic in the US: >30,000/y
    41. Re:yawn by hazah · · Score: 1

      you HAVE to declare your destructor virtual

      No, you don't. It's a good idea to, but you DON'T HAVE TO, hence, the language does not force you to.

      In case you're missing it: you can forgo the late binding mechanism if you know that you'll never destroy your object through a base class pointer.

      Sure, that would be poor design, but what you present is essentially a straw-man argument.

    42. Re:yawn by tcc3 · · Score: 1

      Nonsense. Anytime theres a problem with the code its because you forgot a semicolon.

      Every one knows that.

    43. Re:yawn by sibte · · Score: 1

      I did'nt comment on Objective-C. Haven't got a chance to work on it yet

    44. Re:yawn by Anonymous Coward · · Score: 0

      So just what is a protected abstract virtual base pure virtual private destuctor, and when was the last time you needed one? Wow, your incredible ability to string words together at random has really convinced me that C++ sucks. I suppose I'll switch to a language that doesn't have any words associated with it at all. That's bound to be far better!
    45. Re:yawn by Dog-Cow · · Score: 1

      Just to add to your point, my cousin Stephen might argue about ph and f sounding the same.

      (I really have a cousin named Steven, but he doesn't spell it with ph.)

    46. Re:yawn by Plutonite · · Score: 3, Insightful

      This is the problem with people who don't know how to appreciate C++ capabilities. Do you even know why a "virtual" declaration on a method may be useful, or what it does internally? The whole idea is that you write code that can call methods named in a base class but defined in a derivative (child), via pointers. So, if you want to keep your code clean, you just have one line like:

      Parent *p = new Child();

      and the rest of the "user" code stays the same. You change the one line above to change functionality of every virtual method.

      Now since destructors are called implicitly most of the time, and since you OBVIOUSLY DECLARED VIRTUAL METHODS FOR A REASON, the compiler will warn you if the destructor is not virtual too, because then the object will be destructed as if it is a Parent object. It is a very valid warning, and will save you memory leaks(child objects contain more stuff to be freed..etc). It all makes sense now, see. The compiler is being nice, yes? Do you not agree that you should be blushing, after accusing the heavenly father Stroustrup of psychosis?

      Advice for life in general: If you don't know how to use something, don't use it ;)

    47. Re:yawn by ultranova · · Score: 1

      Whenever you want to use a language, you must learn it first. That's true even of Visual Basic.

      Actually, I wrote my first Python and PHP programs before I had learned the languages - just opened their homepages in a browser and began writing :). Horrible programs, of course, but they do their job (automatic downloading and archiving of binary newsgroups into a PostgreSQL database, and a Web-based viewer for said database, respectively, although the viewer has been re-implemented as a Java servlet).

      Trying to write code without any idea about the underlying ideas of a language has its own perverse joy, especially the first time the program runs over a minute without crashing... IT'S ALIVE !!!! And looks the part too ;).

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    48. Re:yawn by ultranova · · Score: 3, Insightful

      When I'm driving my car and I turn the steering wheel right, I expect the car to run right, without having to think about exactly how all the rods and pinions and bearings and whatever are making the car turn right. Sure, I need to know that the more I turn the steering wheel, the tighter I turn, but that should be it. Why should a programming language force me to think about low level implementation details that are nothing to do with the algorithm I'm trying to write?

      Because a programmer is a car designer, assembler or a mechanic, depending on his specific job description. The user of the program is analogous to the driver of a car.

      If you want to be a car mechanic, you'd better learn how cars work. If you want to be a programmer, you'd better learn how programs work. You'd think this would be bloody obvious, but oh well...

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    49. Re:yawn by drinkypoo · · Score: 1

      To be honest, you don't need to know precisely how cars work to be a mechanic. I am perfectly capable of doing an excellent job making a mechanical repair to almost any part of my car, though I would hesitate before messing about with engine or geartrain internals for lack of good precision measurement tools, which I do know how to use correctly... if only I had them. Yet I still learn something new almost every time I work on one, though this is not least because I do occasionally work on other people's cars and only take jobs I find easy or interesting, or feel I should practice. Granted I know a super-shitload more than most people, but what I'm getting at is that I'm not qualified to be an engineer, but I am qualified to be a mechanic. I'm not really qualified to write you a new fuel map, but probably know enough to figure it out over time if I didn't burn something up first :) There is plenty of money to be made doing the kind of stuff I can do if you don't mind getting greasy. I do mind getting greasy if it's not my car, which is why I have a totally unused certificate in automotive A/C. I was planning to get a degree in auto body and paint on the basis that we'll be painting things for a long time... but hell, that's about as toxic as anything I've ever done. Just another reason to make money computing.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    50. Re:yawn by Anonymous Coward · · Score: 0

      OMFG. I'm glad you're not working for me since "having to think about implementation details" is what programming is all about.

      I'm betting you prefer HTML.

    51. Re:yawn by pigwin32 · · Score: 2, Funny

      Umm, QED?

    52. Re:yawn by andy_t_roo · · Score: 1

      /me cheers for the best car analogy in the thread

    53. Re:yawn by drinkypoo · · Score: 1

      I've definitely learned what little I know of PHP (very little, thankfully) by hacking Drupal modules. I've submitted a few patches which have been adopted so if you are out there using Drupal there's a chance you're using some of my code (run away!) I originally learned to write useful perl scripts (not very complicated, but then, I think we all know the saying that applies best here) with the online documentation. Did I really know what I was doing? No, but like any clever money, I can see monkey doo. Wait, is that how it goes?

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    54. Re:yawn by Mitchell+Mebane · · Score: 1

      Not to mention make you susceptible to bugs.

      --

      The roots of education are bitter, but the fruit is sweet.
      --Aristotle
    55. Re:yawn by Anonymous Coward · · Score: 0

      I'd suggest you to learn the language. Virtual destructor is not needed every time you have a virtual member function... this is why the language lets you declare one when you need one ...

    56. Re:yawn by TimboJones · · Score: 1

      Hilarious!

      Post: All languages have "implementation details" and various gotchas.
      Reply 1: Yeah, but C++ has so many. Lisp has the fewest.
      Reply 2: Yeah, but C++ has so many. Only Lisp has more.

    57. Re:yawn by master_p · · Score: 1

      That's one of the reason I don't like wxWidgets. Macro hell? not for me!

    58. Re:yawn by Anonymous+Brave+Guy · · Score: 1

      Of all the languages I know, the only one that has more ... [gotchas] ... is Common Lisp.

      You really need to learn more languages. Tried programming any Perl recently, for example?

      C++ has its fair share of dangers, like any low-level language. However, most of them only become "gotchas" if you stopped reading at chapter two of the textbook and never learned to use the language properly. Techniques for things like avoiding memory leaks and exception safety in C++ have been known for literally decades, require negligible effort to use, and have been well documented in the literature. It's not rocket science.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    59. Re:yawn by goose-incarnated · · Score: 1

      Whenever you want to use a language, you must learn it first. That's true even of Visual Basic. The reason you see those problems of yours as "gotchas" is that you don't understand how the language (and, in the case of C++, the computer) works. If you let the language shape your thoughts instead of trying to cram your crummy thoughts into C++, it would have been much easier and simpler for you. I used to think like that when was still a C++ programmer, until one day I read an FAQ somewhere that details the possible differences between "f(a++)" and "f(a); a++;". That's when I saw the light and seriously switched to Java. I think when a normal person looking at a normal piece of code cannot know what it will do, there is something wrong with the programming language.

      Quick question (which I always used to interview candidates claiming familiarity with C++):

      What, if any, are the differences between 2 programs, one using "f(a++)" and the other "f(a); a++;"? For added fun, also compare "f(++a)" and "++a; f(a);".

      Hint: If you answer "no difference" you don't know enough about C++.

      More hint: there are at least 2-3 ways where the result of the program can differ significantly, depending on the signature of f(), the actual type of a, how is operator ++ defined for that type, etc.

      Your entire argument is wrong - you must have gotten confused by something like "f(a++) + a", because the examples you give are all well-defined.
      --
      I'm a minority race. Save your vitriol for white people.
    60. Re:yawn by khchung · · Score: 1

      I am quite surprised there will be people replying yet still don't get it even with the hints provided.

      It has been years since I worked deeply with C++, but off the top of my head, I can still remember these possible differences.

      First, for the simpler cases, when "a" is of the simple types, such as "int", and assume a=10 initially:

      1. If f() is declared as f(int& a) - i.e. takes a reference, then might have changed value of a, e.g. set it 20. Then with "f(a); a++;" you get a=21 afterwards. With "f(a++)", a remains 11 since, surprise, a reference to a temporary instance of int of with the old value of a is passed to f().

      Second, if "a" is of a class type, e.g. of class "A", it gets even more fun

      2. If f() is declared as f(A& a), taking a reference, the usually caveat about modifying a reference to a temporary copy still applies, but now it also depends on how the ++ operator is defined for class A. You know, A::++() could have returned the reference to the same instance afterall, such as if the ++() operator is not about changing value but performing some action. Stupid? As stupid as using the bitshift operator for reading/writing from a stream. Don't underestimate the creativity of your fellow programmers.

      3. At the very least, the execution order of the ++ operator and the f() is reversed.

      4. Have more fun considering the possibility of global variables modified in f() and the A::++() operator! Remember, the order of execution is different in the 2 cases.

      5. If f() is declared as f(A a), have extra fun now you add in the copy operator to the mix for the temporary copy created when f() is invoked! Think again of the different execution order for the 2 calls. Hint: in one case ++() is called first, in the other it is called last.

      6. If the above are not enough, consider the possibility that there is no matching function f(A), BUT there is one f(B) where the typecast operator from A->B exists. Have even more fun considering the possible execution order, global variable dependency, etc.

      7. Add in the fun with polymorphism with virtual ++ operator, virtual typecast operator, etc.

      8. Have extra bonus fun with considering what happens if f() or ++() throws exception (Thanks AC for this, I haven't even considered exception until you mentioned it)

      Bottom line is unless you know exactly how f() is defined and exactly how type A is defined, you cannot be sure if it will safe to replace "f(a++)" with "f(a); a++;". Won't that be great if either f() or A comes from a third party library?

      When you can't even be sure with basic operations like function call and post-increment operator, it is beyond reasonable to expect a normal average programmer NOT to hit some gotchas in a normal program.

      BTW, you Java example is wrong too. It should be replacing "f(foo(a))" with "A a = foo(a); f(a);". And guess what, no matter how f() and foo() is defined, as long as A is the return type of foo(), you can be sure the two forms will give the same results, even in the case of exceptions.

      --
      Oliver.
    61. Re:yawn by shutdown+-p+now · · Score: 1

      You really need to learn more languages. Tried programming any Perl recently, for example?
      Sure. I know a fair few languages, from Lisp and Scheme to Python and Smalltalk to Haskell and Objective Caml, and some weird stuff like ALGOL 60 (now that's another ancient gem of horrors lurking in the corner cases).

      The real gotchas in C++ do not have to do with exception handling or manual memory allocation (both are widely known and practiced elsewhere). It's weird stuff like: silent conversions in mixed signed/unsigned integer arithmetic; template function overload resolution (just try to read the corresponding paragraph from the Standard aloud, and see if it makes sense the first time you do that); "typename" qualifiers for nested dependent types and "template" qualifiers for nested dependent templates; behaviour of constructors in virtual base classes ("what do you mean, it wasn't called with the arguments I specified?"); argument-dependent lookup (can you quickly remember the trick that has to be used to call swap() properly, to call the efficient specialized overload if one is available, and fall back to std::swap if one is not?); SFINAE (do you remember what errors are failures, and what aren't?); constructors defaulting to being implicit conversion operators - this in addition to the ability to define proper conversion operators; complicated rules for building chains of conversions, differentiating between built-in conversions and user-defined ones, and then between operators and constructors (do you remember the one and only case where two user-defined conversions can happen implicitly one after another?); difference in default initialization and lifetime of POD vs non-POD types; silent array-to-pointer decay in function signatures (but not elsewhere); etc. I could go on and on. It really is a mess. This doesn't make it any less successful or useful as C++ is, already, but to fully use the language, to understand any code that is thrown at him, and to quickly find bugs, a C++ programmer needs to know much, much more than programmer in most other mainstream languages.

    62. Re:yawn by Anonymous+Brave+Guy · · Score: 1

      I guess I just look at this from a slightly different perspective.

      Sure, there's no disputing that templates and overloading are pretty much a disaster in C++. Given what they do, and the number of other languages with features at least as powerful yet somehow expressed with a clear, unambiguous model in orders of magnitude less space, this area of C++ is remarkable for all the wrong reasons.

      The pointer/array/string stuff is a mess C++ inherited from C, but I think the rules are fairly clear once you get used to them. Crucially, almost every C++ programmer does get used to them very quickly because they are so commonly used.

      I'm not sure I'd agree about the conversion ones: while some are counter-intuitive, you can get similar (and indeed much worse) ambiguities and pitfalls in almost any of the popular dynamically typed languages, and if you run into them in practice it is usually a symptom of a broader design failure anyway.

      So while I agree that many of the examples you gave are far from ideal, I'm not sure I would call them gotchas. I don't think something counts as a gotcha unless, well, it's likely to get an unsuspecting developer in real life. As those go, I'm not sure C++ is so much worse than PHP with its random name generation for library functions, Perl with its frequent use of implicit variables, early Java with the boxing/unboxing mess, Haskell with writing things twice because of monads and lifting, etc. etc.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    63. Re:yawn by Nicolay77 · · Score: 1

      And with macros you can program your own gotchas.

      --
      We are Turing O-Machines. The Oracle is out there.
    64. Re:yawn by Nicolay77 · · Score: 1

      Actually, I find using those macros easier than using the equivalent templates.

      The point is: those macros are already written and only the wxWidgets developers suffer from macro hell, not the end users.

      --
      We are Turing O-Machines. The Oracle is out there.
  9. everything programmers should know about C++? by OglinTatas · · Score: 5, Funny

    in an 8 page interview? I feel like a sucker for buying the 900 page book

    1. Re:everything programmers should know about C++? by linal · · Score: 2, Funny

      Just be thankful you didn't buy this book
      http://www.amazon.com/gp/product/1418499757/ref=cm_rdp_product

    2. Re:everything programmers should know about C++? by 192939495969798999 · · Score: 2, Funny

      Yeah, he is apparently very good at refactoring.

      --
      stuff |
    3. Re:everything programmers should know about C++? by GeckoX · · Score: 2, Funny

      Yeah, but that's 8 pages of pointers into said book ;)

      --
      No Comment.
    4. Re:everything programmers should know about C++? by Anonymous Coward · · Score: 0

      Warning: Offtopic

      Funniest review ever on Amazon!

    5. Re:everything programmers should know about C++? by tehcyder · · Score: 1

      FFS it didn't even have a "Hello World" program!

      --
      To have a right to do a thing is not at all the same as to be right in doing it
    6. Re:everything programmers should know about C++? by toriver · · Score: 1

      No, it's just excellent compression.

    7. Re:everything programmers should know about C++? by shutdown+-p+now · · Score: 1

      Absolutely; you can do just fine with a different 800-page book.

  10. And ... by LizardKing · · Score: 4, Informative

    ... for an equally partisan view from another perspective, the C++ FAQ.

    1. Re:And ... by Kamineko · · Score: 2, Informative

      In case anybody got confused, that's FQA above, not FAQ. This is FAQ: http://www.parashift.com/c++-faq-lite/index.html

    2. Re:And ... by Anonymous Coward · · Score: 4, Insightful

      ...it's largely a waste of time. The author spends an inordinate amount of time complaining that C++ prefers compile-time overhead to run-time overhead, and has no understanding that C++ is designed to have no unnecessary performance penalty relative to C. It would be nice if he did, as whatever insights the FQA author has concerning OO languages could be gleaned without wading through a few thousand lines of whining over the lack of things like garbage collection, heap compaction, run time bounds-checking, etc. He also has apparently never heard of Boost.

    3. Re:And ... by Anonymous Coward · · Score: 0

      Heh, I was expecting to have to leap to C++'s defence there, but that guy is essentially complaining that C++ isn't a high-level virtual machine based language and... well, it isn't.

      The biggest design problems with C++ are that there is no proper ABI (you have to use binaries from the same compiler) and and it never actually encourages you to use good technique even though such techniques do usually exist. I guess the second problem is a bit abstract but it does lead to trying to do things that seem to be OK, but are really much better accomplished through some other means. The practical points he made about debugging and compilation are spot on though; tracing heavily inlined optimised core dumps are a real pain and error messages a always at the place where a type is derived rather than instantiated (fixed in C++0x sort of). It takes a long time to get used to what you're compiler is trying to tell you and the compiler takes bloody ages to tell you. The fact that the language is so complicated does definitely make it harder to understand why certain decisions are made in C++ projects even if those decisions make perfect sense.

      As with all language wars, it's all ultimately pointless. Sometimes you need something a bit like C, but with exceptions, or a way to have type-safe meta-code, or low-level code with high-level constructs, or any number of the other (all be it probably too many) things that C++ was designed to do. If you don't need these things then don't use C++; otherwise take the time to learn how C++ actually works so that the oddities---and it is an odd language---don't affect you.

    4. Re:And ... by tepples · · Score: 1

      He also has apparently never heard of Boost. I beg to differ: "don't try to 'fix' it (or 'boost' it)".
    5. Re:And ... by croftj · · Score: 1

      This looks like it was written by Sun trying to convince folks why Java should be used instead of that clunky old C++

      --
      -- Many men would appreciate a woman's mind more if they could fondle it
    6. Re:And ... by ChadN · · Score: 1

      Wow, I'm not sure if you did it intentially, but you linked to the C++ FQA, *not* the C++ FAQ. I'll assume from context that's what you meant, and just labeled it wrong.

      In any case, both are very useful reads:

      http://codemines.blogspot.com/2007/10/no-updates-for-6-months-then-two-in-day.html
      http://www.parashift.com/c++-faq-lite/
      http://yosefk.com/c++fqa/index.html

      --
      "It's overkill, of course. But you can never have too much overkill." - Anonymous Slashdot Coward
  11. Favorite line... by wiredog · · Score: 3, Funny

    programs in C++ could be simultaneously elegant ... and efficient for systems programming... Obviously, not every program can be both and many are neither

    Many are neither. Ain't that the truth.

  12. Everything you need to know about C++ by Anonymous Coward · · Score: 1, Funny

    Avoid it like the plague!

  13. Has he grown a beard? by Anonymous Coward · · Score: 1, Funny

    Some of you might remember the article at:

    Facial Hair:Coding Success

    Has Bjarne grown a beard or something? That's the only way I can explain that he's on the front page of slashdot today.

    1. Re:Has he grown a beard? by swilde23 · · Score: 1

      I saw him at SDWest this past March and he was beardless then. However, that was three months ago, so anything is possible.

      --
      There are 10 types of people in the world. Those that understand this sig, and those that beat up people who do.
  14. The name by Anonymous Coward · · Score: 2, Funny

    FTA they tried calling it C with Classes, but that didn't stick, so they asked for suggestions and got C++

    I think they should have called it Class-C. Much more fun to pronounce.

  15. The Truth about C++ by Anonymous+Admin · · Score: 5, Funny

    On the 1st of January, 1998, Bjarne Stroustrup gave an interview to the IEEE's Computer magazine.

    Naturally, the editors thought he would be giving a retrospective view of seven years of object-oriented design, using the language he created.

    By the end of the interview, the interviewer got more than he had bargained for and, subsequently, the editor decided to suppress its contents, for the good of the industry, but, as with many of these things, there was a leak.

    Here is a complete transcript of what was was said,unedited, and unrehearsed, so it isn't as neat as planned interviews.

    You will find it interesting...

    Interviewer: Well, it's been a few years since you changed the world of software design, how does it feel, looking back?

    Stroustrup: Actually, I was thinking about those days, just before you arrived. Do you remember? Everyone was writing 'C' and, the trouble was, they were pretty damn good at it. Universities got pretty good at teaching it, too. They were turning out competent - I stress the word 'competent' - graduates at a phenomenal rate. That's what caused the problem.

    Interviewer: problem?

    Stroustrup: Yes, problem. Remember when everyone wrote Cobol?

    Interviewer: Of course, I did too

    Stroustrup: Well, in the beginning, these guys were like demi-gods. Their salaries were high, and they were treated like royalty.

    Interviewer: Those were the days, eh?

    Stroustrup: Right. So what happened? IBM got sick of it, and invested millions in training programmers, till they were a dime a dozen.

    Interviewer: That's why I got out. Salaries dropped within a year, to the point where being a journalist actually paid better.

    Stroustrup: Exactly. Well, the same happened with 'C' programmers.

    Interviewer: I see, but what's the point?

    Stroustrup: Well, one day, when I was sitting in my office, I thought of this little scheme, which would redress the balance a little. I thought 'I wonder what would happen, if there were a language so complicated, so difficult to learn, that nobody would ever be able to swamp the market with programmers? Actually, I got some of the ideas from X10, you know, X windows. That was such a bitch of a graphics system, that it only just ran on those Sun 3/60 things. They had all the ingredients for what I wanted. A really ridiculously complex syntax, obscure functions, and pseudo-OO structure. Even now, nobody writes raw X-windows code. Motif is the only way to go if you want to retain your sanity.

    [NJW Comment: That explains everything. Most of my thesis work was in raw X-windows. :)]

    Interviewer: You're kidding...?

    Stroustrup: Not a bit of it. In fact, there was another problem. Unix was written in 'C', which meant that any 'C' programmer could very easily become a systems programmer. Remember what a mainframe systems programmer used to earn?

    Interviewer: You bet I do, that's what I used to do.

    Stroustrup: OK, so this new language had to divorce itself from Unix, by hiding all the system calls that bound the two together so nicely. This would enable guys who only knew about DOS to earn a decent living too.

    Interviewer: I don't believe you said that...

    Stroustrup: Well, it's been long enough, now, and I believe most people have figured out for themselves that C++ is a waste of time but, I must say, it's taken them a lot longer than I thought it would.

    Interviewer: So how exactly did you do it?

    Stroustrup: It was only supposed to be a joke, I never thought people would take the book seriously. Anyone with half a brain can see that object-oriented programming is counter-intuitive, illogical and inefficient.

    Interviewer: What?

    Stroustrup: And as for 're-useable code' - when did you ever hear of a company re-using its code?

    Interviewer: Well, never, actually, but...

    Stroustrup: There you are then. Mind you, a few tried, in the early days. There was this Oregon company - Mentor Graphics, I think they were called - re

    1. Re:The Truth about C++ by Anonymous Coward · · Score: 3, Interesting

      What a wonderful bit of fiction. I did find it entertaining, so thank you.

      I have worked with some very good programmers, and some mediocre ones. The very good ones usually liked C++, and often preferred it when given a choice. The younger (good) ones tend to go with C# these days, though they don't bad-mouth C++.

      It is always the mediocre ones who badmouth C++.

      That has just been my experience, I don't know if this is true across the board, but I do encounter this a lot. Average and below-average programmers hate C++ with a passion, whereas the really good ones like it (or at least respect it).

    2. Re:The Truth about C++ by GeckoX · · Score: 1

      Er, hardly a Troll there mods. It's definitely personal opinion, (And one that I would have to agree with from personal experience), but not a troll.

      --
      No Comment.
    3. Re:The Truth about C++ by Mongoose+Disciple · · Score: 3, Interesting

      Nice. If you don't like C++, it must be because you're a bad programmer.

      It's much harder to write C++ code that, for example, will never leak memory no matter what goes wrong than in the assorted garbage collected languages, or even vanilla C. That, I don't see how anyone could even reasonably argue.

      C++ was an important step on the way to better languages (for the problems it was trying to solve -- not for everything), but that doesn't mean that given today's alternatives it should be considered good.

      Being a good programmer is about being good at solving the problem at hand in a clean, maintainable way. It's not about being able to memorize the weird inconsistencies in a language or fight a better fight with a difficult language. Even for a project that has to be done close to the machine, you'll almost always get in less trouble using C. (Or, if you must, using C++ but generally ignoring the C++ features.)

    4. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      Nice. If you don't like C++, it must be because you're a bad programmer.

      The parent didn't say that. The parent said that bad programmers tend to dislike C++.

      You have committed the fallacy of affirming the consequent, which has this form:

      If A then B.

      B.

      Therefore A.

      Or, more specifically...

      If you are a bad programmer, you probably dislike C++.

      You dislike C++

      Therefore, you are a bad programmer.

      This is a logical fallacy that you committed (not the parent), and which caused you to put words in the parent's post.

    5. Re:The Truth about C++ by johannesg · · Score: 1

      I'm not sure why this garbage is not being collected, but honestly, C++ making it easier to leak memory than C? What are you smoking, and can I have some?

    6. Re:The Truth about C++ by lefticus · · Score: 5, Insightful

      Yawn.

      If you don't like C++, you probably just don't understand it. Yes, it's a complex language. However, if you use RAII (a fundamental tenant of C++) you will not. leak. memory. ever. Same arguments about C++ are used over and over again by people who don't grok the language. Is it the end-all be-all language? No. But it is darn good at what it does (performance minded system level code) with almost none of the problems C has (memory leaks and weak typing).

    7. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      It's much harder to write C++ code that, for example, will never leak memory no matter what goes wrong than in the assorted garbage collected languages, or even vanilla C. That, I don't see how anyone could even reasonably argue.

      Yeah, I don't see how somebody could argue the point that you made, either. You know, the part where you said C deallocation is easier than C++.

      What about free is easier than delete, again? You know, other than that delete also calling a destructor which can delete more of a structure hierarchy for you (so you don't need a special free_my_struct function like you do in C).

      And you've obviously never used a smart pointer class. I haven't had a single memory leak since I started using boost::shared_ptr.

    8. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      "Nice. If you don't like C++, it must be because you're a bad programmer."

      No, it's because you don't know the proper techniques (RAII, smart pointers), which aren't that difficult to learn or apply. Once you know them, the opposite is true (it's easier to write something in C++ that doesn't leak than in some language that doesn't support RAII where you rely on GC instead--say, java).

      It's not a matter of "You idiot--you forgot to delete your memory", but rather, "You idiot. Why are you using naked pointers to hold onto memory?"

    9. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      Excuse my newbishness, but if C++ is on the downslide, what is replacing it? Are coders back peddling to C or are there new things taking it's place? I'm not a coder, but find this rather interesting.

    10. Re:The Truth about C++ by TerranFury · · Score: 1

      It's true, there are a lot of C++ features I don't really understand.

      Not "getting" RAI, though, is not, I think, where my problem lies. It makes perfect sense to write code that way. The problem for me is implementing RAI in C++: It's all the damned constructors and destructors that get me. I want one way to make a new FOOMINATOR, one way to kill a FOOMINATOR, and maybe one way to copy a FOOMINATOR. Unfortunately in C++ this isn't enough! My issue is that I get confused with all the "ways in" and "ways out" of existence that objects have. At the very least, I wish C++ would do away with its "automatically do a shallow copy when you haven't provided an appropriate constructor for this case" policy and produce an error (or at least a warning), so I'd know when I was doing something stupid. I expect that if I wrote C++ more I'd get used to it, but as it stands I'm pretty happy achieving pretty much the same thing with C with structs, functions, and multiple files. Then, I do pretty much the same things as all the C constructors and destructors, but it's very explicit, so I understand what's happening. The difference between this C approach and C++ strikes me as syntactical sugar which, for my uses, is currently more confusing than useful.

      But hey, I don't program for a living. I program for fun, and for my research (though MATLAB, horrid language that it is, is largely taking over in my toolbox for that, since its matrix manipulation and its libraries are wonderful. The commandline interface is also very nice; it makes for a very good debugging environment). So it's doubtful that I'll pick up C++ any time soon -- unless someone has a nice set of libraries they can recommend to duplicate MATLAB's functionality in C++.

      So you see why, for this user, C++ hasn't caught on. Right now, I don't see anything at the top of the learning curve that makes the slope worth climbing. I'd rather spend my time (when I'm not procrastinating on Slashdot) learning theory.

    11. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      With constructor destructor pairs, there should not be a problem in managing memory unless you neeed to do fancy tricks. But for all concrete classses, please have the constructors and destructors handle the memory management problem (whether directly, using allocators...). This means that most variables/objects will act as local variables which will simplify everything as they will just free their ressources once they go out of scopes.

    12. Re:The Truth about C++ by serviscope_minor · · Score: 1

      It's much harder to write C++ code that, for example, will never leak memory no matter what goes wrong than in the assorted garbage collected languages, or even vanilla C. That, I don't see how anyone could even reasonably argue.

      Wow. I have heard some crap about C++ in my time, but this ranks up there. Myself, I don't like C++ because it makes pixies fly out of my nose, and that makes me sneeze. Firstly, if you often use new and delete, then you're doing it wrong. Secondly, if you love C so much, then why not use full-on C style memory management? Then it's almost exactly the same as C.

      --
      SJW n. One who posts facts.
    13. Re:The Truth about C++ by Mongoose+Disciple · · Score: 1

      You know, the part where you said C deallocation is easier than C++.

      Except that's not what I said. I said it was harder to write C++ code, using the C++ language features that differentiate it from C, and not leak memory.

      Freeing up the memory when you know you need to is easy. Catching every case in which you need to no matter what unexpected thing happens is not easy. A C++ programmer who thinks it's easy either has been working with C++ a very long time, or, more likely, is leaking memory and doesn't realize it.

      Yeah, the C++ community has tried to come up with solutions to these problems; IMHO, the cure is almost always worse than the disease.

    14. Re:The Truth about C++ by Mongoose+Disciple · · Score: 1

      Secondly, if you love C so much, then why not use full-on C style memory management? Then it's almost exactly the same as C.

      Of course C++ is no worse than C if you ignore all of its unique features, but then, what did using C++ get you?

    15. Re:The Truth about C++ by Mongoose+Disciple · · Score: 1

      With constructor destructor pairs, there should not be a problem in managing memory unless you neeed to do fancy tricks.

      What happens when an exception is thrown in your constructor or destructor?

    16. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      RAII only works when you're not sharing objects.

    17. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      > It's much harder to write C++ code that, [...] languages, or even vanilla C. That, I don't see how anyone could even reasonably argue.

      Except that C is virtually a sub-set of C++. So it can't possibly harder, unless you deliberatly choose not to do something in a clean, maintable way.

    18. Re:The Truth about C++ by jez9999 · · Score: 1

      Systems programming - C.
      Applications programming - C#, Java.
      Web scripting - Perl, Python, Ruby.

    19. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      Well, this is a problem I'm not that familiar yet. My programs need to take input, compute something , output the result then exit so I don't need fancy recovery techniques: if an exception is uncatched in a destructor, the program calls std::terminate which calls abort
      so no leaks there. The only exception that might be thrown in my constructors is bad_alloc, which I don't catch therefore terminate is called too.

      Anyway, I think it's still an improvement over C: to ensure you just have to be careful with constructors and destructors which makes it a local problem. In C to manage memory, you must consider the whole program as a whole in your head. I believe it's still harder to manage memory in C.

    20. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      In case someone reading this doesn't know, this is a well-known piece of humor, and not /actually/ a real interview.

    21. Re:The Truth about C++ by adonoman · · Score: 1

      If the constructor throws, the memory gets cleaned up automatically.
      Don't write destructors that leak exceptions.
      Just don't.

    22. Re:The Truth about C++ by Mongoose+Disciple · · Score: 1

      Don't write destructors that leak exceptions.

      Well, right. Wouldn't you say that's an added "gotcha" / source of complexity as far as doing memory management correctly, one that doesn't exist in most other languages?

    23. Re:The Truth about C++ by jamesswift · · Score: 3, Insightful

      It's much harder to write C++ code that, for example, will never leak memory no matter what goes wrong than in the assorted garbage collected languages, or even vanilla C. That, I don't see how anyone could even reasonably argue.

      Probably true. But what does that tell us about general language fitness really since it's equally as easy to hog resources in a language with GC? Database connections for example.

      When you absolutely need deterministic release of resources you end up having to approach the problem in a similar fashion to c++ memory management anyway.

      Many people believe seem to believe GC allows you to forget about resource management when it doesn't at all.
      It's a great tool for a certain class of problems but not a panacea.

      --
      i wish i could stop
    24. Re:The Truth about C++ by Mongoose+Disciple · · Score: 1


      Probably true. But what does that tell us about general language fitness really since it's equally as easy to hog resources in a language with GC? Database connections for example.

      When you absolutely need deterministic release of resources you end up having to approach the problem in a similar fashion to c++ memory management anyway.

      Many people believe seem to believe GC allows you to forget about resource management when it doesn't at all.
      It's a great tool for a certain class of problems but not a panacea.

      That's a good point, and absolutely true. My 'other resources' management code in GC languages does look a lot like my memory management code in C++ -- but slightly less so, because there are generally less gotchas around exception handling in those languages.

      In response, I'd only offer that almost all of the code I write uses what would amount to dynamic memory allocation in C++, but a much smaller subset of it uses database connection or other "unmanaged resources." I think it's easier to be good about something like that when it's less ubiquitous.

    25. Re:The Truth about C++ by jamesswift · · Score: 1

      Yeah, I'd guess your experiences are even reflective of most. But it's good to know about resource management as it will probably crop up at least once or twice in a reasonably complex program. The long and most boring debates around GC often seem to ignore this and many junior programmers come away with a misconception that they can forget about it.

      --
      i wish i could stop
    26. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      That's not the case.

      Original poster didn't just say If A then B. He also said if not A then not B:

      Paraphrased: Bad programmers dislike C++, good programmers don't.

    27. Re:The Truth about C++ by Anonymous Coward · · Score: 0

      if you use RAII (a fundamental tenant of C++) tenet
      The fu--ing word you meant is 'tenet'. Not tenant.

    28. Re:The Truth about C++ by mrriver · · Score: 1

      A real programmer uses the right language for the problem. Is C++ the best programming language for all the applications? Of course not! It's a very interesting language. But for several applications there is easier languages. For instance, for web applications Java or C# are good languages. And they are very very used for that. C++ could be used in web? Of course yes! C++ is a great programming language. It's my preferred language and beliave me, using it you can do anything. And the best part for me is because I almost allways can say to language/compiler how my program must be. Using other languages the runtime enviriorment make some choices for you. Are that choises the best for any application? Again... Of corse not. But they are good for almost all of them. It's why other languages are easier to learn. The programamenr don't have to thing about a lot of issues during development. But there is some not equal situations. And in this case, for instance, C++ is a good choice. Any programming language can be defined like a set of sintax rules and semantic rules. You must use the right language for the problem.

  16. Car analogy time by Anonymous Coward · · Score: 0

    Computerworld is undertaking a series of investigations into the most widely-used programming languages. Previously we have spoken to Alfred v. Aho of AWK fame, S. Tucker Taft on the Ada 1995 and 2005 revisions, Microsoft about its server-side script engine ASP, and Chet Ramey about his experience maintaining Bash.

    It's like having a series on car designers, where they're the teams responsible for the Renault 4, DeLorean, Trabant and NSU Ro 80 respectively.

  17. "What good progammers should think" by Anonymous Coward · · Score: 3, Funny

    and of course what all good code-writers should think about when using the language he created Let me guess. "How am I going to shoot myself in the foot today?"
    1. Re:"What good progammers should think" by Anonymous Coward · · Score: 0

      This has already been documented here

    2. Re:"What good progammers should think" by HyperQuantum · · Score: 1

      Don't you mean: "do I still have a leg to blow off today? ... Nope :("

      --
      I am not really here right now.
  18. diamond in the rough by Anonymous Coward · · Score: 0

    Good find. I don't usually look on websites that bill themselves as "The Voice of IT Management"---the reason why I wear headphones---but apparently even ComputerWorld can rise above the morass of vapid "IT" bullshit once in a while.

  19. Re:Bjarne does.....what? by geminidomino · · Score: 1

    BTW C++ is the worst programming language on Earth, a hideous abomination of some really bad ideas. Sounds like someone's never used PHP for anything more complex than a blog...
  20. Re:Bjarne does.....what? by Anonymous Coward · · Score: 3, Funny

    Inaccurate. You forgot COBOL. But that's understandable, I want to forget it, too.

  21. Language stability by Yetihehe · · Score: 2, Interesting

    I wrote C++ code 20 years ago that still runs today and I'm confident that it will still compile and run 20 years from now.
    Funny thing, I tried to use some c++ code, but after one day and correcting about 300 errors (about 20 different TYPES of errors) I gave up and scraped the code (this was Object-Oriented RayTracer from Nicholas Wilt).
    --
    Extreme Programming - Redundant Array of Inexpensive Developers
    1. Re:Language stability by LizardKing · · Score: 2, Insightful

      Stoustrup probably means the binary still runs on the now antiquated system it was originally compiled for. I very much doubt he means that the 20 year old source code still compiles with a modern compiler, as the language has changed way too much. So, Stoustrup's probably being a little bit disingenuous as usual.

    2. Re:Language stability by nuzak · · Score: 1

      Unless that C++ program was statically linked, it's ridiculously unlikely a 20 year old binary will still run. Even then, some kernels don't even bother supporting a.out at all.

      Hell, even Windows doesn't run a good chunk of 20 year old code, especially not Vista.

      --
      Done with slashdot, done with nerds, getting a life.
    3. Re:Language stability by Anonymous Coward · · Score: 0

      I rather suspect your problem comes from the fact that you reuse graphics-intensive code that relies heavily on outdated external libraries, headers, APIs...

      So a DirectX 10 API is going to be different from a GDI API, X11 APIs are going to be different from Quarz, and so on, so yeah, you can't just take a GUI program that compiled on 1984 Mac and expect it to compile on a 2008 linux pc. Not really C++ fault, is it.

      In contrast, Java, which is supposed to provide a total hardware abstraction bubble for your code, is a complete piece of shit. Even incremental VM upgrades break most old programs (say going to 1.5.11 to 1.5.14 or whatever that was...

    4. Re:Language stability by gbjbaanb · · Score: 1

      I have C++ code from 20 years ago that is still used in the products my company sells. I imagine most C++ will work, unless some relatively obscure (for the time) features were used. Most of the language hasn't changed at all.

      OK, it is somewhat "better C" than a full-on templated metaprogram.

    5. Re:Language stability by LizardKing · · Score: 1

      And how many times has that 20 year old code been modified so that it still compiles? I once worked on a largish (100,000+ LOC) project written in C++. It compiled without warnings in GCC 2.95, but when I attempted to compile it under GCC 3.0 the number of warnings were in the thousands, and it failed to link. Thankfully, our management allowed us to junk it and write a replacement in Java and a small amount of C.

    6. Re:Language stability by Anonymous+Brave+Guy · · Score: 1

      Did your code compile without warnings because it was correct, or because GCC 2.95 was broken? IIRC, a lot of people got stung with the move to GCC 3, but almost invariably because they had been using compiler-specific extensions.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    7. Re:Language stability by Logic+and+Reason · · Score: 1

      You re-wrote a 100,000-line project rather than fix some compiler warnings?

    8. Re:Language stability by NotZed · · Score: 1

      This has been my experience, over and over. BS is full of BS on this one. I suspect the code he was talking about was little more than straight C with some object syntax.

      If a package is not well maintained - or even if it is and it was written using an older or different compiler, it will almost always require work to get it building. I've given up downloading 'sample code' if it is written in C++ because it usually just wont work without more effort than I care to spend. Just 2 days ago I tried to customise the blackbox window manager, and it wouldn't build on a Fedora 9 box because of some changes to stdlib/stdio or something. The fixes required weren't big, but it just didn't build out of the box, and required some patching for gcc 3.4.

      C on the other hand, rarely has this problem - it is normally the other way around, using c-nothing features against a c-90 compiler. I'm sure this is one of the reasons C++ never replaced C outright (among the many other reasons such as it taking so long to be standardised and implemented even remotely well). That a language with such compiler dependencies has got as far as it has is a testament to marketing effort I suspect. And probably more than a little to do with the intentionally confusing name that makes it sound like C. Most people even make the mistake of saying 'C/C++' all the time when they are very distinct languages. I think all everyone ever really wanted was 'C with objects', not the mess they ended up with (which is why java and c-hash had an instant market).

      --
      _ // `Thinking is an exercise to which all too few brains
      \\/ are accustomed' - First Lensman
    9. Re:Language stability by LizardKing · · Score: 1

      Yes, because the pain of no new feature releases while we rewrote it were worth it in the long run. We ended up with something that was much more stable and maintainable, plus, we were able to use much better tools and libraries. It was easier to design decent API's and classes because we weren't worrying about C++ gotchas all the time, and in those places we got things wrong it was much easier to refactor. We were also able to reuse code written for the backend on portable devices like handheld scanners that can run a Java VM - quite important to us in the warehouse automation industry.

    10. Re:Language stability by LizardKing · · Score: 1

      There was certainly some crap in the codebase, but it was largely well written and fairly portable (it was originally developed with DEC's compiler for Tru64, and then ported to GCC). What we were really stung by was the drawn out standardisation of C++, and the compilers long catch up with the resulting standard. And I can't help feeling that any attempt to rectify the problems with C++ now are going to be too little, too late. They'd really need to break backwards compatability to fix some of the poor decisions made in the past, and I can't see Stroustrup and friends having enough balls to do that.

  22. Non Geeks by s31523 · · Score: 2, Interesting

    Everybody agreed that semantically ++C would have been even better, but I thought that would create too many problems for non-geeks. Um, how many non-geeks know anything about programming languages... Why worry about them.
    1. Re:Non Geeks by Creepy · · Score: 1

      Uh, how about
      Management types (PHBs)
      Book Store workers
      Publishers
      Librarians

      You may even have issues with some file systems.

      When it comes to computing, ignorance rules the masses - I'm still amazed at how many people still call / backslash (which I heard on the radio today when a DJ was giving a URL).

    2. Re:Non Geeks by Anonymous Coward · · Score: 0

      Um, mangers whom we have to get permission from.

    3. Re:Non Geeks by Anonymous Coward · · Score: 0

      ...because Marketing and Sales would have a harder time selling Plus Plus C. Sounds like a Japanese cola.

    4. Re:Non Geeks by TerranFury · · Score: 1

      ...because Marketing and Sales would have a harder time selling Plus Plus C. Sounds like a Japanese cola.

      Me, I was thinking we'd call it "Doubleplus C," and then it'd just sound too Orwellian.

  23. Re:Bjarne does.....what? by Yetihehe · · Score: 1

    I've used PHP/MYSQL to make some financial reporting web application which behaved very much like excel. I think it was still better than it would be in c++ (but in php it was about 1000 times slower, which I managed to get only 100 times slower after massive optimizations).

    --
    Extreme Programming - Redundant Array of Inexpensive Developers
  24. If you liked that, read "Design and Evolution"... by SuperKendall · · Score: 2, Informative

    The interview just seems like a very brief sampling of "The Design and Evolution of C++".

    Even if you do not care much about C++, it's an excellent look into the philosophy and thought that goes into language design.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  25. Hello by Nephrite · · Score: 1

    "Hello, C++, I'm your father"

  26. Re:managed code by AndrewNeo · · Score: 1

    Err, you mean like Managed C++?

  27. Re:managed code by Anonymous Coward · · Score: 1, Insightful

    unmanaged code is (deservedly) dying out.

    What are you smoking?

    Our shop now mandates only managed code.

    Which means some PHB swallowed Microsoft's .NET sales lines, not that native code is in decline.

    I think any language that doesn't support managed code is going to die out over the next 10 years.

    Think what you want, if that extends to the belief that kernels, device drivers or any serious (non-research) systems work is going to be deployed as memory managed JIT'd bytecode -- you're a fool. Performance optimizations are still inline ASM, put that in your "managed code" pipe and smoke it!

  28. Use this link to read article on one page by Animats · · Score: 4, Interesting

    First, read the printable version of the article on one page. The original version is one paragraph per page, surrounded by ads and related dreck.

    There's really nothing new there. It's the usual Strostrup stuff. He's still in denial about C++ being the cause of most of the buffer overflows, system crashes, and security holes in the world.

    The fundamental problem with C was the "array=pointer" concept. If array sizes were carried along with arrays, we'd have far less trouble. Even FORTRAN has conformant array parameters. That should have been fixed in C++, but it wasn't, and as a result, we had two more decades of buffer overflow problems. This isn't a performance issue, by the way; Modula 3 got it right, but Modula 3 disappeared for non-technical reasons - Compaq bought DEC and closed down the software R&D operation.

    C++ is also the only language that has hiding ("abstraction") without memory safety. C has neither; almost all later languages (Java, Delphi, all the scripting languages) have both. C++ stands alone in this unsafe place. Nobody ever repeated that mistake. So subtly incorrect calls to objects can result in the object overflowing.

    Yes, some of these problems can be papered over with templates. The C++ committee is full of templateheads, focused on template features that few will use and fewer will use correctly and productively. That crowd is still struggling to make auto_ptr work.

    1. Re:Use this link to read article on one page by shortscruffydave · · Score: 0

      There's really nothing new there. It's the usual Strostrup stuff. He's still in denial about C++ being the cause of most of the buffer overflows, system crashes, and security holes in the world.

      Programming lanuages don't cause bugs....programmers cause bugs

    2. Re:Use this link to read article on one page by PhrostyMcByte · · Score: 4, Informative

      The developer should know if he'll need the size of an array or not. Which is why there is a convenient std::vector and std::tr1::array for when you do want the size. Not forcing you to carry around a size is a feature, not a bug - if you don't need the size, it's just a waste of space.

      And auto_ptr is likely to be depreciated in C++0x, with unique_ptr and shared_ptr replacing it.

    3. Re:Use this link to read article on one page by Anonymous Coward · · Score: 0

      At the machine level, arrays [i]are[/i] just pointers. C++ makes the correct choice in representing them as such.

      Not to mention the fact that there are countless libraries that do the bounds-checking for you. Or (god forbid) write your own. It isn't hard, especially since C++ hands you the array pointer without modification.

      Don't beat down on C++ for making a design choice that favors the competent programmer just because you can't be bothered to do some safety checks yourself.

    4. Re:Use this link to read article on one page by Anonymous Coward · · Score: 0

      "The fundamental problem with C was the "array=pointer" concept. If array sizes were carried along with arrays, we'd have far less trouble."

      template<size_t size1, char size2>
        void sample_buffer_copy(char (&src)[size1],char (&dest)[size2]) {
            for (int i=0, max=std::min(size1,size2); i<max; ++i) {
                if (!(dest[i]=src[i])) return;
            }
            dest[std::min(size1,size2)-1]=0;
        }

      Do you mean like that? Or were you talking about the lack of std::vector?

    5. Re:Use this link to read article on one page by erikvcl · · Score: 2, Funny

      How is it Stoustrup's fault if people use the C features instead of the C++ ones? Your claim that Stroustrup is the "cause of most of the buffer overflows, system crashes, and security holes in the world." is absurd.

      You made this statement: "If array sizes were carried along with arrays, we'd have far less trouble". Array sizes ARE carried along with arrays. See the following code:

      #include
      #include

      int main(int argc, char **argv)
      {
                      const char str[] = "hello world";
                      const char *str1 = "hello world";

                      printf("array len: %d\n", sizeof(str));
                      printf("ptr len: %d\n", sizeof(str1));

                      return(0);
      }

      This code produces the following output:

      array len: 12
      ptr len: 4

      Arrays and pointers to character strings are not the same thing, though they are related and, in many circumstances, can be used interchangeably.

      It seems that you should learn more about C before you start criticizing C++. As others have stated, it's usually the mediocre programmers who complain about C++.

    6. Re:Use this link to read article on one page by Animats · · Score: 2, Insightful

      Array sizes ARE carried along with arrays.

      No, they're only available where the original declaration is visible. Try:

      void arraylength(int tab[])
      { printf("size of tab: %d\n",sizeof(tab)); }

      which won't work. "sizeof" is not meaningful in that context.

      Compare FORTRAN, which allows

      SUBROUTINE ARRAYLENGTH(TAB, N)
      INT TAB(N) ! conformant array declaration using param
      WRITE(*,*) SIZE(TAB) ! write size of array, as known by language

      This carries along the info needed for subscript checking. It also encourages users to request the size of an array from a known good source.

      The retrofit of conformant arrays into FORTRAN wasn't perfect, but it's ahead of C/C++. ISO Pascal, of course, also has conformant arrays, as do Modula 1/2/3, Ada, and Delphi.

    7. Re:Use this link to read article on one page by DeVilla · · Score: 1

      He's still in denial about C++ being the cause of most of the buffer overflows, system crashes, and security holes in the world.

      The fundamental problem with C was the "array=pointer" concept. If array sizes were carried along with arrays, we'd have far less trouble. Even FORTRAN has conformant array parameters. That should have been fixed in C++, but it wasn't, and as a result, we had two more decades of buffer overflow problems.

      OK, let me get this straight. C++, which is supposed to be as compatible with C as reasonable, remained compatible with a fundamental aspect of C that you obviously don't like and now all the problems that come from that C behavior is C++'s fault? You sounds like a manager talking to an engineer. Use a vector or blame C and it's APIs.
    8. Re:Use this link to read article on one page by Anonymous Coward · · Score: 0

      agree

    9. Re:Use this link to read article on one page by m50d · · Score: 1

      The developer should know if he'll need the size of an array or not. Which is why there is a convenient std::vector and std::tr1::array for when you do want the size.

      Yeah, because what, 15 characters of overhead for an array literal is really convenient. C++ supports just about everything, but there's only a finite amount of syntax, and they gave it to the poor alternatives, which means writing good code in C++ will destroy your fingers, and can never be very readable.

      And auto_ptr is likely to be depreciated in C++0x, with unique_ptr and shared_ptr replacing it.

      Great, even more to learn before I can, y'know, actually write programs.

      --
      I am trolling
    10. Re:Use this link to read article on one page by myrdos2 · · Score: 1

      I don't know about the other stuff, but you're dead wrong on Stroustrup's position on arrays. Here's what he has to say on the matter:

      What's wrong with arrays?

      In terms of time and space, an array is just about the optimal construct for accessing a sequence of objects in memory. It is, however, also a very low level data structure with a vast potential for misuse and errors and in essentially all cases there are better alternatives. By "better" I mean easier to write, easier to read, less error prone, and as fast.

      The two fundamental problems with arrays are that

      * an array doesn't know its own size
      * the name of an array converts to a pointer to its first element at the slightest provocation

      Naturally, a programmer usually get the size right, but it's extra work and ever so often someone makes the mistake. I prefer the simpler and cleaner version using the standard library vector.

      He goes on to make other arguments against using arrays, you can read them here.

    11. Re:Use this link to read article on one page by erikvcl · · Score: 1

      I understand your point.

      I would argue a few points:

      1. Generally, you shouldn't be using C-style arrays in C++ code. The exception to this is if you are interacting with a C library; in this case, you'll want to abstract this interaction code as much as possible.

      2. Since arrays don't carry inherent semantic meaning, passing into as pointer to one is rarely a good interface -- even in Fortran. A character string's length can be found with "strlen()", so we know the size there. A non-character array (e.g. an array of arbitrary, possibly binary, data), is often best incorporated into a data structure (along with other data values, possibly a length) which could be passed in as an argument. At the very least, an array pointer and a length can be passed in as an argument to a function.

      3. C is a low-level language. Fortran is a high-level language. It is not a fault of C that Fortran provides more facilities to the programmer than C does. Fortran was around before C and I'm sure that K&R designed C the way it is on purpose: I'm quite glad they did. That being said, I believe that C++ w/STL is a better solution than using C-style arrays in C++ code.

    12. Re:Use this link to read article on one page by Abcd1234 · · Score: 1

      Yeah, because what, 15 characters of overhead for an array literal is really convenient.

      Have you really never heard of the 'using' statement?

      I mean, I dislike C++ intensely, but this argument is just silly.

    13. Re:Use this link to read article on one page by shutdown+-p+now · · Score: 2, Informative

      C++ is also the only language that has hiding ("abstraction") without memory safety. C has neither; almost all later languages (Java, Delphi, all the scripting languages) have both. C++ stands alone in this unsafe place. Nobody ever repeated that mistake. So subtly incorrect calls to objects can result in the object overflowing.
      Delphi is no more memory-safe than C++ is. For that matter, Delphi actually requires you to call destructors for all objects explicitly, and woe be on you if you forget to, or, worse yet, accidentially call it twice. No smart pointers either: welcome to hell.

      By the way, what the hell is "object overflow"?

    14. Re:Use this link to read article on one page by shutdown+-p+now · · Score: 1

      No, they're only available where the original declaration is visible. Try:

      void arraylength(int tab[])
      { printf("size of tab: %d\n",sizeof(tab)); }
      which won't work. "sizeof" is not meaningful in that context.
      Actually, no, sizeof is meaningful in this concept, and is equivalent to sizeof(int*) - that's because "int tab[]" decays to "int* tab" in function signatures at the point of declaration. However, in C++, you can do thus:

      template <std::size_t N>
      void arraylength(int (&tab)[N])
      {
      printf("size of tab: %u\n", sizeof(tab));
      }
      And get the expected value (though in this case, you might just as well just use N without sizeof). Of course, using std::tr1::array is preferrable, anyway.
    15. Re:Use this link to read article on one page by benhattman · · Score: 1

      The developer should know if he'll need the size of an array or not. Which is why there is a convenient std::vector and std::tr1::array for when you do want the size. Not forcing you to carry around a size is a feature, not a bug - if you don't need the size, it's just a waste of space. Wrong, wrong, wrong. You always need the size of an array, even if you aren't going to use it explicitly. Why do you think there are two kinds of delete operations: delete and delete[]? It's because when delete is called on an array, it needs to know that there is a multiple of objects to delete. Under the covers, every C++ implementation stores the size of the array.

      So, you haven't saved any space! In fact, by not making that size accessible to developers, you are using up more memory! They now have to manually pass around size parameters.
    16. Re:Use this link to read article on one page by Eli+Gottlieb · · Score: 2, Informative

      I can see why you've been modded Funny. Null-termination is not, at all, even slightly, the same thing as an array carrying its size with it. Null entries can pop up anywhere for any reason, often bugs. It's much, much, much safer to just use the extra integer word and store the number of entries in the array.

    17. Re:Use this link to read article on one page by erikvcl · · Score: 1

      My example has nothing to do with NULL termination. If you look carefully, you see I'm using sizeof(). As Animats admitted, C DOES know about array sizes in the local scope.

    18. Re:Use this link to read article on one page by IdeaMan · · Score: 2, Interesting

      Programming lanuages don't cause bugs....programmers cause bugs Programming languages were written for humans, not other computers.

      Inferring from what you said that we never make mistakes and know all the features of the language intimately, why did he bother putting in type checking? That the Bjarne went to all the trouble of implementing type checking, then again for templates, and STILL has not addressed resource allocation is very frustrating to me. What? You'll define the type of an object but not its lifetime? Huh???

      --
      They ARE out to get you simply because They are in it for themselves and they don't care about you.
    19. Re:Use this link to read article on one page by frantzdb · · Score: 1

      Not forcing you to carry around a size is a feature, not a bug - if you don't need the size, it's just a waste of space.

      In C, the size of the array is there even if you can't get at it. On the stack, the compiler needs to know how big an array is to know where to put the next variable; on the heap, the runtime needs to know how big the buffer was returned from malloc so it knows how to delete it. You just don't have access to that number.

    20. Re:Use this link to read article on one page by m50d · · Score: 1

      Have you really never heard of the 'using' statement?


      I mean, I dislike C++ intensely, but this argument is just silly.


      Even with using, it's still array([blarg]). On it's own, it's not so bad, but then to get sensible strings I have to do string("message"), tuples have to be tuple(x,y,z), sensible pointers have to be smart_ptr(x), and don't get me started on how much I have to write to get anything done with templates. And this adds up to a language that's unpleasant to write and difficult to read.

      --
      I am trolling
    21. Re:Use this link to read article on one page by ozone_sniffer · · Score: 1
      I read up to when you demonstrate you know not what you're talking about.

      The fundamental problem with C was the "array=pointer" concept You can't do pointer arithmetics on arrays, C or C++. Please shut up.

      If array sizes were carried along with arrays, we'd have far less trouble. Even FORTRAN has conformant array parameters. That should have been fixed in C++ Ever heard of STL containers? Vector? List? Tried reading TFA? They're mentioned there. Please shut up. You don't know C++, the STL, and are commenting on things you don't understand. While up to know I've read many sensible critics on the language in this thread, unfortunately, the majority of C++ detractors just don't understand the language and are frustrated by the fact, it seems. I'm not saying that C++ is the ultimate tool. But it is a very good and powerful one, as are C#, Java, and many others, for that matter, with their strengths and weaknesses. It just seems it is the one that is the least understood.
  29. Tell it like it is by gbjbaanb · · Score: 1

    but the intent was (and is) that a competent programmer should be able to express just about any idea directly and have it executed with minimal overheads (zero overheads compared to a C version). Possibly the most important part of the article. non-competent programmers, go find a language more suited to your skills, preferably one with an IDE that does it all for you.

    Convincing the systems programming community of the value of type checking was surprisingly hard. The idea of checking function arguments against a function declaration was fiercely resisted by many - at least until C adopted the idea from C with Classes And today, we have script languages like this. Just shows things never change, they just go quiet before returning to fashion. (unlike bell-bottom flares which really should never return)(ask your dad)
    1. Re:Tell it like it is by EvanED · · Score: 1

      And today, we have script languages like this. Just shows things never change, they just go quiet before returning to fashion.
      To be fair, the non-type-checking of old C compilers (or new C compilers if you do something wrong and don't follow good conventions) is an entirely different animal than the non-type-checking of today's Python or Perl.

      In the former, the function you're calling expects certain types in particular register and/or memory locations, and runs as if they are there. If it's wrong, and the caller didn't set up the stack right, you'll have fun times debugging what the hell is going on.

      In the latter, the function you're calling expects certain types in particular register and/or memory locations, and verifies at runtime that they are there. If the wrong type or wrong number of arguments is provided, a predictable result will occur.

      There's a big difference between untyped (which is what C is at the linker, and what K&R C is at the compiler) and dynamically-typed (which is what the scripting languages you refer to are).

  30. Re: And... by Tragek · · Score: 1

    The FQA. One of my favourite extended rants. I cant speak as to how accurate it is (never really have done much in C++), but there are many eye openers in there. (C++ grammar is undecideable-what?)

  31. Love C++, but it still sucks... by UnknownSoldier · · Score: 4, Informative

    * No standardized pragmas
    * Macros after-thought and not type safe
    * No 24, and 32 bit (unicode) chars
    * Still has float / double crap, instead of being properly deprecated and f32, f64, f80 used instead
    * Still has short / long crap, instead of being properly deprecated, and i8, i16, i32, i64, i128, u8, etc...
    * No distinction between typedefs and aliases
    * Inconsistent left-to-right declarations
    * Compilers still limited to ASCII source
    * No binary constant prefix (even octal has one?!)
    * No standard way to assign NaN, +Inf, -Inf to floating point constants at compile time

    1. Re:Love C++, but it still sucks... by PhrostyMcByte · · Score: 4, Informative

      * Pragmas are made specifically for non-standard compiler extensions. There can be no "standard" pragmas.
      * C++0x is adding support for UTF-8, UTF-16, and UTF-32 character types and literals.
      * TR1 adds cstdint which includes int32_t etc. types.
      * NaN and +Inf (not -Inf, though) can be had from std::numeric_limits

      alas, if those are the first complaints you think of, you haven't been using C++ long enough to really know the painful bits.

    2. Re:Love C++, but it still sucks... by Eponymous+Bastard · · Score: 5, Informative

      Most of your complaints seem aimed at C and not C++. Let's see:

      * No standardized pragmas

      You want standardized *compiler extensions*?

      They standardized the extension mechanism. That sounds good for a start, but I don't see how you could go farther.

      * Macros after-thought and not type safe C compatibility, basically deprecated now as they also affect everything, including members, variables, anything that gets #included, etc.

      * No 24, and 32 bit (unicode) chars wchar exists, toghether with I/O stuff, though I'm not sure about the encoding type. You can even declare streams and strings for any character type you build.

      * Still has float / double crap, instead of being properly deprecated and f32, f64, f80 used instead
      * Still has short / long crap, instead of being properly deprecated, and i8, i16, i32, i64, i128, u8, etc... C compatibility. I believe they are inheriting the new types from C99 too.
      Also, short/int/long give you the sizes optimized for the specific processor, so you can use that if that's what you want. You can't really deprecate them because of that

      * No distinction between typedefs and aliases What on earth is an alias? Are you talking about C's struct namespace? (one of the few things that C++ doesn't inherit)

      * Inconsistent left-to-right declarations Inconsistent in what sense?

      * Compilers still limited to ASCII source C++ has included trigraphs for over ten years now, which allow an editor to insert any unicode character and still store everything in ASCII for compatibility. Compilers don't even need to support unicode for things to just work. The editor just has to interpret the trigraphs and paint them on screen as the appropriate character.

      I've never used them though.

      * No binary constant prefix (even octal has one?!) I've never met anyone who actually worked in binary. Hex is close enough and less error-prone. Octal probably got included for a) C compatibility and b) People did use to work in octal (see file access permissions)

      * No standard way to assign NaN, +Inf, -Inf to floating point constants at compile time Would you like a quite or signaling NaN?

      For double:
      #include <limits>

      const double inf = std::numeric_limits<double>::infinity ();
      const double minf = -std::numeric_limits<double>::infinity ();
      const double nan = -std::numeric_limits<double>::signaling_NaN();

      See more here for example.

      There are has_infinity() and related functions to check for a type's capabilities (say, in a template)

    3. Re:Love C++, but it still sucks... by Bazer · · Score: 2, Informative

      * No standardized pragmas

      Pragmas were meant to be OS and compiler specific. If your OS or compiler doesn't provide a standard then it's the language is not at fault.

      * Macros after-thought and not type safe

      Macros weren't meant to be type safe. You should use templates if you need type safety.

      * No 24, and 32 bit (unicode) chars

      What about std::wstring and cwchar?

      * Still has float / double crap, instead of being properly deprecated and f32, f64, f80 used instead * Still has short / long crap, instead of being properly deprecated, and i8, i16, i32, i64, i128, u8, etc...

      Use cstdint and cfloat

      * No distinction between typedefs and aliases * Inconsistent left-to-right declarations

      I don't have much experience with those in C++ so maybe someone else should elaborate. Could you provide examples where these two would be a problem?

      * Compilers still limited to ASCII source

      This is true but hard-coding unicode strings is considered a no-no.

      * No binary constant prefix (even octal has one?!)

      This is true.

      * No standard way to assign NaN, +Inf, -Inf to floating point constants at compile time

      Standard since C99.
    4. Re:Love C++, but it still sucks... by pclminion · · Score: 1

      * No standardized pragmas

      Part of the definition of pragma is "compiler-specific."

      * Macros after-thought and not type safe

      Macros are obviated by inline functions.

      * No 24, and 32 bit (unicode) chars

      Why should some specific UTF encoding be built into a language? Unicode is a character set, not an encoding. Why limit yourself?

      * Still has float / double crap, instead of being properly deprecated and f32, f64, f80 used instead

      And on a machine with a 71 bit float, what the hell are we supposed to use?

      * Still has short / long crap, instead of being properly deprecated, and i8, i16, i32, i64, i128, u8, etc...

      What about 9 bit words?

      * No distinction between typedefs and aliases

      What the hell do you need that for?

      * Inconsistent left-to-right declarations

      Historical, due to backward compatibility with C. Deal with it.

      * Compilers still limited to ASCII source

      Legitimate gripe.

      * No binary constant prefix (even octal has one?!)

      We're COMPUTER PROGRAMMERS. We understand HEXADECIMAL. Binary is pointlessly verbose. Learn the basics.

      * No standard way to assign NaN, +Inf, -Inf to floating point constants at compile time

      Legitimate gripe.

    5. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      Really? Ada has dozens of "standard" pragmas.

      --


      Anonymous Cowards suck.
    6. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      He said "at compile time". These are not compile-time constants.

      --


      Anonymous Cowards suck.
    7. Re:Love C++, but it still sucks... by Srin+Tuar · · Score: 1


      >* No standardized pragmas

      Jumbo Shrimp?

      >* Macros after-thought and not type safe

      Preprocessor macros are largely deprecated by C++, except where they make sense.

      >* No 24, and 32 bit (unicode) chars

      Have you missed the last 8 years of i18n progress ? Putting unicode datatypes into primitive is a failed model.
      Wake up and smell the utf-8.

      >* Compilers still limited to ASCII source

      Ever use gcc ?

      >* Inconsistent left-to-right declarations
      Whats inconistent about them?

      >* No binary constant prefix (even octal has one?!)

      Learn hex already

    8. Re:Love C++, but it still sucks... by Anonymous Coward · · Score: 0

      We are all eager on criticizing C++ and with reason. But really, now: what language would you choose for systems programming (OS, compilers etc.) other than C/C++?

    9. Re:Love C++, but it still sucks... by serviscope_minor · · Score: 1

      Unfortunately, you misunderstand quite what is involved in portability. You also are unaware of some features of C++. I suspect you have never done any embedded work. If so, then the assumtions you make about int and float sizes all go out of the window. Also, f80 is pretty x87 specific and even intel is putting more effort in to SSE than x87. As for intNN, there is the cstdint header for processors that support it, but it won't work on many DSPs, since they do not allow octet access. inf and nan are dealt with in std::numeric_limits and are available if the floating point implementation supports them properly. Bear in mind that there are many platforms which aren't fully IEEE compliant: if you use -ffast-math on gcc, IEEE compliance is broken, regardless of whether the underlying implementation is IEEE compliant.

      Also, macros were inhereted from C and still have a small amount of use, but are best avoided.

      Other than that, unicode source and binary constants would be nice (though you can make something like that with templates).

      --
      SJW n. One who posts facts.
    10. Re:Love C++, but it still sucks... by Anonymous Coward · · Score: 0

      * No standardized pragmas

      That's by design. The point of pragma's is to allow vendor-specific behaviour to be defined without clashing with the programming language. Standardized features are implemented as language constructs, not pragma's.

      * Macros after-thought and not type safe

      Macros aren't meant to be type-safe. Use (inline) (template) functions for that. If you're designing your C++ program around unsafe macros you're doing it wrong.

      * No 24, and 32 bit (unicode) chars

      Wide characters are supported, though it's not specified how large these are. This is a deliberate design decision though (see below).

      * Still has float / double crap, instead of being properly deprecated and f32, f64, f80 used instead

      What does the name matter? If you want to, you can typedef them the way you like them on your platform.

      * Still has short / long crap, instead of being properly deprecated, and i8, i16, i32, i64, i128, u8, etc...

      This falls in the same category as above. It was a deliberate design decision to allow implementors some freedom to choose the sizes of types so that they can select a size that makes the most sense on a particular platform. You call it crap, others think it's a useful feature. If you insist on working with fixed-size types, you can include <cstdint> which includes stuff like uint32_t (and a whole lot of others).

      * No distinction between typedefs and aliases

      Not sure what you mean by that.

      * Inconsistent left-to-right declarations

      Not sure what you mean by that.

      * Compilers still limited to ASCII source

      Not true. I can't even remember working with an ASCII-only compiler.

      * No binary constant prefix (even octal has one?!)

      Granted; that's occassionally annoying.

      * No standard way to assign NaN, +Inf, -Inf to floating point constants at compile time

      There is, look at numeric_limits defined in <limits>.
    11. Re:Love C++, but it still sucks... by blueforce · · Score: 3, Funny

      ... +Inf, -Inf...

      Everything has its limits, you know.

      --
      If you do what you always did, you get what you always got.
    12. Re:Love C++, but it still sucks... by Eponymous+Bastard · · Score: 1

      Yes they are. Try it.

      const in C++ does mean constant. Especially if you declare them globally.

      Also, inlining in C++ templates will end up generating the exact same assembly as if you were to use some macro. Run this through g++ with -O3 and check the ASM.

      That's one of the reasons why the STL is actually efficient.

    13. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      I know what const mean in C++. I've been developing C++ professionally for about 15 years. What does "try it" mean? Just be cause it is valid construct doesn't mean it is done at compile-time. These are not defined at compile-time. They are initialized during static construction. It won't be until the next release of the standard until C++ is allowed to create compile-time constants (i.e., an ICE) from a simple, inlined functions.

      --


      Anonymous Cowards suck.
    14. Re:Love C++, but it still sucks... by Eponymous+Bastard · · Score: 1

      True, sorry. I realized the difference after I hit submit. Most of the stuff in numeric_limits is a constant, except for a few of these floating point numbers.

      I'm curious, what are you doing that requires a floating-point compile-time constant? Most of the things I can think of that you'd need one are things like defining an array size, which is obviously not something you'd need a NaN or any other floating point value for. There are compile-time constants for whether a NaN exist, so you can use that fact for the definition of an array in a template, for example.

      Getting the actual value for a comparison or assignment works just as well with the inlined numeric_limits functions.

    15. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      As an example of what I mean, compile the following program with gcc -pedantic. GCC *may* optimize the code, so the value is known at compile-time, but it is not a compile-time constant by C++ rules. It will be rejected with "error: ISO C++ forbids variable-size array `a'". It will compile without the "-pedantic" option as a GCC extension. You cannot rely on all compilers to do this.


      inline int size() {return 5;}

      int main()
      {
      const int x = size();
      int a[x];
      }

      --


      Anonymous Cowards suck.
    16. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      Never said I did. I was just pointing out the example didn't disprove what the OP said. By the way, a lot of the values in limits are not constant, specifically min and max--even for integers. You have to use climits and use the macros if you want compile-time constants.

      --


      Anonymous Cowards suck.
    17. Re:Love C++, but it still sucks... by shutdown+-p+now · · Score: 1

      What about std::wstring and cwchar?
      Not guaranteed to be of any particular size (a conforming implementation can a 8-bit wchar_t; in practice, it varies between 16 bits on Windows, and 32 bits elsewhere), nor of a particular encoding (the BSDs use non-Unicode wchar_t for certain multibyte locales, for example; on the other hand, GNU libc guarantees that wchar_t is always UTF-32 no matter the locale).

      Use cstdint
      cstdint is only part of TR1, not the base ISO C++ standard.

      * No distinction between typedefs and aliases
      * Inconsistent left-to-right declarations
      Could you provide examples where these two would be a problem?
      The first one you want when you want to overload functions for your typedef, and require explicit conversions to/from it (i.e., when you want it to behave as a new type).

      Standard since C99.
      ISO C++ does not yet include C99 features, not until C++0x.
    18. Re:Love C++, but it still sucks... by Anonymous Coward · · Score: 0

      Ada != C++

      More specifically: I don't know Ada, but based on what you said, I'd assume that pragmas in Ada aren't the same as pragmas in C and C++. In C and C++, pragmas are specifically intended as a hook for non-standard features.

    19. Re:Love C++, but it still sucks... by tbp · · Score: 1

      I'm curious, what are you doing that requires a floating-point compile-time constant?

      To use them as non-type template parameters? Which is, of course, a wider problem. Fear not, for there is *cough* http://ompf.org/stuff/metafloat/ *cough*
    20. Re:Love C++, but it still sucks... by Anonymous Coward · · Score: 0

      So you want to make infinite arrays on the stack?

    21. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      Except, it is not legal to use floating points as template parameters.

      --


      Anonymous Cowards suck.
    22. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      What is your point? Your comment doesn't make any sense. Either way, I was not expressing a desire. I was pointing out that x, in my example, is not an ICE (integral constant expression).

      --


      Anonymous Cowards suck.
    23. Re:Love C++, but it still sucks... by tbp · · Score: 1

      Except, it is legal to operate on non-type template parameters which, incidentally, may contain floating points (and that's exactly what metafloat does).

    24. Re:Love C++, but it still sucks... by Eponymous+Bastard · · Score: 1

      I have to say: ewwww

    25. Re:Love C++, but it still sucks... by drxenos · · Score: 1

      I am not sure what you mean.

      --


      Anonymous Cowards suck.
  32. Same Story different interviewer by UseCase · · Score: 1

    There is always, introduced with much fanfare, a new interview with Stroustrup where he says the same thing he said in the previous 15 interviews. As a professional developer I enjoy reading these types of things but I get frustrated at the same questions being asked over and over again. The was a very good read but fell into the normal Stroustrup interview cadence.

    I did like the "sugar daddy" comment!!!
  33. Cfront by metamatic · · Score: 2, Insightful

    And in fact, Cfront was a compiler, not just a preprocessor; it was just a compiler that compiled C++ into C.

    --
    GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    1. Re:Cfront by toriver · · Score: 1

      isn't that a bit like saying cpp is a compiler too since it compiles "C with macros" into "C with expanded macros"? ;)

      C is probably close enough to low-level code to count as intermediate code for two-step compilation though.

  34. Managed code on handhelds? by tepples · · Score: 1

    Problem: unmanaged code is (deservedly) dying out. Our shop now mandates only managed code.

    How well has your shop been able to port managed code to handheld devices? Sure, there's J2ME on cell phones, but more often, the buzzword "managed code" appears to refer specifically to Microsoft's .NET Framework (and compatible environments such as Mono).

    1. Re:Managed code on handhelds? by Mongoose+Disciple · · Score: 1

      How well has your shop been able to port managed code to handheld devices?

      There's the .NET compact framework specifically for that.

      I personally haven't done anything with it, but the handhold folks I know are pretty happy with it, and a couple of those guys are rabidly anti-Microsoft in the general case, so I assume it must be decent.

  35. UTF-8 in literal strings by tepples · · Score: 1

    Compilers still limited to ASCII source But might UTF-8 be a widely implemented extension? My copy of g++ will accept UTF-8 in literal strings as long as I use an editor that can write UTF-8 without a byte order mark (i.e. not Windows Notepad).
    1. Re:UTF-8 in literal strings by petermgreen · · Score: 1

      At least in my experiance most compilers don't care about encoding beyond expecting the ASCII characters to be in the right place. That is with the exception of quoting characters the bytes from your string constant will just be copied verbatim to your binary.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  36. Sand-bagger by blueforce · · Score: 3, Funny

    Bjarne Stroustrup Reveals All On C++

    You mean... He's been holding back?

    --
    If you do what you always did, you get what you always got.
  37. The FQA is "equally" partisan? by Anonymous+Brave+Guy · · Score: 5, Insightful

    I'm afraid that web site is one of those things that gets way too much attention in some on-line communities because of its controversial nature.

    The reason the two sides are far from equally partisan is that Stroustrup freely admits there is another side to the debate and that C++ has its flaws, and he is making efforts to improve the situation. The FQA, on the other hand, just makes blanket statements like "For example, the lack of garbage collection makes C++ exceptions and operator overloading inherently defective", which simply isn't true (and neither are many of the statements made in the FQA under those particular headings).

    If you read the comments the guy who wrote the FQA makes on forums like reddit, as well as throughout the FQA itself, it's pretty obvious that unlike Stroustrup, he has little interest in any balanced discussion on the subject. He's just out to prove the other side wrong — where "wrong" often means "not agreeing with him" — and perhaps, the cynic in me suspects, to make a reputation for himself in the process.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:The FQA is "equally" partisan? by Anonymous Coward · · Score: 0

      Having read some of the other things he's written, I suspect it's more of a case of taking his anger out in odd ways. It's sort of like writing a long, detailed, scathing review of a movie you were forced to watch.

  38. Can this possibly be by WorthlessProgrammer · · Score: 1

    the (in)famous s l a s h d o t ?

    No LANGUAGE WARS ?? So far an astoundingly decent discussion.

    At least for me, Stroustrup's most interesting statement of the interview was

    "My view of GC differs from that of many in that I see it as a last resort of resource management, not the first, and that I see it as one tool among many for system design rather than a fundamental tool for simplifying programming."

    Exactly, and dead on. Ignoring the potential (and pointless) language wars, I just do not understand the Java focus on their GC weirdness, and am fascinated by Ruby's ability to turn GC on and off. Probably too late for Python to do this...

    While I do not have fond memories of C++ from my school daze, I have more 'respect' for C++ than Java. To paraphrase Archimedes, give me ANSI C and Python and I can simulate the world.

  39. Re:managed code by Anonymous Coward · · Score: 0

    There ARE managed versions of C++ available. However, they do have a few disadvantages relative to languages designed to be managed by default, instead of having this bolted on. As managed code becomes the prevailing paradigm, it is expected that this will create a disadvantage for C++ relative to other languages. However, there is a lot of inertia in language use - there are still people making a living doing Cobol programming, and similarly C++ will still be in use in 20 years, although it will continue to fade in importance over that time.

    Producing managed code is *already* a much larger industry than unmanaged. Java & C# together dwarf C and C++ together. Imagining this trend will not continue is just wishful thinking. Unmanaged code is becoming a niche.

  40. Want to know more? Read the book by idiot900 · · Score: 3, Insightful

    "The Design and Evolution of C++" by Stroustrup is a must-read if you are interested in why C++ is the way it is.

    After reading it, I really hated C++. It's the classic example of a project that gets ruined by too many people working on it, all with their own goals, and the book tells you exactly why this happened. C++ now is a hideously complex monstrosity that is popular because it is all things to all people, not because it is a good language.

    Anyway, if you disagree with me, have a look at the book. It is a testament to Stroustrup's objectivity that I came to the conclusion I did, and that you may come to the exact opposite conclusion as me after reading it.

    1. Re:Want to know more? Read the book by V!NCENT · · Score: 1

      It's better than C IMO because you have the power of low level programming and high level programming combined and at the same time it's also really useful and way more productive with large scale projects. In other words; C++ gives you the power to do it all, instead of having to learn and combine a high level programming language with a low level programming language. If that wasn't great enough, it also almost doesn't need a runtime environment, except for a few functions so it's also uber fast.

      --
      Here be signatures
    2. Re:Want to know more? Read the book by Abcd1234 · · Score: 1

      Bah, that's the same attitude the cell phone companies have: just mash all the features of a phone, organizer, music player, etc, into one crappy interface. Problem is, just like C++, the result is a tool that's only mediocre at doing any one of those things, rather than a bunch of tools that are perfectly designed for the job at hand.

      Personally, I would *much* prefer to write an application in a high-level language that has a top-notch FFI, and write the high-performance stuff in C. Why? Because, like most people, I spend the vast majority of my time *not* writing performance-critical code, and in that case, I want a language that's easy to use, has a strong toolset, and is designed to make my job easier while preventing me from screwing up. Meanwhile, if I hit a point where I really do need to squeeze that last ounce of performance out of a piece of code, I have the option to switch to a lower-level language that's tailored for that job.

    3. Re:Want to know more? Read the book by V!NCENT · · Score: 1

      Yes C++ should not be use for everything. But take KDE4 for example. It requires both low- and high level programming. So it's for the better that they use C++. But if you have a project either focusing on just low level or just high level then it is better if you use a language strictly designed for that sort of thing and not C++ just because it is possible. That is what Stroustrup also says in his C++ book.

      --
      Here be signatures
    4. Re:Want to know more? Read the book by Abcd1234 · · Score: 1

      Yeah, but libraries are a whole other ballgame entirely. If you want a library, like KDE4, accessible from multiple languages, traditionally you needed a lowest-common-denominator language. KDE/Qt chose C++. Gtk chose C. Were it not for that requirement, there is absolutely no reason not to use a higher-level language, as the vast bulk of the work done by KDE and Qt is not performance critical. The only exceptions are graphics and audio processing, but it's trivial to write those bits in a faster, lower-level language (which is how, say, Squeak manages something as impressive as Croquet).

      As such, I would contend that the *vast* majority of the time, you really *don't* want a single language that can "do it all" (after all, how often do you build a cross-platform library that must be available from multiple languages?). As such, C++ is almost always the wrong solution to a given problem, especially given just how many issues there are with the language itself.

    5. Re:Want to know more? Read the book by V!NCENT · · Score: 1

      The only exceptions are graphics and audio processing, but it's trivial to write those bits in a faster, lower-level language (which is how, say, Squeak manages something as impressive as Croquet) C++ is just as fast as C when you are using the language for low level programming. You can import an entire C program into C++ without any changes. However if you use C++ for high level programming and you use certain high level functions then you may need a runtime environment for those functions.

      As such, I would contend that the *vast* majority of the time, you really *don't* want a single language that can "do it all" (after all, how often do you build a cross-platform library that must be available from multiple languages?). I am not sure what you mean by "how often". Do you mean most of the time or almost never? Well, KDE4 components are accessible with scripts (javascript, phonon, etc.). Anyway, with the KDE developtment kit you can embed a media player with just 5 lines of code (as shown in their Google KDE4 release event keynote speach (http://www.youtube.com/watch?v=UneGtZlehTU)
      --
      Here be signatures
  41. Re:Bjarne does.....what? by Stew+Gots · · Score: 1

    You forgot COBOL.

    You forgot Forth, a write-only language if there ever was one.

  42. Re:managed code by gbjbaanb · · Score: 3, Interesting

    I think any language that doesn't support managed code is going to die out over the next 10 years You'll still be a Windows-only shop then? In ten years Microsoft may have changed its mind again about a programming platform. they seem to do so every ten years or so. Hell, in 10 years Microsoft might not even exist.

    And I suppose your shop used to say "COM only", and now says "ugh, COM, who'd want to code those things up". You seem to have swallowed the Microsoft marketing man's sales spiel wholesale.

    When you find out how slow some parts of .NET is (eg DB access), or how much memory it uses when you don't want it to, or how to find the object you expected to be GCd but hasn't been.. then you'll think about writing a chunk of your code in old C++.

    MS did do a lot of work (pretty poor IMHO though) with C++/CLI to get some interop going between C++ and C#/VB. Poor because of the somewhat contrived bodges to the language they put in that they could have hidden behind the compiler, and also because there isn't any real interop with old unmanaged C++ except by wrapping it with a managed dll (or recompiling with the /clr flag set). Its also a poor implementation - eg STL/CLR is a lot slower than the .NET containers surprisingly.

  43. and worst of all... by mkcmkc · · Score: 3, Interesting

    25 years later there's still not a !@#^%^&$ single compiler that implements the entire language correctly. We're all waiting for Godot...

    --
    "Not an actor, but he plays one on TV."
  44. What is it? by rbanffy · · Score: 1

    So... Is it a prank after all?

  45. It sure did by VeNoM0619 · · Score: 1

    C++ inherited the weaknesses and the strengths of C++, It sure did! In fact, I'm 100% sure that my truth is fact.
    --
    Disclaimer: I am not god.
    We may not be created equal
    But we can be treated equal.
    1. Re:It sure did by nuzak · · Score: 1

      > C++ inherited the weaknesses and the strengths of C++

      Huh. Must have been using the Curiously Recurring Template Pattern.

      --
      Done with slashdot, done with nerds, getting a life.
  46. Re:managed code by Anonymous Coward · · Score: 0

    Yes we are a windows only shop (oh noes, we've limited ourselves to 93% of the market!), but managed code can be created on non windows systems. We don't do that here, but it works fine.

    You might argue any *particular* managed language won't be here in the future, but managed code will be the norm in a decade in *some* form. In fact, it's probably the norm right now.

  47. Like RTL? by tepples · · Score: 1

    Early C++ "compilers" usually did more than just macro processing, but only just; most of them were implemented in terms of translating C++ to equivalent C code and then compiling the resulting C. How is that any different from translating Flex/Bison to equivalent C code and then compiling that? Heck, how is it different from translating C or C++ to equivalent RTL code and then compiling that?
  48. Re:managed code by Anonymous Coward · · Score: 0

    Sure but this so called "managed code" is for user space apps where performance is not critical. Even Microsoft recommend that performance critical code is unmanaged (ie: native). What you're saying is disingenuous; by the same metric I could say that PHP and javascript are set to replace all other programming languages. And IMHO, scripting languages will wipe the floor with Java and C# well before native code becomes a niche. The underlying C ABI isn't going anywhere in the next decade, no matter what second-tier "managed coders" think.

  49. Something different from Bjarne... by pdxp · · Score: 0, Redundant
    It's interesting to read what he said about C++ 10 years ago:

    "It was only supposed to be a joke, I never thought people would take [the book] seriously. Anyone with half a brain can see that object-oriented programming is counter-intuitive, illogical and inefficient." http://www.ariel.com.au/jokes/An_Interview_with_Bjarne_Stroustrup.html

    (Do yourself a favor and read the note at the bottom of the page)
  50. Re:managed code by tepples · · Score: 1

    Even Microsoft recommend that performance critical code is unmanaged (ie: native). Then why does Microsoft XNA Game Studio, which is designed for developing performance-critical video games, use managed code?
  51. Re:managed code by Anonymous Coward · · Score: 0

    Exactly.

    The performance issues are for the most part untrue - for 98% of all purposes, even games and other performance sensitive things, managed code can be as fast as unmanaged. By FAR the bigger factor is programmer skill, not whether the target is managed or unmanaged code. That's why unmanaged code is becoming a niche. There may always be a tiny sliver where it continues to be useful, but that is going to become a very small area over time. Again comparisons to Cobol come up: there are still Cobol jobs out there, but it's a very small area.

  52. Re:managed code by bovinewasteproduct · · Score: 1

    MS did do a lot of work (pretty poor IMHO though) with C++/CLI to get some interop going between C++ and C#/VB.

    I think Herb Sutter did a pretty good job of explaining why they designed C++/CLI the way they did in this article on his website http://www.gotw.ca/publications/C++CLIRationale.pdf.

    Except for some problems with boxing/unboxing(as in being a pain in the ass), I've not really ran into any problems using C++/CLI as a langauge on any of my projects. And unless your using the /clr:safe flag, linking with "OLD" C++ should not be problem, every thing else being equal.

    And yes, while .NET can be slow, inconsistent and otherwise a piece of s**t, for somethings it's all there is, atleast without rewriting/creating alot of code.

    BWP

  53. Oh come on... by Anonymous Coward · · Score: 0

    The performance critical parts (DirectX) are native code with managed bindings. Not that you can't use JIT techniques to great effect in a rendering pipeline but the heavy lifting has to be done without memory management. Many games use scripting languages for the game logic, it's simply not a performance bottleneck.

    But you already know all this ;)

  54. It was never a preprocessor by Joce640k · · Score: 2, Interesting

    If you're thinking along the lines of a bunch of #defines making C into proto-C++ then you're completely wrong.

    The early compilers produced C as a sort of "assembly language" so that it could be used on many different targets (C was widely available).

    But it you looked at the C it produced you'd have a hard time relating it to the original C++ source code.

    --
    No sig today...
    1. Re:It was never a preprocessor by afidel · · Score: 1

      This makes sense. I was quite young when I started with C++ (middle school?) and so wouldn't have fully understood the difference between the pre-processor step and proper compilation to C. I just remember having to feed the output of the C++ compiler into the C compiler kind of like manually feeding things to the linker. Having since worked with another compiler (one of the Eiffel compilers) that targeted portable C and compilers that target the JVM I understand the design decision =)

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
  55. A few actual examples might give credibility by Joce640k · · Score: 1

    Without examples your statement is completely vacuous.

    --
    No sig today...
  56. Operator overloading... by Joce640k · · Score: 1

    Try writing some numerical code and see if operator overloading is useful.

    --
    No sig today...
    1. Re:Operator overloading... by hey! · · Score: 1

      But it is not generally useful. It is a feature of the language everyone has to deal with for a tiny minority of users.

      It would make more sense to maintain a fork of the language for numerical applications.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    2. Re:Operator overloading... by speedtux · · Score: 1

      It would make more sense to maintain a fork of the language for numerical applications.

      We do. It's called "C++". It's just that foolish people keep trying to use it for writing GUIs and other silly things.

    3. Re:Operator overloading... by Javagator · · Score: 3, Interesting
      It is a feature of the language everyone has to deal with for a tiny minority of users.


      The people using C++ for engineering, mathematical, and scientific applications may be a minority, but not a tiny minority. No one has to deal with operator overloading if it is not applicable to their application. If a developer is too immature to recognize when a feature is a bad choice, then operator overloading is the least of his problems.

    4. Re:Operator overloading... by hey! · · Score: 1

      A developer doesn't have a choice about whether a feature is used if he is doing maintenance.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
  57. Accurate? Not at all... by Joce640k · · Score: 1

    Might have been a valid rant in about 1992 or so, but that's a long time ago.

    C++ programmers will laugh at you for posting it, non-C++ people will be confused, so why bother?

    --
    No sig today...
    1. Re:Accurate? Not at all... by Rumble · · Score: 1

      I can't find a fqa from that site that has been rectified since 1992. I would wager that most of the criticisms on the FQA are still valid on every c++ implementation as of today. (heck, let's even say by next year)

      You don't know what you are talking about. There are very detailed paragraph by paragraph explanations on nearly every fqa. Serious flaws and problems, not just 'i don't like the way that works'. Architectural flaws that if you knew one language other than C++, would be obvious to you.

      C++ is garbage, I write it every day. It's difficult to write, syntax is impossible to remember, silent errors, millions of gotcha's. there is nothing C++ does that some other language doesn't do better. It was a cheap hack to get classes in C++, and technologically relevant 30 years ago, why are people still praising it?

      c++ is a rusty old bus, do you actually think it's a sports car?

    2. Re:Accurate? Not at all... by Tragek · · Score: 1

      I was about to mention that it seems rather well maintained; And Yosefk seems pretty amenable to changes, or at least defending his points.
       

  58. "Hey, I don't program for a living." by Joce640k · · Score: 1

    >"there are a lot of C++ features I don't really
    > understand."

    That doesn't stop you spouting off on message boards though, does it?

    Leave C++ opinions to people who understand it and use it every day.

    >"It's all the damned constructors and destructors that get me. I want one way to make a new FOOMINATOR, one way to kill a FOOMINATOR, and maybe one way to copy a FOOMINATOR.""

    Um, there*is* only one way for each (well, ok, you can overload the constructor but I fail to see how that's confusing).

    Plus, if you learn what a smart pointer is then you can mostly forget about writing copiers and destructors - let the compiler do it for you.

    --
    No sig today...
    1. Re:"Hey, I don't program for a living." by TerranFury · · Score: 1

      That doesn't stop you spouting off on message boards though, does it? [...] Leave C++ opinions to people who understand it and use it every day.

      Don't be a jerk. I was not saying "C++ sucks." I was saying that it has some features that I find confusing.

      Other Slashdot users are no doubt in the same boat, but they couch their arguments in more authoritative language. They may even be experts. Regardless, it sounds an awful lot like they're saying the same thing. For just one example, here's a quote from a post that was modded "+4, Interesting:"

      C++ is also the only language that has hiding ("abstraction") without memory safety. C has neither; almost all later languages (Java, Delphi, all the scripting languages) have both. C++ stands alone in this unsafe place. Nobody ever repeated that mistake. So subtly incorrect calls to objects can result in the object overflowing.

      This speaks about, in more general terms, the same issues I was addressing in my post. My post differs in that (1) it was more specific about the language features that lead programmers to hide memory leaks inside abstractions, and (2) I admitted that I am not an expert. Both aspects make my post easier to attack, but they are really just matters of presentation.

      As for point #2 above: I want to stress that jumping on people for admitting ignorance on Slashdot will reduce the honesty that you'll see on these boards. It creates more incentive for people to speak in authoritative language without in fact being experts -- and that, unlike the posts of admitted non-experts, really is a problem.

      At any rate: Though not an expert in C+++, I am a reasonably competent programmer and a decent when it comes to algorithms, so I don't think my comments were entirely pointless. I think it's worth mentioning which features of C++ cause confusion and act as barriers to entry.

      I was also looking for a few practical suggestions, since I made it very clear that I still have things to learn. Obviously I'm not investing a great deal of time into training myself in C++, but if somebody had a few tips that they could give and I could receive without much effort (on either's part), then I was clearly welcoming them. Hence, I appreciate these parts of your post:

      Um, there*is* only one way for each (well, ok, you can overload the constructor but I fail to see how that's confusing).

      (Translation: Take a second look at the operators, and maybe they'll make sense.)

      and

      Plus, if you learn what a smart pointer is then you can mostly forget about writing copiers and destructors - let the compiler do it for you.

      These both sound like good suggestions.

      So: Don't be obnoxious, but thanks for the tips.

  59. So, um, don't use arrays .... problem solved! by Joce640k · · Score: 1

    The C++ FAQ says "arrays are evil" and I completely agree with that.

    Use std::vector instead and all your memory management and buffer overflows will melt away.

    "C++ is also the only language that has hiding ("abstraction") without memory safety"

    C++ can have as much memory safety as you want, even more than Java if that's what floats your boat. The point is that C++ doesn't force you to have that overhead unless you want it.

    eg. You can write a version of std::vector which always range-checks operator[], iterators, etc.

    You should never use a raw C-style pointer to control a resource (Bjarne even says this in the article).

    No stray pointers, no buffer overflows.... tell me again why C++ is "bad"....

    --
    No sig today...
  60. Re:[AC]useful but oh so flawed by everphilski · · Score: 1

    What about using Maple to write the math, and then generating C code from that? better than hacking the language.

    Oh, good lord, have you ever seen Maple (or Matlab) C output? it's horrendous. We used to integrate that stuff at work for a project I was on. Never again.

  61. Anyone trying to defend C++ as a language by frank_adrian314159 · · Score: 3, Informative

    Anyone trying to defend C++ as a language should read this. And I speak as a programmer who has used C++ since cfront 1.0 was released to the world.

    Useful, yes. Pragmatic, maybe. Design heavily rationalized ex post facto by its creator and its proponents, most certainly. But a well-designed programming language, it is not.

    --
    That is all.
    1. Re:Anyone trying to defend C++ as a language by Anonymous Coward · · Score: 0

      No, the kind of idiocy spouted by the person in that link makes me think the person is a VB programmer or something. Stating that C++ is bad because the programmer was dumb enough to attempt to access something out of range in an array (or whatever) and/or not implement bounds checking to ensure this doesn't happen? That debugging a *compiled* program doesn't have some universal nice and easy way to access the underlying code? The fact that a complex language might need a complicated type system that is easily understandable after spending any amount of time learning C++?

      I'm not the biggest fan of C++ myself (I prefer the more simplistic and straightforward C), but putting down C++ when you clearly don't understand it or have the mindset of a very simplistic beginner's language is just petty.

  62. C++ has a lot of problems by master_p · · Score: 1

    1. no *optional* (I repeat: optional) garbage collection.

    2. many syntax problems: not context-free grammar (great problem for tools), various semicolons that are reduntant etc.

    3. no functional programming(no lambdas, etc).

    4. shared_ptr sucks (just try to pass 'this' to a function that requires a shared ptr and deletes the current object).

    5. no consistency: primitives are not classes, although I could program classes that behave as primitives.

    6. no import statements; still using old boring header files.

    7. many others, too numerous or small to mention.

    C++ is built on some excellent ideas, it's just the execution of those ideas that sucks. There can be another C++ like language with none of the problems of C++ and all its benefits.

    1. Re:C++ has a lot of problems by EsbenMoseHansen · · Score: 1
      true, but...

      1. no *optional* (I repeat: optional) garbage collection.

      It is on the way, but (apparently like Bjarne, wow!) I find this to be of little matter. I very seldom have memory resource problems.

      2. many syntax problems: not context-free grammar (great problem for tools), various semicolons that are reduntant etc.

      True, but newer and better parsers are getting there. But I agree that the syntax is the worst bit about C++. KDevelop 4.0 is looking good, though, once they get the memory consumption under control :D

      3. no functional programming(no lambdas, etc).

      None is a bit rich, but the syntax is very bothersome at best. Lambdas will land in the next standard (as the article also mentions)

      4. shared_ptr sucks (just try to pass 'this' to a function that requires a shared ptr and deletes the current object).

      .... you will get a compile error?! shared_ptr's one-parameter constructor that takes a pointer is declared explicit. Were you hit by a bad implementation, or a bad compiler perhaps?

      5. no consistency: primitives are not classes, although I could program classes that behave as primitives.

      I don't quite agree, but I do find the distinction unnecessary and think it should be done away with in any case. So we are more or less in accord here.

      6. no import statements; still using old boring header files.

      That critique is a bit weak. There are pro's and cons to either approach.

      C++ is built on some excellent ideas, it's just the execution of those ideas that sucks. There can be another C++ like language with none of the problems of C++ and all its benefits.

      Yeah, I dream about this :) Be sure to shout it from the mountaintops if you make it or find it someday!

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    2. Re:C++ has a lot of problems by master_p · · Score: 1

      It is on the way, but (apparently like Bjarne, wow!) I find this to be of little matter. I very seldom have memory resource problems.
      On the other hand, our team of programmers have had quite a lot of issues, especially when different programmers have different ideas about how to manage memory. I definitely prefer to have garbage collection so as that this particular problem (which can become seriously nasty) is solved.
      Perhaps a programmer going solo does not have a problem, but for projects in the enterprise, where programmers come and go, it's very serious.

      True, but newer and better parsers are getting there. But I agree that the syntax is the worst bit about C++. KDevelop 4.0 is looking good, though, once they get the memory consumption under control :D
      Newer and better parsers? I have Visual Studio 2008, and Intellisense still lags a lot behind me. On the other hand, in the Java world, for example, by the time I have finished writing an identifier, the environment already knows what I am talking about and has already pointed out the errors.

      None is a bit rich, but the syntax is very bothersome at best. Lambdas will land in the next standard (as the article also mentions)
      None is a short of an understatement. You can't combine functions in the way ML or Haskell does. You need a lot of boilerplate code and a lot of hacking to get the same results.
      I've seen the proposal about lambdas, and I wasn't impressed. There are many redundant declarations, for example you have to declare your enclosed variables twice.

      .... you will get a compile error?! shared_ptr's one-parameter constructor that takes a pointer is declared explicit. Were you hit by a bad implementation, or a bad compiler perhaps?
      Try the following code:

      #include <boost/shared_ptr.hpp>
      using namespace boost;

      class Bar {
      public:
      void action();
      };

      void foo(const shared_ptr<Bar> &bar) {
      }

      void Bar::action() {
      foo(shared_ptr<Bar>(this));
      }

      int main() {
      Bar bar;
      bar.action();
      return 0;
      }
      ...and see your program die a horrible death...! It does not matter that the shared_ptr constructor is explicit. When you have a precompiled library that accepts shared_ptrs and you want to use 'this', you are basically screwed.

      That critique is a bit weak. There are pro's and cons to either approach.
      There are no advantages in manually coding module interfaces.

      Yeah, I dream about this :) Be sure to shout it from the mountaintops if you make it or find it someday!
      Someone will make it. D is a step forward (and a step back in the same time).
    3. Re:C++ has a lot of problems by EsbenMoseHansen · · Score: 1

      It is on the way, but (apparently like Bjarne, wow!) I find this to be of little matter. I very seldom have memory resource problems.

      On the other hand, our team of programmers have had quite a lot of issues, especially when different programmers have different ideas about how to manage memory. I definitely prefer to have garbage collection so as that this particular problem (which can become seriously nasty) is solved. Perhaps a programmer going solo does not have a problem, but for projects in the enterprise, where programmers come and go, it's very serious.

      I have worked in the enterprise, with no problems stemming from this. I made a short text and a seminar to get the ball rolling, and that pretty much eliminated that problem. On the other hand, I have been in Java projects where resource management was truly problematic --- I ended up solving that with Javas pitiful excuse for functional support. The syntax sucked, but it worked.

      But of course, gc might solve *your* problem, which of course makes it important to you :) Personally, I think it is of little consequence --- gc is the last memory management method I would pick.

      True, but newer and better parsers are getting there. But I agree that the syntax is the worst bit about C++. KDevelop 4.0 is looking good, though, once they get the memory consumption under control :D

      Newer and better parsers? I have Visual Studio 2008, and Intellisense still lags a lot behind me. On the other hand, in the Java world, for example, by the time I have finished writing an identifier, the environment already knows what I am talking about and has already pointed out the errors.

      KDevelop 4 (alpha) does completion in realtime, including type information etc. I'm told that the on-the-fly error checking will come. And of course parsing is easier in Java, which cannot do as much as C++. My point is that I believe you can retain the power of C++ and still make the parsing a lot easier for tools, but that on the other hands, the tools are getting more powerful and the problem might be solved that way around.

      None is a bit rich, but the syntax is very bothersome at best. Lambdas will land in the next standard (as the article also mentions)

      None is a short of an understatement. You can't combine functions in the way ML or Haskell does. You need a lot of boilerplate code and a lot of hacking to get the same results.

      ...eh, no. You can easily make a functor object that takes two other functor objects and combines them. The syntax sucks, the error message would be worse and so on... but there is no boilerplate code. In fact, I think you would be able to use boost::lambda to do this directly today.

      I've seen the proposal about lambdas, and I wasn't impressed. There are many redundant declarations, for example you have to declare your enclosed variables twice.

      I can't remember the exact details, but I don't recall any redundancy, except that you had to explicit tell which local vars should be available to the function --- something I regard as a good thing.

      .... you will get a compile error?! shared_ptr's one-parameter constructor that takes a pointer is declared explicit. Were you hit by a bad implementation, or a bad compiler perhaps?

      Try the following code:

      As I thought. The library tries to prevent you from making that mistake, but you overrode it with an explicit cast, and the code does something you didn't mean to. We call that error for "error 40" around here... it originated 40cm from the screen.

      It does not matter that the shared_ptr constructor is explicit. When you have a precompiled library that accepts shared_ptrs and you want to use 'this', you are basically screwed.

      sounds like yo

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    4. Re:C++ has a lot of problems by master_p · · Score: 1

      I have worked in the enterprise, with no problems stemming from this. I made a short text and a seminar to get the ball rolling, and that pretty much eliminated that problem. On the other hand, I have been in Java projects where resource management was truly problematic.

      Having been in both environments, with projects of similar complexity, Java projects had fewer resource management problems and were easier to detect bugs and resource-management issues.
      Perhaps your team is more competent than mine. This only proves the higher barrier for entry into C++. Unfortunately, having C++ programmers that are so experienced as to solve *any* memory management issue is very difficult, if downright impossible.
      And let's not forget each language's ability to scale. Java projects scale much more easily than C++ in complexity. Because for each additional degree of complexity in C++, memory management becomes twice as more complex as in the previous step.

      I ended up solving that with Javas pitiful excuse for functional support. The syntax sucked, but it worked.

      Functional support has nothing to do with resource management. Both languages don't have any functional support, but it can be faked in both languages (with different machine and programmer performance results) more or less in the same way (i.e. by exploiting the constructs of each language).

      But of course, gc might solve *your* problem, which of course makes it important to you :) Personally, I think it is of little consequence --- gc is the last memory management method I would pick.

      Mine and the problems of a lot of others, including my manager, my client's manager, my client's developers, my client's customers, etc. And a whole other people that prefer not to have to spend time on memory management.
      Of course, there are always a bunch of people that don't want the easy way out, so that's why I said it should be optional. Nevertheless, it's missing.

      KDevelop 4 (alpha) does completion in realtime, including type information etc.

      So does Visual Studio 2008, but in practice, it's not instant. It's realtime though, in the sense that it happens when you type. You have to wait for it for good results to come up.
      I wish KDevelop4 succeeds in it, but this is 2008 and I am still waiting for many things regarding C++, including GC, lambdas and decent intellisense.

      And of course parsing is easier in Java, which cannot do as much as C++.

      You can do anything in Java, just like you can do anything in C++. Both are Turing complete and very similar in concepts and layout.

      My point is that I believe you can retain the power of C++ and still make the parsing a lot easier for tools, but that on the other hands, the tools are getting more powerful and the problem might be solved that way around.

      Yes, in 2020, maybe. But, by that time, I would be retired.

      ...eh, no. You can easily make a functor object that takes two other functor objects and combines them. The syntax sucks, the error message would be worse and so on... but there is no boilerplate code.

      ...eh, yes. Having to write the combined function outside of the point of interest is much more time consuming, and it disturbs the thinking flow seriously.

      In fact, I think you would be able to use boost::lambda to do this directly today.

      Aha, someone else wrote the boilerplate code! you see, it's needed.
      Of course, if you check out boost lambda, it has some serious gotchas and limitations, which can not be avoided, due to the nature of C++. You can't have blocks of statements as lambda, for example.

      As I thought. The library tries to prevent you from making that mistake, but you overrode it with an explicit cast, and the code does something you didn't

  63. Page Layout Pathological Case by DrPascal · · Score: 1

    Is anyone else getting increasingly frustrated with these retarded web page layouts? The only reason this "in-depth" article is 8 pages is because the column width of ACTUAL CONTENT on the page is 280 pixels wide, out of 960 pixels (locked).

    29% of the page is content, or less, if you count the stupid header ads and such. Eight pages, my ass.

    --
    DrPascal: Not the language, the mathematician.
  64. Bitmasking by bill_mcgonigle · · Score: 2, Insightful

    Hex is close enough and less error-prone

    When you're actually bitmasking, it's nice to see the bits rather than having to accumulate them in your head.

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
  65. WTF? Re:Interesting Read by Anonymous Coward · · Score: 0

    Is that example program on the first page some kind of weird joke?

    Sorry, but I am uninterested in exploring a web site or language that includes this kind of shit:

    "Note: all D users agree that by downloading and using D, or reading the D specs, they will explicitly identify any claims to intellectual property rights with a copyright or patent notice in any posted or emailed feedback sent to Digital Mars."

    what the fuck does that even mean?

    1. Re:WTF? Re:Interesting Read by bytesex · · Score: 2, Interesting

      It's the real reason that D hasn't taken off yet. Well, that and the fact that it has 90+ (!) keywords. The guys at digital mars are doing what Sun tried to do with java; it's ours, ours, and ours alone ! Yes, there is a spec, and yes you can build compilers, but wait - not so fast. You have to let us test your stuff, or you can't call it D. And maybe pay us a little. Or at least remember us in any code that you write.
      .
      Whenever I go to digital mars' website, I'm reminded of my Corba days and that institution - I forget what it's called - that was in charge of it. People should be well reminded that the days of commercial languages are over. Even Microsoft won't try it anymore. That should say something.

      --
      Religion is what happens when nature strikes and groupthink goes wrong.
    2. Re:WTF? Re:Interesting Read by Anonymous Coward · · Score: 0

      If you send feedback to Digital Mars about their language, and you feel you have some IP claim on anything in the language, you need to explicitly state it. They don't want their language to become widely used only to be hit by some sneaky patent holder, biding his time until it's lucrative to strike.

  66. GC ~= complexity by micromuncher · · Score: 1

    Course that point in the article is contentious. Adding garbage collection after the fact can yield a host of problems. And inevitably most applications in C++ that use dynamic memory allocation will need some sort of GC. Purists would argue you hide this in your constructor/destructor, or object manager classes... but it all adds up to complexity, and complexity is bad, because it means defects.

    Languages that support GC, or have optional support, still allow programmers to write bad programs. I review so much bad Java code that bleeds objects - show me that the developer was never educated (in school or by fire) about the how and why GC works or doesn't.

    To add this to C++0x (or any language) late in the game is silly, even if optional. Languages like Java, more specifically the VM behind them, have over 10 years of solid development and evolution. Most Java developers do not know that they can complete tune and/or replace GC strategies in the VM. I wouldn't call this wierdness, if that is what you refer to. It, in my opinion, has everything to do with knowing about how things work under the hood. Optimization in general seems to be a forgetten art.

    And of course I'd never come to appreciate it in Java if I weren't a C++ programmer for 8 years prior where a lot of my time was wasted hunting down memory issues and/or reinventing GC as the application's problem (yay object reference counters, object managers, and other strategies that aren't directly related to problem domain.)

    --
    /\/\icro/\/\uncher
  67. C++ Debuggers by saccade.com · · Score: 3, Funny
    At a corporate event a few years ago, I found myself seated across from Mr. Stroustrup. I asked him what debugger he used for his own development.

    His answer was along the lines of: "Oh, I never use a debugger. If something's not working right I just think about it...maybe I'll add a printf once in a while if I need to check something."

    Now you know why utterly un-debuggable features like templates went into the language...

    1. Re:C++ Debuggers by Anonymous Coward · · Score: 1, Interesting

      Brian Kernhighan also admitted in an interview
      that he only used a debugger to get a stack trace.

      http://www.cs.cmu.edu/~mihaib/kernighan-interview/

    2. Re:C++ Debuggers by Anonymous Coward · · Score: 1, Insightful

      You might be surprised how many smart people think you're better off actually understanding your code instead of having the computer explain what one path happens to do right now.

    3. Re:C++ Debuggers by Traf-O-Data-Hater · · Score: 3, Insightful
      "you're better off actually understanding your code instead of having the computer explain..."

      That's just the point. Your code isn't the problem for you to understand. In the real world where people have to look at other people's code, you often need all the debugging help you can get.

      Stroustrup is being very smug in his response here. He lives in an ivory tower, how much real-world code written by other people (to a deadline or management constraints) has he ever dealt with?

      My feeling is, very little..

    4. Re:C++ Debuggers by dkf · · Score: 1

      you're better off actually understanding your code instead of having the computer explain... That's just the point. Your code isn't the problem for you to understand. In the real world where people have to look at other people's code, you often need all the debugging help you can get. I've worked with other people's code for a long time now, and yet the most useful thing from a debugger is indeed usually just a stack trace. Typically when a stack trace is insufficient, the other debugger facilities won't help that much either; you're still left staring at the code thinking "WTF!"

      Stroustrup is being very smug in his response here. He lives in an ivory tower, how much real-world code written by other people (to a deadline or management constraints) has he ever dealt with? My feeling is, very little.. If you want to improve your productivity (and haven't already done this) write a suite of unit tests so that you can check you haven't made any blunders as part of your normal build process. If you can divide your code into distinct modules and check that each works correctly on its own, it's much easier to then focus on just the inter-module issues rather than having to deal with the code as one large mass. (The problem with debuggers is that they're not very good at respecting the module boundaries that you know about; they just pile everything together in a jumble.) Of course, getting test suites right is itself rather tricky. That's why you have coverage tools. And don't forget to use tools like valgrind or purify.
      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    5. Re:C++ Debuggers by zaphle · · Score: 2, Insightful

      Just a side-note on unit-tests and debuggers (actually off-topic): They're all fine and well, but bugs resulting from bad synchronization (e.g. use of mutex etc) in multithreaded programs will not be detected. Often, if an object is not well synchronized, the chance of having race conditions or lost updates are generally very small and therefor hard to reproduce, but in a production environment they would still come up fairly regularly. E.g. If there's a chance of 1 in a million for something to go wrong due to bad synchronization, you would only encounter it on average every one millionth time you debug your application (=never), while for a computer it's not a big deal to run a piece of code billions of times per day. By definition, unit tests are never run while other threads are touching the same memory because they are meant to test an isolated unit, which boils down to testing them on a single thread, so unit tests will even never spot them.

      Don't get me wrong, it's good practice to have unit tests, but there are actually people out there (often IT managers) who imagine that if all code is covered by unit tests that this would guarantee that the program as a whole can't fail so I always like to add this disclaimer when talking about unit-tests or testing in general.

      --
      And what if there's nothing behind the door until it is being opened?
  68. Stroustrup seems to say (don't use exceptions!) by EMB+Numbers · · Score: 2, Informative

    Here is a real eye opener: Bjarne Stroustrup cited the JSF coding standard as an example of C++ usage: "Also, embedded systems programming is a major area of use and growth of C++; for example, the software for the next generation US fighter planes are in C++ (see the JSF++ coding rules on my home pages)." http://www.computerworld.com.au/index.php/id;408408016;pp;5;fp;16;fpid;1

    I particular like the following statement in the JSF++ coding rules that the creator of C++ holds up as an example of how to use C++:
    AV Rule 208 C++ exceptions shall not be used (i.e. throw, catch and try shall not be used.)

    Rationale: Tool support is not adequate at this time.

  69. Cut the senseless C++ bashing, please. by js_sebastian · · Score: 2, Interesting

    It's much harder to write C++ code that, for example, will never leak memory no matter what goes wrong than in the assorted garbage collected languages, or even vanilla C. That, I don't see how anyone could even reasonably argue. You don't see? let me try to show you...

    About C: you think it is easier to manage memory with C char* and arrays than with C++ string,vector,and exceptions + resource-acquisition-is-initialization paradigms? I can only call that an outlandish claim! Hell even auto_ptr helps (I use it to express ownership transfers in function parameters and return values), and in C++0x they will finally have a real smart pointer standardized too. If you use raw arrays in C++ and get buffer overflows, don't blame stroustroup.
    About garbage collected languages: true, memory management is not your problem anymore, which makes coding a bit easier (although there are other resources than memory which must still be managed manually). The problem is performance and, specifically, memory usage. My memory-leaking C++ implementation may well use half as much memory at any given time as your non-leaking GC code. Despite what people think, computers do not have over-abundant performance for all relevant tasks. I myself wrote 2 pieces of code in C++ just in the first months of this year where I knew from the start performance would be a problem. In one case because of the sheer size of the data I was handling, in the other because I knew the problem was NP-Complete. The first one would have simply page thrashed me to death in a GC environment.

    The problem is that GC is viral, in the sense that if I link my non-GC code to a single library written to run in a GC environment, GC needs to be enabled for the entire program. This is the difficulty of adding GC as an optional feature to C++. Making it mandatory is not an option for performance reasons. In a GC environment you have little in the way of guarantees that memory will be freed right away, and this will occasionally come back to bite you hard when your application slows to a crawl as it runs out of memory. GC may be fine 98% of the time, the problem is if the language uses GC, you just can't turn it off locally where the memory usage is really hurting you.
    1. Re:Cut the senseless C++ bashing, please. by Nicolay77 · · Score: 1

      I think you can overload the new operator for only a few classes and that way provide GC only to those classes.

      So the right way should be via a GC library and a way to say which classes get the GC.

      --
      We are Turing O-Machines. The Oracle is out there.
  70. Always Read at the Print This link by Anonymous Coward · · Score: 0

    Me too.

    Simple solution - look for the print this link and read there.

    If there is no print this link, then the article is not worth reading.

    No stress.

  71. Re:managed code by velen · · Score: 1

    Anyone who has tried to use .NET/C# for a TCP server with a few thousand clients over a GPRS cloud (frequent disconnect/reconnects) has my sympathies. .NET is not worth the hassle for scalability in some areas. Of course, since M$ is showing it down the throat of the next generation of CS students, the sheeple will go down the same path as that of C++

  72. A wisely used tool for elegant implementation by Douglas+Goodall · · Score: 2, Informative
    I am the first to admit you can write totally unmaintainable code in c++ if you want to. I will also admit that I have known a lot of c++ programmers that absolutely had to use every feature or they weren't happy.

    I on the other hand used about 10% of the features and had a wonderful time using a subset that probably was actually just "c with classes". I used c++ as a better c compiler with warnings turned up all the way. I found classes an elegant way of encapsulating code that dealt with hardware. Concrete classes were my favorite. My c++ programs were straightforward and easy to read. I am thankful that BS wrote the language. It was a lot of fun. I never really needed more than I learned in the first month. Strong type checking kept me out of trouble. I actually spent very little time subclassing and enjoyed the luxury of keeping my prime classes functional. Modeling hardware as c++ objects was the most fun I had in programming ever. When done right, the code was as compact and maintainable as any I have written in any other language. Unfortunately I got very little follow-on work because the functionality of my code was obvious. Vendors like Microsoft and Borland just couldn't wait to use polymorphism to create frameworks. I hated frameworks because they were these huge collections of c++ complexity that had to be studied endlessly, and about the time you knew enough, the vendor brought out a new version. MFC is a prime example of a piece of code I just couldn't get my head around. It seemed to me that the point of all the frameworks was to make hello.cpp in 100 lines or less, but anything non-trivial got huge quickly.

    I suspect that there are other people out there that felt like I did about c++. At least I hope there are. Every time I encountered a project where the legacy code used every feature of c++, my spirits took a dump. C++ was a tool that consultants often used to make themselves indispensable. Some of the code I encountered, like the bio-rad application was a good thesis, but a lousy piece of intellectual property. Twenty levels of nested classes, heavily subclassed made for a long research project every time you needed to track down a bug.

    The secret of c++ for me was knowing just how much to use to leverage off the power of it's object orientation. Encapsulation was good, Inheritance was ok sometimes. Multiple inheritance was almost never a good thing, and polymorphism usually lead to spaghetti code. IMHO

    1. Re:A wisely used tool for elegant implementation by Nicolay77 · · Score: 1

      I do agree with you that C++ and concrete classes can be very useful and fun.

      And if you instantiate the objects in the stack, it's an order of magnitude faster than Java.

      I wish more people would understand that to use C++ you don't need to use every single feature of the language.

      --
      We are Turing O-Machines. The Oracle is out there.
    2. Re:A wisely used tool for elegant implementation by Douglas+Goodall · · Score: 1
      Thank you. I was wondering if I was really that alone in my relationship to c++.

      (pearls) swine(); '

  73. Re:heresay... by zaphle · · Score: 1

    ... should be hearsay. I noticed after submitting. My apologies to the grammar-nazis out there.

    --
    And what if there's nothing behind the door until it is being opened?
  74. Re:managed code by gbjbaanb · · Score: 1

    Sooo right.

    I worked on a large-scale system a few years back and the performance was atrocious. Truly the directors were concerned the company would go bust if they couldn't sell the product, and the product was unsellable. A long story shortens to: it was MTS. We had out comms working through DCOM objects, only those objects were placed in MS Transaction Server, you know the nice green spinning globes. This made it easy to implement and MS told us it was the bee's knees.

    Unfortunately, removing those objects and running the comms through plain DCOM made an astounding difference. (the other things we found were XML is slow as treacle, and context switches are bad).

    Now, we find the same thing: MS wraps lower level technology with more and more "feature-added", "easy to use" stuff and forgets to tell us that its slower, sometimes dramatically so. What they do tell you deserves a marketing-person health warning.

    So, I'm looking at WCF now. Its 'cool' apparently, but I find it to be more wrappers on top of the already slow ones. And you can't even connect a WCF tcp/ip socket to a non-WCF socket. (you want interop, you should use SOAP apparently, tcp/ip connections are 'optimised' for WCF-only apps).

    I can see why you'd want to use it all, its easy (though maybe its me, its not much better that anything else), but on large-scale systems you should avoid .NET and for small-scale systems (where resources are a premium) again avoid .NET. For systems that you need to be resource-efficient (because you're going to run it in a VM alongside several others - popular in today's green world), you should avoid .NET too.

    Hmm.. not much left really, when will the world realise this?

  75. I remember him saying something else... by sticks_us · · Score: 1

    Have you ever sat down and worked on a C++ project? Here's what happens:

    "First, I've put in enough pitfalls to make sure that only the most trivial projects will work first time. Take operator overloading. At the end of the project, almost every module has it, usually, because guys feel they really should do it, as it was in their training course. The same operator then means something totally different in every module.

    Try pulling that lot together, when you have a hundred or so modules. And as for data hiding. God, I sometimes can't help laughing when I hear about the problems companies have making their modules talk to each other. I think the word 'synergistic' was specially invented to twist the knife in a project manager's ribs."

    --
    "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth
  76. Re:Bjarne does.....what? by Nicolay77 · · Score: 1

    I helped doing the database bulk importing routines of a PHP application. The catch is that every record needed some processing, so it was not really bulk.

    I eventually wrote that part in C++, PHP would have taken days to do what C++ did in minutes. I used wxWidgets as a framework, and things like Unicode support (the source files where in UTF-8) were much easier in C++ than in PHP. Nevermind that a true hashtable was also much faster than a PHP associative array.

    That said, I would never try to write that in plain C++. Too painful that way. Frameworks are the key to C++.

    --
    We are Turing O-Machines. The Oracle is out there.