Slashdot Mirror


Interview With Bjarne Stroustrup

koval writes "artima.com has published an initial portion of interview with Bjarne Stroustrup. The scope of first part is mostly about improving the style of C++ programming and getting maximum from a language."

48 of 502 comments (clear)

  1. Improvements? by Eric+Ass+Raymond · · Score: 2, Insightful

    How about eliminating the buffer overflows?

    1. Re:Improvements? by Dr.+Photo · · Score: 2, Funny

      std::vector already does this. How about using it?

      Am I the first to think that maybe "STD vector" is possibly the worst name for a data type? ;)

    2. Re:Improvements? by orthogonal · · Score: 3, Funny
      Am I the first to think that maybe "STD vector" is possibly the worst name for a data type? ;)

      try:
      using namespace condom ;
  2. Scott Meyers by CyberGarp · · Score: 2, Funny

    Any language that allows for someone making a living pointing out everything one shouldn't do needs more than a face-lift.

    --

    I used to wonder what was so holy about a silent night, now I have a child.
    1. Re:Scott Meyers by gaijin99 · · Score: 2, Funny
      Any language that allows for someone making a living pointing out everything one shouldn't do needs more than a face-lift.

      Cute, but meaningless. Any language has features that are easily overused or abused. One of the things a programming teacher has to do with any beginning class is explain what you shouldn't do. Or at least he should be spending time on that.

      C++ has problems, yes; pretty unavoidable since it was the first real object oriented language. Java has a different set of problems since it was the first language that was OO from the ground up. I'd say its time to learn from the mistakes of both, scrap 'em, and build a language with the pitfalls of neither. 'Course that's a bundle of work, and you can get along well enough in either of them, so people tend to try and patch rather than start from scratch.

      The funny thing is that C still stands out as an excellent general purpose programming language. Possibly a bit akward for use in writing GUI's, but overall it still works after all these years. K&R deserve more praise than they've been getting.

      --
      "Mission Accomplished" -- George W. Bush May 1, 2003
    2. Re:Scott Meyers by CyberGarp · · Score: 2, Interesting

      C++ has problems, yes; pretty unavoidable since it was the first real object oriented language.

      This comment alone summarizes the posters knowledge of programming languages. For a better understanding of C++, check it out on the Computer Languages History website

      My reply: Cute, but it unfortunately does mean something. C++ has more features that are so easily misused (not abused), that Scott Meyers wrote 3 large volumes on the subject. Other languages have similar featuers, but not in near the quantity of C++. Java has been jokingly refered to as C++--++. The "--" refers to the stripping away of all the majority of the problems that Scott Meyers addresses in his books.

      PS Object Oriented is a concept adapted from functional programming languages, i.e. LISP.

      --

      I used to wonder what was so holy about a silent night, now I have a child.
    3. Re:Scott Meyers by Waffle+Iron · · Score: 5, Funny
      C++ has problems, yes; pretty unavoidable since it was the first real object oriented language. Java has a different set of problems since it was the first language that was OO from the ground up.

      Let me guess... you work as a prior art researcher for the USPTO.

    4. Re:Scott Meyers by PD · · Score: 2, Funny

      Or assembly. You could have any object you wanted, as long as it fit in a register.

    5. Re:Scott Meyers by stonecypher · · Score: 2, Insightful

      Any language that allows for someone making a living pointing out everything one shouldn't do needs more than a face-lift.

      It's not exactly clear to me whether I'm taking a joke on as if it were serious. That said, this is a genuine sentiment with many, so I feel my rebuttal to be germane to them if not nessecarily to you.

      The problem with language is that its domain is inherently difficult. The more expressive a language is, the deeper and more powerful structures it can express. Conversely, because making a language more expressive involves adding new methods of control, the more expressive a language is, the more difficult it is. You need to know how to generate the syntax which wields the new expression mediums, etc.

      The problem as I see it is that the professional field requires a significantly higher degree of skill in expression than the amateur field wants to put forth. At first this seems like a tautology, but think about it: it's fairly rare that an experienced c++ programmer suggests there needs to be a starting-over. Given that few other dominant-in-their-day languages can make that statement, I think it's worth considering that maybe C++ is as horrible as it is by necessity.

      Bjarne suggests that there are more than a dozen languages named D (which is stupid; c++ *is* D, as well as P; don't try to extends jokes you don't understand, folks, kthxbye) and another half dozen named E or P. That some of them are backwards compatible and *still* haven't takjen over should be an indication that C++ is doing at least something right, despite hordes of popular, well supported contenders.

      I too hate a lot of things about C++. But frankly, even though it's not even close to my first language, I can't think of another language I like more for a generic problem domain. Sure, when it's web apps it's PHP; when it's database toys or mostly UI apps it's Delphi; et cetera. Still, when it's difficult, it's c++, every single time.

      Any profession that allows for a whole subprofessions making a living pointing out what one should not do has become satisfyingly deep. Things which one can just jump into and be the best at are shallow. Art, writing, engineering, mathematics, induction, politics, philosophy. Each of these has books, tomes on what you should *not* do in order to be effective. In some fields this study of counterexamples has become so important that it elevates to its own subfield of study (fallacies and converses;) arguably that's happening in CS with AntiPatterns right now.

      What I think you're seeing is a language which is way ahead of the game in community support. ;)

      --
      StoneCypher is Full of BS
    6. Re:Scott Meyers by You're+All+Wrong · · Score: 2, Interesting

      """
      I swore off C++ almost a year ago (wish I had done it sooner), and in retrospect, getting "the maximum" from C++ felt like getting blood from a turnip.
      """

      Gawd bleshya for your honesty.

      Fess-up time:
      I was a C++ _lecturer_ about a decade ago, and would with a clear conscience recommend it for almost everything(*), but I more often than not (i.e. 90% of the time) recommend _other_ languages than C++ nowadays.

      I've even heard occasional derogatory remarks from those on the national standards committees who ten years ago thought the road to programming heaven was paved with C++.

      YAW.

      (* I even wrote a real-time microkernel in C++ in order to prove to my students that C++ didn't have to be slow. I could task-switch 6000-times a second on a 486/33, for example (but not do anything in the tasks obviously!))

      --
      Your head of state is a corrupt weasel, I hope you're happy.
  3. Yes! by kurosawdust · · Score: 3, Funny

    Oh boy! I can't get enough of Bjarne and J-Lo!

  4. Probably fake but . . . by Brahmastra · · Score: 4, Funny
    I agree with every word of this probably fake interview

    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 - really caught a cold trying to rewrite everything in C++ in about '90 or '91. I felt sorry for them really, but I thought people would learn from their mistakes.

    Interviewer: Obviously, they didn't?

    Stroustrup:

  5. Compilers by ultrabot · · Score: 3, Interesting

    Speaking of C++, is there a compiler that complies with the ISO standard already? Does anyone use it?

    --
    Save your wrists today - switch to Dvorak
    1. Re:Compilers by X · · Score: 4, Interesting
      as any C++ programmer knows, most compilers completely blow when it comes to standards conformance at the moment.
      This is the conventional wisdom. It is (sadly) based on how things used to be. However, there has been a significant amount of progress in the last few years with regards to standards compliance. Aside from the Comeau compiler, you have Microsoft's, Intel's, IBM's, and G++. The last time I used Sun's C++ compiler, the only problems I had were with the antiquated version of the STL that they insist on using for backwards compatilibity purposes. The lastest issue of Dr. Dobbs has actually looked at this based on examples from the C++ standard, and while Borland seems to be making little progress (I don't think their compiler itself has changed in a while), most of the other vendors are rapidly approaching full compliance (although export seems to remain a mystery to everyone besides Comeau).
      --
      sigs are a waste of space
    2. Re:Compilers by Zathrus · · Score: 3, Interesting

      Aside from the Comeau compiler, you have Microsoft's, Intel's, IBM's, and G++.

      I believe that MS VC++ 7.0 (or whatever it's marketed under now) and G++ are the most compliant of the bunch. IBM's compiler may be standard, but their linker is anything but -- thanks to it we can't use dbx or gdb on our code base (both simply core either while loading the core image or when you do a "where"; IBM's dbx occasionally works but never gives proper symbol names and setting break points is impossible). I don't have any experience w/ Intel's compiler so I can't say there. HP's compiler is abysmal.

      One interesting place to look at compatibility is the Boost library -- Boost is a rather large C++ library being developed by some of the big names in C++ that may wind up in the next standard -- and how well it compiles on various platforms and compilers. Check out the compiler status page. It's certainly not a definitive test of what is and is not standard, but it's a data point.

      You're certainly correct in that C++ compilers and their STL libraries have come very far in the past couple of years. One of the worst (Microsoft) is now one of the best -- largely due to them hiring a project lead that's a STL advocate.

    3. Re:Compilers by stonecypher · · Score: 2, Interesting

      Sorry, just saying luminaries wanted it banished and then not explaining left a bad taste in my mouth. I should have provided this link to a Herb Sutter article called "Can't Afford Export" (regarding getting rid of the export keyword) in the original post.

      This isn't the only such article, but it's the only one I'm finding on a brief search; IIRC, I think I've also seen similar stances from Meyers and Dewhurst. Not certain, though, 'cause I can't seem to find them (yay 30 second searches.)

      --
      StoneCypher is Full of BS
  6. Re:What about... by Sir+Haxalot · · Score: 2, Interesting

    Where do you see C++ going as a language?
    I think I'll just clarify that. In four or five years, what changes would you like to see happening to the language, and how realistic it is to be able to achieve those goals in that time period?

    --
    I have over 70 freaks, do you?
  7. Confusion (not a Slashdot interview!) by wackysootroom · · Score: 2, Informative

    I see that a lot of people here are confused and posting questions for Bjarne Stroustrup. This is not a slashdot interview where people post questions for the guru and the editors pick the top 5 for the interviewee to answer. This is an interview that was done by an external website and not interviews.slashdot.org.

  8. From the article by Apreche · · Score: 3, Insightful

    Quote Bjarne Stroustrup: Yes. If every data can have any value, then it doesn't make much sense to have a class. Take a single data structure that has a name and an address. Any string is a good name, and any string is a good address. If that's what it is, it's a structure. Just call it a struct. Don't have anything private. Don't do anything silly like having a hidden name and address field with get_name and set_address and get_name and set_name functions. Or even worse, make a virtual base class with virtual get_name and set_name functions, and override it with the one and only representation. That's just elaboration. It's not necessary.

    Thank You! This is the number one java peeve. Every time I just want to make a structure I've got to make a whole class. That's a whole file. That's a whole lot of extra code. In C/C++ I can make an equivalent struct in a few lines.

    This is why I like python so much. I can do all the object-orientedness I want and all the proceduralness I want and they work together perfect. And everything pops out into super efficient C code and then into executable with my gcc. And if I want it cross platform I can just use jython and get workin .class files.

    --
    The GeekNights podcast is going strong. Listen!
    1. Re:From the article by X · · Score: 3, Insightful
      You need to bone up on your Java, and perhaps your C++.
      1. In C++, in terms of writing effort, a class and a struct are the same
      2. In Java, you can have multiple classes in a single file. Indeed, the compiler could care less, just like in C++.
      3. You can compile Java code to binary, indeed you can do so with gcc.
      4. Try benchmarking Java vs. Python some day. You'll discover that aside from start up time, Java outperforms Python in the majority of cases.
      This is the C++ code for a class:
      class Foo {
      public:
      int bar;
      int baz;
      };
      This is the C++ code for the equivalent struct:
      struct Foo {
      int bar;
      int baz;
      };
      This is the Java code for the equivalent class:
      class Foo {
      public int bar;
      public int baz;
      }
      Not a lot of difference is there?
      --
      sigs are a waste of space
    2. Re:From the article by Anonymous Coward · · Score: 2, Informative

      I suppose he could be talking about Psyco, the Python JIT module. I haven't used it yet, but I hear good things.

    3. Re:From the article by Angst+Badger · · Score: 4, Insightful

      I find that nearly everyone who criticizes [INSERT LANGUAGE HERE] is either using an ancient implementation ... or they simply haven't explored the language fully.

      This is an excellent template for recognizing language bigotry. Try this as a template for recognizing language agnosticism:

      "I can enumerate dozens of less-than-perfect features in my favorite language."

      Until you understand the weaknesses as well as the strengths of your favorite language, you either haven't explored it fully or you don't know enough languages well enough to have a basis for comparison. (C|C++|Java|Perl|AWK|Python|COBOL|RPG|Fortran|BASI C|PHP|Forth|6502 Assembly|Forth) all suck if you're only looking at their flaws, and they all rock if you're only looking at their strengths. If you're not looking at both, you're not getting it.

      --
      Proud member of the Weirdo-American community.
    4. Re:From the article by jcbphi · · Score: 2, Informative

      These are some of the many reasons why Python is my language-of-choice, and why I don't program much in Java (my first programming language!). However, I should point out that what pops out is not super efficient C, but rather reasonably efficient compiled byte-code. Its nice, but python is rarely as fast as I'd sometimes like it to be.

      But that's a story for another day...

      Cheers,
      J

  9. Re:Why did they need to interview bjarne about tha by deadlinegrunt · · Score: 2, Insightful

    All he did was complain about over and under object-orienting c++ code. Not sure why that's useful... My Computer Science professors do that all the time.

    Being that there is a large codebase out there that breaks either one of these rules I would venture a guess that is why he commented on it. He does not believe that there is a sliver bullet to solving software problems nor does he believe that C++ is one either. It is just a language he designed to solve problems he encountered while programming.

    C++ is not object oriented. It has OOP support but does not mandate it. The other extreme is that it is not C. If you find yourself falling to one of these extremes in *EVERY* coding probem then there is a high probability you just might have missed his point.

    --
    BSD is designed. Linux is grown. C++ libs
  10. Re:OOP IS FOR PUSSIES by BurKaZoiD · · Score: 2, Funny

    Real men code in assembler

    Since when did Steve Gibson start posting here as an Anonymous Coward?

    Some people use a screwdriver, others use a butter knife. That's the beauty of programming; there are numerous tools and technologies at your disposal that will all achieve the effect (or at the very least, a semblance of the effect) you desire. Business users typically don't know the difference anyway, so it's really a matter of programmer's preference. Pick those you feel most appropriate to your project, and leave the rest.

    Most people I know don't get the beauty of something like C++. It's a massively complex language. So complex, as a matter of fact, that you can create OTHER languages with it (via templates). But, like any other, tool or technology, take what you want from C++, and leave the rest behind.

  11. Weird guy by the+uNF+cola · · Score: 2, Informative

    I went to one of this guy's conferences on C++. I thought it'd be more in depth, but it was merely introduction to the features of C++. It does this, it does that. Neat libs like boost and the stl. Also has ACE libs for cross compatability

    Well, as one may expect, someone asked about java. He got very biligerant and brief about it. "C++ is supported on N many more platforms than java." (Can't remember N). It was also the last question too, which left that "weird" sense in my mind's eye.

    --

    --
    "I'm not bright. Big words confuse me. But Wanda loves me and that should be enough for you." - Cosmo

    1. Re:Weird guy by kraut · · Score: 2, Insightful

      Funnily enough, I've met him a few times at accu (http://www.accu.org/) conferences and had really interesting discussions with him.

      He's certainly no weirder than most other programmers I know, if you make allowances for him being Danish ;) And you have to make some allowances for being annoyed about Java: He developed a systems programming language that allows you to use OO; then everyone jumped onto the bandwagon and wrote crap programs in it (think monkeys with powertools), and then someone comes up with an application level programming language that's much safer for monkeys to handle (i.e. Java), and everyone asks "didn't you really want to design Java?".

      Duh. He may be mild mannered, but that must get irritating after a couple of years.

      --
      no taxation without representation!
  12. Invariant/struct discussions and binary compatibil by tjansen · · Score: 2, Interesting

    Stroustrup and the interviewer miss one important point in the class vs. struct and invariant discussion: binary compatibility. The reason why you should not access variables in structs/classes directly is not always that their representation may change. More often it happens that you need to add a member, but this is not possible without breaking binary compatibility (at least on the usual Linux/Unix compilers). So you need to use the private class/d-ptr pattern to hide at least future members from the public class. This does not break apps that use the class members of earlier version, but it would make the API inconsistent, as the newer version would need to offer a different way of accessing the members. And the easiest one is to have get/set methods. So if you don't want to fall into the inconsistent API trap later, you should use get/set methods from the beginning. It's the only chance to have a consistent API over several evolving but still binary compatible versions.

  13. Re:Java ? by ripleymj · · Score: 3, Informative
  14. C++ Programming Language by happyfrogcow · · Score: 2, Funny

    I've always liked C++. After reading about half (still working on the rest of it) of "The C++ Programming Language" by Bjarne, I've learned so much about what good C++ programming is about. During University, the C++ class I took covered so little. It was basically a C course except we implemented yet another string class. This book is great. Bjarne comes across as a really smart and logical person. The last few chapters about design are great. I skipped up to them after reading the first 2 sections or so. I love reading interviews of him and things he's written. Everytime I work on a personal project I try to add another idea he presents to my own work.

    I seriously enjoy programming in C++.

  15. The real trouble with C++ by Animats · · Score: 3, Insightful
    C++ suffers from the same problem that killed Pascal - its creator thinks everything is just fine, yet people are deserting it because it has some major problems that the creator refuses to fix and everybody has to work around.

    We went through this with Wirth. Wirth devised Pascal, which had reasonable data structures, although not objects, terrible I/O, and strings that only worked if they were short. He then insisted that it shouldn't change. From this came a whole range of incompatible Pascal dialects (Turbo Pascal, Object Pascal, Clascal...), and some successor languages (Modula I, II, III). Modula III was actually rather good, but nobody except some researchers at DEC SRL (now an empty building in Palo Alto) used it. Two decades later, few use Pascal or its derivatives, and Wirth is a forgotten and bitter man in Switzerland.

    This cycle is being repeated with C++. The first version of C++, before templates and the STL, was terrible. Without templates, horrible schemes involving huge defines were used to make generic objects. Strostrup used to have great hostility to run-time type information, which led to unchecked downcasts all over the place.

    Round 2 of C++ came late, and it took a long time before the compilers did templates. Then came the STL, which is wierd and unsafe, although useful.

    C has little abstraction and little safety. Java has both abstraction and safety. C++ has abstraction without safety, a terrible combination. The basic problem with both C and C++ is that the language requires the programmer to obsess on storage allocation and release, yet gives no assistance in this. Attempts to encapsulate storage allocation in C++ fail miserably (look at the history of auto_ptr). Attempts have been made to fix the language by adding another layer of rote ritual ("patterns") on top of it, but compilers can't check that, so it doesn't reduce bugs.

    Another area of trouble comes from the history of C++ as a preprocessor for C. Bell Labs had a tradition that "you can't change the linker". (This is probably because the original UNIX linker was written in assembler and had few comments.) Because of this, some tasks that should be deferred to link time (such as building vtables) are done at compile time.

    The price paid for not changing the linker is substantial. Private function members appear in header files so that vtables can be built at compile time. That's the real reason, despite what you read. If it weren't for that, you could have much stronger separation between declaration and implementation. And you wouldn't be recompiling class users just because the class implementation changed. Ada and Modula got this right, but C++ got it wrong. And Strostrup refuses to fix it.

    Yes, there are "patterns" for working around this. But they're workarounds. The programmer is doing the compiler's job. This imposes a cost on every programmer and distorts C++ programs.

    Strostrup still insists there's nothing really wrong with his language. Read what he's written about the C++200x standards revision cycle. Meanwhile, C++ is being abandoned for Java, C#, C, and scripting languages.

  16. Not awake yet- by IWantMoreSpamPlease · · Score: 2, Funny

    I mis-read the title. Thought it said "interview with a mousetrap"

    oooops...

    --
    So rise up, all ye lost ones, as one, we'll claw the clouds.
  17. C++ in the long term. by Godeke · · Score: 2, Interesting

    I programmed in C for years, mostly due to the performance of the early machines I used. Today, I wouldn't consider going back to C unless it was for time critical functions. Everything I do these days is in an environment that protects me from the gory details of memory management and pointers of doom. If I really need performance, I am going to profile my code and find the parts that really need the boost, and then recode the classes as C++ COM or more recently C++ assemblies for .NET. It is the same procedure I used to use when C was my primary language: find the performance hot spots and drop to assembly if needed.

    The discussion of class design has nearly nothing to do with C++. I can use Java to build overly complex towers of inheritance. I can also use it to build poorly defined libraries. One think I *can't* easily do is blow myself (and the underlying OS) up do to a memory allocation problems.

    I see C++ remaining for many years to build those "cycle critical" components, which are going to be consumed by languages with a guard over the chainsaw blade. Programmer efficency should always trump speed concerns until you have exhausted *algorithmic* improvement. I don't know how many times I see programmers saying "I'm using C++ for performance" while simultaniously writing something that is going to run in o(n^2) time, when a o(log(n)) algorithm is available. Yes, your C code will run your inefficent algorithm quicker than I would in a protected environment, but if my protected environment allowed me to see the abstraction that runs the fastest algorithm, my code will still be faster for large data sets.

    --
    Sig under construction since 1998.
  18. It's an education issue by Anonymous+Brave+Guy · · Score: 3, Insightful
    Seriously, you can't seriously improve a language by telling people how to program with it.

    However, you very much can improve how a language is used by telling people how to program with it. The single biggest problem C++ has isn't dangerous pointers, or ugly template syntax, or lack of a garbage collector, it's lack of good programmer education. C++ is a power tool, and requires skill to use. When most of the C++ textbooks in the world are teaching decade-old crap themselves, and most of the university professors don't know their own subject, it's not too surprising.

    I can sympathise a lot with Stroustrup here. His tool is unjustly battered by the ignorant more than perhaps any other mainstream language today, and it creates a self-fulfilling prophecy: most people who learn C++ learn it badly, and write code with buffer overflows and other kindergarten mistakes. Others pick up on this, and learn from people who themselves learned badly, and write more code with kindergarten mistakes. It's about time the C++ programming industry reached High School, but few ever seem to, and when they do, they aren't valued as much as they should be.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  19. Chill by Robb · · Score: 2, Insightful
    C has little abstraction and little safety. Java has both abstraction and safety. C++ has abstraction without safety, a terrible combination.

    This is just a doofy sentence. C has "little" safety but C++ is "without" safety? dude, learn a language before you start spouting marketing crap. If you don't know why your sentence is completely wrong, then you're not qualified to comment.

    Fully encapsulating the complexity of an abstract data type without just giving up and making many of the important decisions in the language itself is an extremely difficult problem in language design. I find the first poster's sentence, while obviously an exageration, to be rather insightful.

    C++ has high aspirations in terms of giving the programmer complete control but ultimately fails due to the emergent complexity that results from the inability to fully encapsulate all of the design decisions.

  20. Confirmed: C++'s not very object-oriented by dpbsmith · · Score: 4, Insightful

    I'm not saying that's necessarily a bad thing.

    The interview is interesting in that it confirms the impression I've had from using and/or struggling to use C++. When I try to do anything object-oriented, specifically anything involving polymorphism, it seems to be fighting me all the way. After some struggling I usually emerge triumphant, but it's almost always a battle.

    What Stoustrup seems to be saying is that classes should be treated as a special big deal, and shouldn't be used unless you're sure they're necessary. He seems to be recommending that there be, um, a class of elite programmers who put in the intense work to develop good, usable, well-debugged classes, and that the rank and file should, by all means use those classes but should not aspire to write new ones.

    And this is not unreasonable, given the effort of writing classes and getting the storage management right and so forth.

    The thing is, it's not a big deal to use classes in a truly object-oriented language. I'm not just talking about Smalltalk. Heck, they're trivial to use in REALbasic.

    Well, is that good? It certainly leads to overuse of OOP. To a man with a hammer everything is a nail, and every programming language tends to encourage overuse of the things that it facilitates. Every programming language has a tendency to induce brain-warp.

    C++, for better or for worse, does not induce object-oriented brain-warp.

    People who try to use OOP in C++ because it's cool or because of some article they read (or some instructor they had) find that C++ punishes such behavior. And Stoustrup is right: when you are programming in C++, OOP should be used sparingly and only when it's needed.

    Again, I'm not saying whether that's bad or good. That will depend on the degree to which you think OOP ought to be encouraged. If you think OOP should be just as much a part of a programmer's mental toolbox as iteration, or recursion, then it's not good. If you think OOP was the overhyped IT fad of the nineties, then it's not bad.

    What I'm saying is that it has always seemed to me that C++ is not a very object-oriented language, and Stoustrup's remarks seem to me to confirm the objective validity of that observation.

  21. Which ADTs? by Chromodromic · · Score: 2, Interesting
    C++ has high aspirations in terms of giving the programmer complete control but ultimately fails due to the emergent complexity that results from the inability to fully encapsulate all of the design decisions.

    Come on. If you're talking about vectors, lists, sets, queues, stacks, hash_maps, etc., then I think the STL does, via templates, quite a stunning job of encapsulation. Stroustrup's comment in the article concerns wider adoption of the STL as a starting point for more developers, and I challenge straightforward applications developers to disagree with that. In reviewing others' code, I'm frequently surprised to see arrays being used where vectors or lists would suit as well and be safer, and frequently disappointed to see many functions implemented without templates where they could be effectively abstracted and made much more reusable (and refactorable, if that's a word) by using templates. Please tell me where vectors, as an example, fall short in the encapsulation goal.

    Where have other languages succeeded? Java provides a base int type and an Integer wrapper, and this is a fundamental data type. Is this success? I just think it's confusing. And what about operator overloading in Java? Yes for Strings but no for user types? I think operator overloading, in a dedicated OOP language of all things, is very important to encapsulation, but Java says "too dangerous"!

    Rubbish. And I'm not really meaning to pick on Java. My overall point is that on an application level there is a pie-in-the-sky goal that might be feasible in terms of encapsulation and that's what I believe we should strive for. But on a library or language level, saying C++ is at fault for not ensuring "perfect" encapsulation (and I'm not sure what that is) throughout the libraries is a little naive. Please point out the language that gets anything fully correct without sacrificing something else. I mean, isn't this why we have different languages for different things?

    Finally, I don't find that sentence insightful. Saying C++ is "without" safety is only illustrating a complete lack of familiarity with the STL. The programmer does have to keep track of things at times, but nothing even approaches real difficulty until you start creating your own ADTs. Mainstream types of the "Shape" or "Person" or "Animal" ilk are fine and dandy and really no more difficult or "dangerous" than Java or C#. It's not until you get into the implementation of things like "vertex_queue" or "parallel_list" that you, admittedly, start to get into much slower going territory. But there's also a lot of power there, too, power that's taken away in other languages, such as Java, because it's too "dangerous".

    --
    Chr0m0Dr0m!C
    1. Re:Which ADTs? by taradfong · · Score: 2, Insightful

      The fact that the average user can do nothing safely useful in C++ w/o STL further indicates to me that C++ is a wizard's tool. Fine. And it's a great tool for wizards who invested the time needed to truly use C++ properly.

      What I don't buy is propaganda stating that C++ can be a productive tool for non-experts if only you avoid pointers and use the STL. That's the Microsoft mentality: everything's ok if you stay on the beaten path.

      --
      Does it hurt to hear them lying? Was this the only world you had?
    2. Re:Which ADTs? by elflord · · Score: 2, Insightful
      What I don't buy is propaganda stating that C++ can be a productive tool for non-experts if only you avoid pointers and use the STL.

      What propoganda ? Who is saying this ? I haven't heard AT&T saying this, or Bjarne, or anyone else. You're fighting a straw man. If you want a productive tool for non-experts, forget C++, forget java, forget C, forget any compiled language. Non-experts will do much better with an interpreted language, and even if it's 200 times as slow, it will be worth it for the programmer time it saves.

  22. What is OOP? by exp(pi*sqrt(163)) · · Score: 2, Interesting

    If I write something like:

    class F {
    float a;
    public:
    F(float a0) : a(a0) { }
    template<class X> X operator()(X x) const { return X(a)+x; }
    }

    is it OOP? It looks like OOP: it has a member variable, a method, a constructor and so on. But actually I'm defining a function closure. In Haskell you coud write an F(a) object as (a+).

    My point is this: for many programmers today objects are often a(n awkward) vehicle for computing with closures. This has many payoffs: it gives the ease of functional programming but also potentially provides many performance benefits. I code like this all the time as do hundreds of others. This is how you need to code if you actually want to do anything non-trivial with the STL.

    So in some sense I'm an OOP programmer. But in another sense I'm not. I'm not writing my code this way because I want to work with objects - I do it because this is the only way I know to treat a polymorphic function as a first class object in C++. Really I'm a functional programmer forced to use C++. It seems to me that many of Bjarne's remarks are way off the mark for programmers like me. We have to define classes for every damn little thing!

    --
    Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
    1. Re:What is OOP? by exp(pi*sqrt(163)) · · Score: 3, Interesting
      It's just a partially evaluated polymorphic function. Construct one of these things thusly: F(2) and it can now be applied like a function to other objects so F(2)(4) returns 6. The fact that it's polymorphic is very useful because that same object can be applied to a quite different type, say an interval arithmetic type, so F(2)(Interval(1,3)) might return Interval(3,5).

      Why is this useful? I do a lot of numerical/engineering work. Say I have a root finding algorithm that throws a bunch of methods at a function in an attempt to find roots. It might first try doing some interval arithmetic to bound the roots and then when it's close enough go in for the kill with a newton solver. So I need to be able to write a polymorphic function that can be evaluated on the types appropriate to these methods (first intervals and then maybe doubles) but also be able to hand it in as an argument to a solver routine (which in this case would be rank-2 polymorphic though people will tell you C++ can't do that!). The above is the only way I know, And the cool thing is that It can also be a partially evaluated function (ie. in the simple example I gave I'm passing in the two argument function + but partially evaluating it by giving one of the arguments 'a'). This is all routine stuff in the functional world and is beginning to be routine in C++, but not yet. It's kinda object oriented but the object oriented frame of mind really is the wrong way to look at it.

      Greenspun's rule. Yes, someone said that about some code of mine recently. But I have a response. For one thing the primary function of Greenspun's rule is to provide strokes for Lisp programmers' egos but these are the wrong people! C++ is a typed language and Lisp isn't. This makes a big difference. These methods push C++ more towards typed functional languages like ML or Haskell. Secondly: The example I gave is of a closure, written as (a+) in Haskell. But look where the work is happening: I haven't written any kind of interpreter, the compiler's doing the work. In fact if you take this stuff to its logical conclusion you're not implementing a Lisp interpreter but instead twisting the C++ compiler into a Haskell compiler. And if you don't believe me, here is that logical conclusion. If you look closely very little of that code is executed at run time (the lazy lists are), instead that minor mountain of code is directives to the compiler telling it how to behave like a Haskell compiler.

      As for performance penalties: yup, they exist. It's the so-called abstraction penalty. I don't really understand why it exists because it takes only simple rewriting rules to eliminate the overhead but compiler writers don't use them. Luckily people like Veldhuizen are writing papers showing the compiler writers how they should be doing their job.

      --
      Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
  23. Read Stroustrup's Design and Evolution of C++ by ChaosDiscord · · Score: 3, Interesting

    If you hate C++, it's unfair to suggest you read a book on it. But if you have any fondess for C++, or use C++ (even if you dislike it), Design and Evolution of C++ is probably worth your time. You learn why C++ is the slightly confusing mess that it is, and why Stroustrup believes it's the only way it could have succeeded. Having a grasp on why C++ is C++ (and not Objective C or Java) can improve your C++ coding abilities. And understanding why behavior you don't like is there can at least help minimize the suffering ("This is stupid, but there really isn't any way to change it.").

  24. C++0x by Anonymous+Brave+Guy · · Score: 2, Informative
    'Read what he's written about the C++200x standards revision cycle.' OK, fair enough, you do have evidence. Got a link?

    I think perhaps there's a misunderstanding in the grandparent post. Stroustrup, and others on the standards committee, are on record as saying that they don't see the need for many language changes. They do, however, propose to make extensive library changes. Their reasoning is simply that there is likely to be more than one sensible way to approach topics such as, say, concurrency and synchronisation, and thus building them into the language itself is unduly limiting.

    If you go to Stroustrup's home page (sorry, don't have a link handy, but it'll easily Google) and then look for his comments on C++0x, I'm guessing the slides from his presentation describing the above are still available.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  25. Re:"memory allocation problem" by Godeke · · Score: 2, Insightful

    True, you can fail to release resources, but in many cases it is handled for you in garbage collected languages by scope. That transparent handling probably is a big source of problems for those unaware of the problems of holding on to references beyond the scope necessary, but what I was refering to was the fact that I can't easily set a pointer up that points to incorrect memory locations and causes a subtle, usually non repeatable, near impossible to find bugs. Granted, tools like bounds checking software can help, but if I take a pointer to an object and then allocate some other objects and release a few, in C or C++ I can easily clobber my earlier object, causing modifications to it to do nearly random changes to other objects. Especially if you have a couple levels of indirection going. Maybe I just suck, but I have blown past the ends of arrays of more times than I probably should admit.

    --
    Sig under construction since 1998.
  26. C++ is too simple. by rice_burners_suck · · Score: 2, Funny
    improving the style of C++ programming

    What C++ really needs is more features... LOTS more features. The language is not "rich" enough. C++ should add many other features to its syntax.

    • For example, the ability to name identifiers with any character in any character set.
    • As C++ is not complicated enough, we need a way to dynamically create syntax. It would work like operator overloading, but much more complicated. And it would be called Syntax Overloading. For example, the code, ("for (" class "in" class ")")() { [insert code here] } would allow you to specify a new type of for loop with your own syntax. The compiler, upon reading this line, would add the new syntax to its language rules. Then, you could type for (className in otherClassName) { some.code.here(); } and it would work as expected.
    • The language desperately needs some built-in cryptography functions. For example, the function const unsigned void do_it(const unsigned short void const crypto % arg) takes one parameter, arg, which is encrypted inside a processor register and cannot enter main memory for security reasons.
    • More complicated template syntax is needed. For example, suppose you want to create a class that is unknown at compile time... obviously, a way to specify runtime template processing is desperately needed.
    • Support for returning multiple return values from a function. For example, the function const unsigned short, const int *, const long long grok_the_file(void) might return three different return values, seperated by commas, as in, return i, j, size; Oh yeah, and you could specify functions that return an unknown number of values using ellipses, as in unsigned short... function_name() or simply ... function_name(). Suppose you want to call a funciton that takes 3 parameters... you could instead pass it one function that returns 3 return values and C++ would know what to do with it.
    • C++ needs a reserved word, like please_reconsider_cast, or something, that uses common sense to figure out what the heck you're trying to typecast into what, so that even if the code is faulty, the compiler will figure out what you really mean.
    These are all just a drop in the bucket. C++ is obviously too small and simple of a language.
  27. Re:source code by X · · Score: 2, Informative

    I develop in both C++ and Java, and while I like both, it's pretty obvious to me that particularly for Junior and Intermediate level developers, Java development is significantly faster. Java's execution model also makes it much easier to design, implement and use frameworks and libraries. This in terms leads to faster development as well.

    While for certain types of problems (for example anything requiring unsigned arithmetic), it's very difficult for Java to outperform C, in other cases I've seen computationally intensive Java code that was written in a few days get within 10-20% of the execution speed of C code that was written in a month (and this was prior to JDK 1.4). That level of performance difference, particularly with reduced development times (which give you more time to improve the efficiency of the overall design) makes Java a worthwhile candidate for a large chunk of the projects out there.

    The sad truth is, a lot of C++ programmers are *not* at the skill level Bjarne is talking about. If even most C++ programmers were at that level, you'd suddenly find that C++ is a far better language to work with. Until programmers reach that level, it is a needlessly complex language which provides few useful advantages over it's competitors.

    --
    sigs are a waste of space
  28. magic programmer education by pyrrho · · Score: 2, Insightful

    I think you make an interesting point about a lot of this depending on the quality of C++ programmer, and I would extend that to admit that there are certain level of programmer that will always need a simplified environment, and that's fine.

    But for professional developers, wouldn't it be best if we just focussed on making he best tools and educating our industry to use them properly?

    I mean, if you look, there are a lot of tools of convienience in the hardware store that professional builders don't use. You can duct tape something and it's good to go, but that's not what you train engineers... though they might use duct tape in a pinch.

    I think you might be onto something about Java for newer programmers. I already have learned about all the things Java is to save me from, like the ins and outs of memory management, so I don't notice an speed up when I code in Java. The kinds of bugs I have to hunt in my stuff is not particularly addressed, and can't really by, by any language.

    If a java program was written in a couple days, and the C equiv in a month... that implies something. There is not that much difference in the language. That sounds like library availability, the C programmer had to write something that was already available in Java, which begs the question... was there a good library available they didn't know about and could they have used C++. The 10% would still make it a better tool and worthwhile.

    But where we really will probably have to agree to disagree is just on the "needless complexity" issue. That needless complexity is C++ giving you more than you need --- so you can decide what you need and have a wide range of paradigms under which you can code. That is C++ not trying to second guess for you. If C++ give an automagical solution, it also give no-solution so you can build your own automagic. If you don't like cout, there is still printf and if you don't like exceptions, it's up to you and your Coding Standards to decide is you have to use them.

    It's that old choice vs. chaos. Personally, I can handle the chaos of choice.

    --

    -pyrrho

    1. Re:magic programmer education by X · · Score: 2, Interesting

      It wasn't a library that really saved the Java project so much time. Indeed, because of performance considerations, the standard Java collection classes weren't used. No, the faster development time came from the fact that the C code had to deal with a lot of ownership and synchronization issues, much of which is quite error prone in C. Java's runtime simplifies these issues (and amazingly does it in a way that tends to be faster than what C can do without a LOT of work) such that you don't waste a lot of time on them.

      The complexity doesn't just stem from having choices. It's from exposing problems to the programmer that they fundamentally don't understand yet. Dealing with templates in a world where you don't understand generic programming is going to do more harm than good. Dealing with exceptions in a world where you don't understand RAI. Dealing with multithreading in a world where you don't understand how the C++ memory model doesn't grok threads. I could go on.

      I've interviewed "senior" programmers a fair bit, and I'm invariably struck by how many of them (basically all) can't do something as simple as a thread-safe getter/setter in C++, but even the more junior programmers can get it right in Java on the first try. These are the kind of mistakes that literally steal weeks of productivity.

      Sure, you can simply not use all those features, as a lot of C++ programmers do, but the end result is a crippled language that has most of the disadvantages of Java, without any significant advantages over C or Java. This is exactly the scenario where C++ turns out to be a poor choice.

      I think rather than hardware store metaphor, I'd suggest something along the lines of mountain climbing. Free climbing is the "cool" thing to do, and it has certain advantages over the "safer" approach, however the vast majority of folks out there shouldn't do it, as sooner or later it will do more harm than good.

      --
      sigs are a waste of space