Slashdot Mirror


Stroustrup Says C++ Education Needs To Improve

simoniker writes "Over at Dr. Dobb's, C++ creator Bjarne Stroustrup has given an in-depth interview dealing with, among other things, the upcoming C++0x programming standard, as well as his views on the past and future of C++. He comments in particular on some of the difficulties in educating people on C++: 'In the early days of C++, I worried a lot about "not being able to teach teachers fast enough." I had reason to worry because much of the obvious poor use of C++ can be traced to fundamental misunderstandings among educators. I obviously failed to articulate my ideals and principles sufficiently.' Stroustrup also notes, 'Given that the problems are not restricted to C++, I'm not alone in that. As far as I can see, every large programming community suffers, so the problem is one of scale.' We've discussed Stroustrup's views on C++ in the past."

567 comments

  1. I'm just glad they're teaching C++ actively again. by Anonymous Coward · · Score: 2, Interesting

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

    One semester later I dropped out and never looked back to computer science again as a career choice. In fact, though I bounced around between community colleges for a few years after, I never finished school.

    Let me restate this: I'm just glad they're teaching C++ actively again. I wouldn't wish my experience on anyone.

  2. I completely agree by betterunixthanunix · · Score: 4, Insightful

    I completely agree with Stroustrup. Too many people these days have little or no exposure to C++, and never learn how programming in the absence of garbage collection works. It is especially problematic in our research labs, where computationally complex problems must be solved with very fast code, but the people writing it get completely confused by pointers and memory management. Worse is when a proof-of-concept is distributed, with horrible bugs and completely incomprehensible code.

    --
    Palm trees and 8
    1. Re:I completely agree by schmidt349 · · Score: 4, Interesting

      Yeah, but that doesn't sound like the sort of problem that gets fixed by learning C++, which has a nasty habit of adding loads of complexity in all the wrong places. If you want tight, fast code and your project doesn't need OOP, use C.

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

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

      In short, novice programmers are not going to learn anything useful if you use C++ as the prescriptive model for how a well-written computer program should look -- they're just going to hit the bottle earlier in life.

    2. Re:I completely agree by CRCulver · · Score: 1

      Too many people these days have little or no exposure to C++...

      That might be because it is rare to learn C++ outside of an organized course, and if you don't get such a thing in school, it's hard to do it on your own later. O'Reilly apparently publishes a self-teaching book called Practical C++ programming , but it's not widely distributed compared to their interpreted language offerings. Every other C++ introduction I encounter seems to be designed for use in schools, not for autodidacts.

      ...and never learn how programming in the absence of garbage collection works.

      Now, that I must disagree with. Isn't C still part of a basic university computer science education? My formal training in programming is two semesters as an undergraduate, but C was a key part of both.

    3. Re:I completely agree by lexarius · · Score: 3, Insightful

      Agreed. Also emphasize that, while Python is not as efficient as compiled languages, you can come back later and rewrite important parts of it in C. Then you can teach C with an emphasis on high-performance computing, rather than the typical "here's how we ask for user input, here's how we copy strings" emphasis typically taught in C courses that I've seen. Eventually, you could then show them how to add in assembly code to get at special-purpose processor operations not exposed by C. Probably do this over the course of a few semesters though.

      Hell, who am I kidding. Just teach them to code in brainfuck. Or maybe INTERCAL. Normal languages will seem much nicer after that.

    4. Re:I completely agree by bsane · · Score: 4, Informative

      The O'Reilly books are an example of the problem here.... their C++ books are the worst O'Reilly books I've ever read. It wasn't until I picked up 'The C++ Programming Language' by Strousup that I realized my mistakes and what C++ was really capable of.

      I agree with the premise that C++ is a great language, that is poorly understood, and often mis-used. Education would seem to be the answer to that.

    5. Re:I completely agree by Midnight+Thunder · · Score: 1

      I completely agree with Stroustrup.

      I agree and I point the finger (I have to blame someone don't I?) at architects who don't understand what computer code is. Have you ever been presented the next amazing design for a solution and thinking, "am I a magician or a software developer?". If an architect has had some contact with code then the solutions tend to be a little more realistic. ;)

      --
      Jumpstart the tartan drive.
    6. Re:I completely agree by gbjbaanb · · Score: 3, Insightful

      I agree too, to quote TFA: "Conversely, there is now a generation who is firmly convinced that a program is only well-designed if just about everything is part of a class hierarchy and just about every decision is delayed to run-time."

      I'm not sure if the problem is bad education or the lazy coders who expect everything to be easy (ie done for them) so they don't have to really think about what they're doing.

      Even MS's clever chaps have this problem - "lets have C# and GC so no-one need think about memeory ever again" they cried. Then they realised that objects are more than just memory so you do have to worry about destruction of the non-memory resources held by an object (eg file handle, etc). Then they realised they were getting problems writing code that interacted with the OS, so they introduced reference counting objects that they could put in their "deterministic" finalisation objects that they could put in their Garbage-collected objects.

    7. Re:I completely agree by itsdapead · · Score: 1

      As for programming pedagogy, I think we'd do a lot better if the faculty of CS departments would migrate away from using Java/C++ as the introductory programming model because so much of what gets said initially just goes in one ear and out the other.

      Even better would be if they didn't get involved in ideological wars about languages, and focussed on the *concepts* they wanted to teach. If students really are coming out of these courses with certificates saying "computer science" which should read "Java forms design for data centers" then arguing the merits of Java,Lisp,C++ or Son Of The Return of the Bride of BASIC isn't going to fix anything. If you're gonna call the course "Computer Science" then students should come out knowing a decent wodge of mathematical theory and having some experience of half-a-dozen diverse languages, plus assembly and microcode. Of course, there are plenty of jobs that don't need that level of knowledge - but in that case the candidates don't need CS degrees.

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

      --
      In a survey of 100 programmers, 111111 thought that duck-typing was a good idea.
    8. Re:I completely agree by thelima · · Score: 1

      Too many people these days have little or no exposure to C++

      Uhm... nowadays too many people have little or even no exposure to math and
      actually nobody cares...

      Having developing for Years in C++, and having learned
      OO in C++, obvoiusly being trapped by most ugly C++ traps I actually am against
      teaching C++ as something other than highly specialized course in University. Sure one
      can teach C++, but definitely C++ should be put to the Ancient Languages Cathedral
      together with COBOL, ALGOL, PL/I, FORTRAN, MODULA etc ideally within the Faculty of Historic Sciences...

      lima

    9. Re:I completely agree by mcvos · · Score: 1

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

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

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

      Sounds like they chose the wrong language for the job. Computationally complex research problems and proofs of concept shouldn't be written in a language that requires manual memory management. Often, functional languages (Lisp, Haskell) are best for that sort of thing.

    10. Re:I completely agree by mcvos · · Score: 1

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

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

    11. Re:I completely agree by roman_mir · · Score: 1

      It wasn't until I picked up 'The C++ Programming Language' by Strousup that I realized my mistakes and what C++ was really capable of. - And if you pickup a similarly named book by this guy, named Stroustrup, your previous realizations will be dwarfed by the new set of information ;)

    12. Re:I completely agree by bondsbw · · Score: 1

      Learn the tool that suites your needs best.

      I'm all for learning programming languages as a general discipline, but I don't see any reason to learn all the ins and outs of something as complex as C++. It is a language that tries to be everything for everyone, but it completely misses when it comes to understandability. More pure languages often sacrifice the "all-in-one" role in order to be something that promotes maintainability. And if they aren't good for your situation, use something else.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    13. Re:I completely agree by Anonymous Coward · · Score: 0

      Indeed. In fact, the O'Reilly books tend to screw up a lot of minds, specially if they are read without any other source of information to straighten the ideas. For example, the pthreads book and virtually all perl books are a royal brainfuck that bring less value than quite a few online references. On the other hand, other works like the xlib books tend to be nice.

    14. Re:I completely agree by 0xC0FFEE · · Score: 1
      Stroustrup's book has passed the test of time. It's the only C++ book I own and I can say (without modesty) that I'm a fairly proficient C++ programmer. The book is the right mix of examples and is a very adequate reference.

      I come from a scientific/engineering background and generally, when you truly want to understand and get the scope of something, going to the initial author or visionary helps a lot. Not only is their explanation simpler and more consistent than later development, it stays relevant as time goes. Especially when it comes to software engineering, one of the major problem to be solved is one of trying to simplify and generalize. So anything that isn't achieving that has probably failed.

      I think C++ is simple enough and powerful enough for most needs. There are some quirks, but the language itself is sound and manageable. Most of the problems generally show up with libraries, they generally don't help to solve a problem (at all). While it may be different for other languages, it certainly isn't for C++ and once you remove libraries from your considerations, C++ becomes a very neat way of expressing solutions. It could be more concise, it could be even more generic, but I think a fair balance as been reached. Now if we could just have some half decent refactoring tools, that would be far more useful than this c++1x crap. Yes it's c++1x, I certainly remember how long it took compiler writers to get templates working right.

    15. Re:I completely agree by ciggieposeur · · Score: 0

      C++ is for operating systems and drivers, and was never intended for application programming.

      It is a systems language, but that does not mean only the kernel and drivers. I would pity the kernel implementor who had to have both stack unwinding and exception behavior work correctly on current hardware. If anyone has succeeded at that, more power to them. Apple and IBM's joint effort (Taligent / Pink) failed miserably.

      I think C++ is really intended to be a language that can provide (most of) the syntactical constructs available in a Lisp-like language but with the ability to both go all the way down to the metal and heavily optimize up-front to get mostly good speeds without requiring a VM+JIT environment. For the stuff I need to really go fast and still be flexible with future rewrites, I use C++. But for research code or proof of concept (as you mention), I would use something else first.

    16. Re:I completely agree by laffer1 · · Score: 2, Insightful

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

      I am not alone in my opinion. Consider the difference in rank on amazon. Many third party C++ books have better ratings. In fact, I'd argue C++ is such a large language that one needs more than one book to provide adequate information. I don't think The C++ Programming language should be anyone's first book on C++, but it could be an extra backup reference.

      As for the O'reilly book, I agree it is not complete but there are a few useful items for reference. Absolute C++ is a better book. Even the deitel C++ how to program book is better and I don't think much of deitel books after having to use three as text books.

    17. Re:I completely agree by mcvos · · Score: 1

      It is a systems language, but that does not mean only the kernel and drivers.

      I didn't mean just those. Virtual machines, high performance libraries and stuff like that also make excellent C++ projects. Anything that forms a layer between the high-level programming language is which applications are written, and the low-level stuff. Anything that requires high performance and that will be reused often enough, and rewritten little enough that you can afford to put up with the complexities of the language.

    18. Re:I completely agree by rolfwind · · Score: 1

      or hell, if you teach them Lisp they'll be horribly screwed up for the rest of their lives but at least they'll understand how registers and OOP work.


      I disagree. C/C++ were my first languages. Lisp, I learned later after reading a few Paul Graham essays.

      But it is a wonderful language. The people who complain about the notation must have never tried it or are really dense. It's generally a simple language to learn (moreso if you use the scheme variant, there's also dylan) to get things done.

      Plus the REPL (read-eval-print-loop) allows instant feedback unlike the C/C++ variants and later breed. It is also a typeless language (allowing for types but not necessary).

      I have seen in that and other aspects for students to be able to concentrate on learning the finer points of programming (algorithms, etc) by being able to get real programs working early on rather than being bogged down in the minutae of many C-style languages.
    19. Re:I completely agree by Anonymous+Brave+Guy · · Score: 1

      Isn't C still part of a basic university computer science education?

      Sadly, no. Even in the better universities, it is often covered only briefly, and it's just expected that any self-respecting CS student will learn it. Of course, while any self-respecting CS student should be gaining exposure to a variety of programming languages and tools, part of the point of the formal academic course is to introduce those students to the ideas they need to be able to do this, which is why I think the courses should include some reasonably deep instruction in example languages of various types before assuming the students will go broaden their horizons independently. If the courses won't do that, what are they actually teaching that someone couldn't just learn on their own?

      IMHO, C actually has far more place in such courses than C++, which while a useful practical language isn't really an optimal example of anything for teaching purposes (apart from perhaps how to combine different programming ideas to produce a practical language).

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    20. Re:I completely agree by Anonymous Coward · · Score: 0

      Yes C++ is a powerful language, but it's one thing for Stroustrup to say that, and a completely different thing for him to teach. I go to Texas A&M university where he modified a freshman course to C++ programming. He even wrote a book for it that is really really hard to understand if you have never programmed before. I found it easier to read code and learn that way than to read that god forsaken book.

    21. Re:I completely agree by orlanz · · Score: 1

      ...maintainable application programming is much easier and faster with a higher level language.

      This is what I think most "programmers," "managers," and clients/customers don't seem to get AT ALL. They want something _now_ that isn't anywhere close to well defined, and needs to be flexible in design so crap can be piled on it with little issue.

      The question is always "How much will it cost to build this?" not "How much will this cost me?" Thou they always ask the later when they actually mean the former. And the "consulting" (a word that has lost so much meaning) industry is set up to say the cost is half of what it really is and the gold standard is to have overruns. I never understood this from a project management stand point (you are ignoring the unknowns and just making that area look good). It looks great on paper, but at the end of the day, they end up completing based on sunk costs (another mistake of project management).

    22. Re:I completely agree by itsdapead · · Score: 1

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

      Ah. I should have put in the corollary there:

      Real Programmers can write FORTRAN programs in any language... :-)

      No language can magically force people to write well-documented, well-organized code if they can't, won't or are under pressure to lash up something that works for the presentation tomor... oh, shit! today...

      /* My coding standards say to put a comment here: this is it! */
      --
      In a survey of 100 programmers, 111111 thought that duck-typing was a good idea.
    23. Re:I completely agree by jgrahn · · Score: 1

      I'm going to have to disagree. The C++ Programming Language is useless to actually learn the language and often times it fails as a reference. If all the ego was removed from the book, it might be useful for something. Compare it to K&R. You'll notice a difference in tone. [---] I am not alone in my opinion.

      The ego? Where did that come from? Stroustrup likes C++; does that show in the book, and does that irritate people who have decided to dislike the language? That's the only reason for your statement I can honestly come up with.

      I agree (grudgingly) that the book is probably not the best tutorial, or even the best reference (for beginners, experienced programmers, or experienced C programmers). It can be very brief when describing something which has huge consequences. Still, I learned modern C++ from it -- that book, and the good people in comp.lang.c++.moderated.

      I also have to point out that the chapters on development and design in general are the best I have read in any book -- obviously drawn from many painful software project experiences.

    24. Re:I completely agree by zippthorne · · Score: 1

      And yet, every application I have that was written in Java is slow and buggy compared to its typical c-programmed counterpart. And yes, I'm including OO.org in that list. What's the deal with that?

      --
      Can you be Even More Awesome?!
    25. Re:I completely agree by Anonymous Coward · · Score: 0

      Indeed! Similarly, there's so many people these days who just drive cars all the time without knowing how to properly guide a horse-drawn carriage (particularly, the horses).

    26. Re:I completely agree by harlows_monkeys · · Score: 1

      If you want tight, fast code and your project doesn't need OOP, use C

      C++ doesn't require you to do OOP. If you want tight, fast code, still use C++, but just use it like C with a couple of nice enhancements (constructors and destructors on structs, std::string, exceptions, and STL), and you'll get code that is just as good as your C code, but clearer, and more likely correct.

    27. Re:I completely agree by Anonymous Coward · · Score: 0

      I've seen wave after wave of language bandwagon roll by over the past 25 years. OOP was a pretty big bandwagon, but I and every professional to-the-metal network software, graphics software, and device driver coder I know is essentially coding in C, not C++. (You still find C++ environments around where it's all C code in C++ wrappers here and there, but it's C in there). It's okay to let C++ fade away.

    28. Re:I completely agree by mcvos · · Score: 1

      And yet, every application I have that was written in Java is slow and buggy compared to its typical c-programmed counterpart. And yes, I'm including OO.org in that list. What's the deal with that?

      I don't know which applications you have, or even which applications that I have are written in C, but I know of a lot of excellent and responsive Java applications. Although Java is a lot bigger on the (web)server than on the client side. Swing is probably to blame.

    29. Re:I completely agree by Glock27 · · Score: 1
      I completely agree with Stroustrup.

      First sign of a problem... ;-)

      Too many people these days have little or no exposure to C++, and never learn how programming in the absence of garbage collection works. It is especially problematic in our research labs, where computationally complex problems must be solved with very fast code, but the people writing it get completely confused by pointers and memory management. Worse is when a proof-of-concept is distributed, with horrible bugs and completely incomprehensible code.

      The problem is you have people (probably engineers or scientists) programming in C++. Time to reinvent FORTRAN (he says sarcastically).

      Hint: People programming mathematical algorithms should be insulated from memory management and the underlying computer architecture.

      --
      Galileo: "The Earth revolves around the Sun!"
      Score: -1 100% Flamebait
    30. Re:I completely agree by icebike · · Score: 1

      The fault lies not with the teachers or the students. It lies with C++ itself.

      The language is an abomination, with over 65 different data types (beyond all need and reason) each capable of being abused in at least 7 different unique and novel ways.

      Its a disaster waiting to happen, and there are precious few tools that are capable of finding abuse of best practices, let alone common sense (which proves to be not that common in practice).

      There is simply no need for this many data types.

      Further the structures commonly constructed in the syntax are not at all humanly intuitive nor necessary for the task at hand.

      --
      Sig Battery depleted. Reverting to safe mode.
    31. Re:I completely agree by UnknownSoldier · · Score: 1

      There is no reason to still use C nowadays. Everything you can do in C, you can in C++, plus you get better type safety for free. Using archaic languages from the 70's ignores all positive changes since then.

    32. Re:I completely agree by try_anything · · Score: 1

      Stroustrup's book has passed the test of time. It's the only C++ book I own and I can say (without modesty) that I'm a fairly proficient C++ programmer. The book is the right mix of examples and is a very adequate reference.
      Amen. Stroustrup is a brilliant writer and teacher. I didn't realize until much later how lucky I was to have learned C++ from TC++PL instead of from any other C++ book. He teaches the language semantics, the reasons for the language design, what C++ is good for, its shortcomings, and the ideology necessary for using it effectively. He does all of this in a way that made perfect sense to me as a programming neophyte and is still intellectually satisfying to me ten years later as a professional programmer who also does Java, Common Lisp, Python, and Scala.

      I particularly like the way Stroustrup teaches the ideology of C++. Most people approach ideology in absolute terms. Either ideologies themselves are evil, or a person has a single ideology which is either correct or evil. Stroustrup teaches the ideology of C++ in a neutral way. C++ is designed to implement programs that are conceived of according to a particular ideology, and if you think in this way you will get the most out of C++. The entire text of TC++PL is dedicated to communicating the C++ ideology, while at the same time making it clear that C++ strives to be agnostic about certain things as well. Of course, you need to be capable of thinking in other ways (or else you are a very limited person), but if you find yourself thinking in a way that is inimicable to C++ while programming in C++, you need to be careful, because C++ may work against you.

      This is a very refreshing approach to the ideology of a programming language. Other programming language books are either ridiculously namby-pamby about ideology or attempt to indoctrinate you into a single way of thinking. Stroustrup offers C++ and its ideology without claiming supremacy for it but without apologizing for it either. TC++PL was my first and deepest influence as a programmer, and it taught me (by example) that I should strive to get as much power and insight as possible out of every language I encounter, from Java to Haskell. Stroustrup is completely the opposite of the intellectually sclerotic partisans who bash their own teeth out with a hammer and then scream, "See? See? This is why you should never touch anything but a toothbrush."

    33. Re:I completely agree by Paiev · · Score: 1

      Education is not the answer when you have someone teaching you that doesn't know what they're talking about. I have a C++ teacher who told us that negative numbers were evaluated to false; I, who already knew C++ pretty well, told him that they were true. He went over to his laptop, typed something up, and then looked back up at me and told me to "throw out whatever book you're using, because it's garbage." I was a bit suspicious, so I checked the standard and it agrees with me, unsurprisingly. The next time the topic came up I corrected him again. He showed us the code he had written the first time:
      int a;
      if (a == -1)
              cout << "True";
      cout << "False";

      That's supposed to check if negative numbers evaluate to true. If you know C++ you should be cringing right about now.

    34. Re:I completely agree by Anonymous Coward · · Score: 0

      Obviously that was just an example. If he wanted to check for all negative numbers he'd have to write over 32,000 "if" statements, and there just isn't time to do production-quality software engineering like that during a lecture.

    35. Re:I completely agree by master_p · · Score: 1

      But garbage collection is faster than manual memory management, especially for computationally complex problems: the least you want is to pay the price for the allocation/free algorithms while your computation needs all the available cycles!

      I don't know why you where modded insightful, but your comment is totally wrong, just like Stroustrup is.

      First of all, the new move semantics bolted onto the new C++ will be a complete disaster for most programmers, just like auto_ptr was. The only reason move semantics exist is because there is no garbage collection.

      Secondly, garbage collection is FASTER (repeat, FASTER) than manual memory management! If you have ever done any tests, Java blows C++ out of the water in memory management tests.

      Thirdly, the problem of horrible bugs and completely incomprehensible code is due to C++'s complexity, which is the result of bad language design, and the lack of garbage collection, in particular.

      Since you are doing computationally intensive complex problems (I suspect of mathematical nature, isn't it so?), you might want to try Haskell. You'll be surprised on how easy it is, since it's actually executable math.

    36. Re:I completely agree by betterunixthanunix · · Score: 1
      I suppose what I wrote wasn't completely clear, but I didn't mean to say that garbage collection was slowing things down. What I meant was that the slowdowns occurred because of things like dynamic typing in Python, the requirement for all objects, even short lived local objects, to be on the heap, the increased complexity of function calls in languages where functions are objects, array bounds checking, etc. The specific project I had in mind involved high-resolution volumetric graphics, on the order of 60000 data objects that needed to be processed. We needed to balance portability with performance. Python, Haskell, Java, etc. would not have been able to meet the performance requirements; the overhead from their various features, especially the way arrays are handled, would have killed us.

      C++ struck the balance we needed. We could have primitive arrays and function calls, objects on the stack, etc., and also be able to run our code on Windows, Linux, or whatever (remember, we had to distribute this to others). It was embarrassing that, under certain circumstances, we had crashes (for example, if the user hit "cancel" instead of opening a model), but the solution is not moving to another language, it is having a team that knows how to program in C++. The main problem, at least in the bugs that I saw, was that people were not familiar with pointers -- assuming, for example, that an uninitialized pointer would have NULL as its value. I trace the problem to a decision by the university to teach introductory CS courses in Python.

      Lest I be accused of being a C++ fanboy, I'll say that I like the idea behind Haskell, and even more being Prolog, especially since I advocate for formal methods. I also like some of the ideas in Ada, especially the strong typing and the numeric range stuff. However, when it comes to dealing with enormous datasets and complicated algorithms that involve a lot of array operations and recursion, I lean towards a language that lets me do dangerous but fast things. Finally, there is the problem of dealing with other people, who may not know obscure languages like Haskell (sorry, but it just isn't mainstream enough for me to assume that the people in that lab would be able to use it).

      --
      Palm trees and 8
    37. Re:I completely agree by xhrit · · Score: 1

      >If you want tight, fast code and your project doesn't need OOP, use C.

      Just use c++ as a better c. You don't have to write everything in oop.

    38. Re:I completely agree by JoshJ · · Score: 1

      I coded a Brainfuck *interpreter* in an assembly language for one of my classes this semester. Not bragging (it really wasn't that hard) but just throwing that out there.

  3. Not another I/O Rewrite please! by Anonymous Coward · · Score: 1, Informative

    Last time Bjarne changed C++, he broke the I/O libraries which gave many of us the thrill of having to go back through old code and rewrite it for no other reason that Bjarne wanted to change something. We got no value out of the changes. They just wasted a lot of people's time.

    Bjarne: C++ should evolve, but there's a mass of C++ code already out there. Improve it please, but don't make us go back and rewrite existing code.

  4. Maybe the real problem... by bfwebster · · Score: 3, Insightful

    ...is that C++ is a rather complex and brittle language. :-) ..bruce..

    P.S. Feel free to flame away at me, but not only have I developed professionally in C++, I've actually rescued a C++ project by (among other things) drafting C++ coding standards and guidelines for the 30 or so developers working on it.

    --
    Bruce F. Webster (brucefwebster.com)
    1. Re:Maybe the real problem... by mathimus1863 · · Score: 2, Interesting

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

      It reminds me of this: http://thedailywtf.com/Articles/It-Had-Too-Many-Functions.aspx

    2. Re:Maybe the real problem... by Stochastism · · Score: 1

      Languages don't kill programs,
      programmers do ;)

      But I tend to agree that C++ is the kitchen sink of languages, and this leads to confusion. I'm sure even B.S. has shaken his head in appalled wonder at some of the things people have done with expression templates and the such.

    3. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

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

      Lower level language... Fuck Off!


      If we want a low level language (typically for performance) we can use asm or C. If we want a high level language and we established performance doesn't matter, we use Java or dynamic languages. For the niche space inbetween and given the opportunity to use ObjC, Vala, or C++ for application programming, C++ would be bottom of the list.


      C++ is effectively dead, take a hint from the COBOL guys ;-)

    4. Re:Maybe the real problem... by ubernostrum · · Score: 5, Insightful

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

      ...and several previous generations of programmes roll over in their graves at the thought that C++ is a "lower-level language".

      The thing is, C++ is huge. Just to have a solid working knowledge of the core language, you need to master whole rafts of things that have nothing whatsoever to do with the low-level operation of the machine, because even the core is a labyrinth of obscure corner cases that make language lawyers drool, and which, if expressed in pseudo-code, would be a bunch of gigantic switch statements with a couple dozen levels of ifs nested inside each case. Now, add the STL on top of that, and add common third-party bits like Boost on top of that, and you're left with a monstrosity. To really understand programming at a lower level, you need at best only a small subset of C++, and unfortunately for C++ that subset is properly called "C".

    5. Re:Maybe the real problem... by Anonymous Coward · · Score: 1, Interesting

      Bruce, you're absolutely right.

      One only has to take a look at issues like const correctness and all the different ways one needs to declare "constness" in or out of the presence of pointers and reference variables to realize that Stroustrop gave birth to a monster that should have been aborted.

      I've developed in C++ for 20 years now, and I've developed in SmallTalk, Common Lisp Object System, and Java.

      Stroustroup should be embarrassed. C++ is complete shit and just gets shittier.

      Anonymous Coward because I am currently involved in working a massive C++ system for the Army consisting of probably 200 developers -- and it's complete shit -- not because the developers are stupid and not because the Army is stupid and not because 200 developers is too many -- but because C++ is complete shit and a house is only as good as its foundation.

    6. Re:Maybe the real problem... by wrook · · Score: 2, Insightful

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

      C++ is also complex in and of itself, but there are good reasons for almost every piece of complexity in the language. Though severely dated the ARM is still a useful place to learn why the language is like it is. Despite it's complexity, I still think C++ is a very handy tool to have in my toolchest for certain types of problems. However I find myself turning to it less and less over the years.

    7. Re:Maybe the real problem... by jellomizer · · Score: 3, Interesting

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

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

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

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

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    8. Re:Maybe the real problem... by JamesP · · Score: 1

      I second that, absolutely.

      Up to a point, C++ is a breeze. And then it falls. Hard.

      Templates are a great idea, but guess what: strong typing makes it almost useless!! Yes, you can create thousands of different collection types with it, for pretty much everything, but it could be so much more powerful.

      Or you build your 'generic thing' for a superclass, which is not generic at all.

      Or you go down the 'template specialization'... not pretty.

      And then you spend hours and hours trying to get a problem to get into C++ model when it would have already been solved if it was in whatever (other) language. Oh, I see, it wouldn't be OO then - except for Java (rolls eyes)

      --
      how long until /. fixes commenting on Chrome?
    9. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

      I think you're confusing C++ with Java/C#.

    10. Re:Maybe the real problem... by shutdown+-p+now · · Score: 2, Insightful

      The thing is, C++ is huge. Just to have a solid working knowledge of the core language, you need to master whole rafts of things that have nothing whatsoever to do with the low-level operation of the machine, because even the core is a labyrinth of obscure corner cases that make language lawyers drool, and which, if expressed in pseudo-code, would be a bunch of gigantic switch statements with a couple dozen levels of ifs nested inside each case.
      Absolutely. This is fairly easy to check, too; here's the most recent draft for C++0x, and it's already 1200+ pages! And they haven't even included everything they want to get there yet (such as concepts, which alone will add a lot more; a full list of what's not yet there, but is going to be, can be seen here). Now, how do you think, how many developers are going to understand it well enough?
    11. Re:Maybe the real problem... by Profane+MuthaFucka · · Score: 2, Insightful

      Mostrosity? Have you looked at java.com lately? That website is a tangle of twisty little API's, all alike.

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    12. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

      I am currently involved in working a massive C++ system for the Army consisting of probably 200 developers -- and it's complete shit

      You too? Is that you, Scott?

    13. Re:Maybe the real problem... by JamesP · · Score: 1

      Not really, but the problem is pretty much the same in Java / C# (its worse in Java, though)

      --
      how long until /. fixes commenting on Chrome?
    14. Re:Maybe the real problem... by Epistax · · Score: 1

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

      ...and several previous generations of programmes roll over in their graves at the thought that C++ is a "lower-level language".

      The thing is, C++ is huge. Just to have a solid working knowledge of the core language, you need to master whole rafts of things that have nothing whatsoever to do with the low-level operation of the machine, because even the core is a labyrinth of obscure corner cases that make language lawyers drool, and which, if expressed in pseudo-code, would be a bunch of gigantic switch statements with a couple dozen levels of ifs nested inside each case. Now, add the STL on top of that, and add common third-party bits like Boost on top of that, and you're left with a monstrosity. To really understand programming at a lower level, you need at best only a small subset of C++, and unfortunately for C++ that subset is properly called "C".

      The way that I see it, C++ isn't really higher level than C. C code is one jump from assembly. Raw assembly can be put into C/C++ at the will of the programmer. Directives can also be put in by the programmer that influence the assembly that gets generated. If you don't understand assembly, you really can't do C/C++ well. Therefore, it's a low level language. Compare this to say, Visual Basic, where I haven't the foggiest idea how things get turned into assembly. I haven't seen any evidence that knowing will help.

      To me, C++ isn't STL. C++ is polymorphism. Vtables. C++ is multi-inheritance from interfaces (classes containing only pure virtual functions). C++ allows the user to program their class members functions in C, or use extensions to the C language.

      That's just how I like to look at it. Not trying to be iron clad, just throwing some stuff out there.
    15. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

      C++ is also complex in and of itself, but there are good reasons for almost every piece of complexity in the language.
      Good design is achieved, not when there is nothing left to add, but when there is nothing left to take away.

      There are languages out there which are both vastly more powerful and vastly less complicated than C++. Each individual piece of complexity may be required, but the aggregate is an insanely overdesigned mess.
    16. Re:Maybe the real problem... by mollymoo · · Score: 3, Interesting

      There's a big difference between a sprawling standard library and a sprawling language definition.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    17. Re:Maybe the real problem... by LizardKing · · Score: 1

      If you actually compare the Java programming language to C++ (in other words, ignore the standard libraries), then C++ is the monster. If you compare the functionality provided by the Java libraries then it dwarfs the C++ ones (the latter amount to a subset of the java.lang and java.util classes in functionality). That massive amount of functionality comes at a cost - the size of the library. However, try writing a socket based app in portable C++ - portable to say Windows and Linux. Can't be done without using a third party library, so while you're fucking about with ifdefs and compiler compatability I'll be shipping my Java based app.

    18. Re:Maybe the real problem... by jgrahn · · Score: 1

      The thing is, C++ is huge. Just to have a solid working knowledge of the core language, you need to master whole rafts of things that have nothing whatsoever to do with the low-level operation of the machine, because even the core is a labyrinth of obscure corner cases that make language lawyers drool, and which, if expressed in pseudo-code, would be a bunch of gigantic switch statements with a couple dozen levels of ifs nested inside each case.
      Absolutely. This is fairly easy to check, too; here's the most recent draft for C++0x, and it's already 1200+ pages! And they haven't even included everything they want to get there yet (such as concepts, which alone will add a lot more; a full list of what's not yet there, but is going to be, can be seen here). Now, how do you think, how many developers are going to understand it well enough?

      Your logic is flawed. It assumes

      • That there are other ISO-standardized languages, comparable in scope, with a spec much smaller than 1200 pages.
      • That there are other languages comparable in scope, period. Note that C++ needs to carry the baggage of C.
      • That developers actually learn the language from the ISO standard rather than books.
      • That developers have to relearn the whole language when C++0x comes out.

      Seriously, you people keep claiming C++ is huge, but never seem to come up with any solid evidence. A decade ago it used to be an argument used by Java advocates, but from what I hear (I don't use Java) that language has grown quite a bit since then.

      Also see Bjarne's canned rebuttal.

    19. Re:Maybe the real problem... by jgrahn · · Score: 2, Informative

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

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

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

    20. Re:Maybe the real problem... by shutdown+-p+now · · Score: 2, Insightful

      Your logic is flawed. It assumes ...
      No, it does not. I wasn't comparing C++ to anything (and there are more complicated industrial languages out there: Common Lisp comes to mind), merely pointing out that its sheer size and complexity is more than most can handle.

      That developers actually learn the language from the ISO standard rather than books.
      They don't, and that's part of the problem (because the books are inadequate; and the books are inadequate because any book that'd cover all the subtleties won't be much shorter than the Standard).

      That developers have to relearn the whole language when C++0x comes out.
      They will, when they run into code written using new C++0x features that they'll have to understand, debug and maintain. That's the problem: in theory, you can only use a subset of the language, but in practice, there's no standard subset, so as long as you use third-party code, you'll get it all eventually, and will have to understand it all as well. If you want a standard subset, that's Java (or C#).
    21. Re:Maybe the real problem... by Nicolay77 · · Score: 1

      I dissagree in one detail with you:

      To me the right subset of C++ is precisely the subset they use in wxWidgets. Classes, C macros to simplify stuff and no templates.

      Sadly they want to use STL (having already a very good wxString class and great IO classes) and other assorted stuff just to please the language zealots.

      --
      We are Turing O-Machines. The Oracle is out there.
    22. Re:Maybe the real problem... by Nicolay77 · · Score: 1

      I'll be using wxWidgets and providing a faster and nicer looking App without investing too much time coding it.

      --
      We are Turing O-Machines. The Oracle is out there.
    23. Re:Maybe the real problem... by pyrrhonist · · Score: 2, Interesting

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

      To fully understand what Bruce means, read this

      --
      Show me on the doll where his noodly appendage touched you.
    24. Re:Maybe the real problem... by bfwebster · · Score: 2, Insightful
      To be honest, I would have been tempted to score my own post as flamebait, though it was not intended as such. Let me quote from myself back in 1995, in the Bibliography section of my book Pitfalls of Object-Oriented Development (M&T Books, 1995):

      The Design and Evolution of C++, Bjarne Stroustrup, Addison-Wesley, Reading, Mass., 1994. This is a good book to have when you reach a point in your C++ studies that you want to throw things through windows. In the first place, it allows Stroustrup to explain the thinking and debates that provide insight into various aspects of C++. In the second place, it's softcover, which means it will bounce off the window when you throw it.


      Elegance is that term of art in software engineering that we use to describe a piece of architecture, design, and/or coding that accomplishes what it needs to (and often a good deal more) with a minimum of complexity and a maximum of clarity. In all my years of dealing with C++, I have never heard anyone call it "elegant", and with good reason. ..bruce..
      --
      Bruce F. Webster (brucefwebster.com)
    25. Re:Maybe the real problem... by bfwebster · · Score: 1

      Pyrrhonist:

      That's a wonderful link; thanks for pointing me to it.

      Note, by the way, that most programming languages have flaws. limitations, and tradeoffs. But I really think that C++ was on the wrong track almost from the get-go, and that it has only gotten worse with time.

      I fully believe that the massive 'Taligent' project -- a joint venture between IBM and Apple for a next-generation OS and graphical environment -- failed in large part because of the choice of C++ as the underlying language. I also believe that one of the reasons that NeXTstep survived and became Mac OS X is because of the choice of Objective C as the underlying language. I may be biased, but realize that (a) I was a professional NeXTstep developer and (b) I worked at becoming a professional Taligent developer (Taligent was too big, too slow, and too buggy and died pretty much stillborn). ..bruce..

      --
      Bruce F. Webster (brucefwebster.com)
    26. Re:Maybe the real problem... by wrook · · Score: 1

      Again I agree with you for the most part. C++ isn't what I'd call elegant either (at least not from an overall perspective). But virtually all of the craziness is there for a reason (usually backwards compatibility with C). The ARM (annotated reference manual) goes into detail about which problems C++ is trying to solve and I have to admit that I wouldn't be able to come up with a better solution. The problems are very difficult.

      However, most of the problems (compatibility with C) are no longer necessary or even desirable in most problems. Back in the mid 80s, though, many of these issues were very important. In fact, if I was doing embedded programming I think I would still rank C++ very highly of the possible tools to use -- for the very same reasons that it was useful in the 80s and early nineties.

      Now, I agree, that C++ is of limited use. One great use, that the person who ported Sim City to the OLPC pointed out, is refactoring legacy C code. Of course one could stick with C, but some problems are better suited to an OO approach and C++ is a great language to use in that circumstance.

    27. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

      Dan??? Hey man, meet in the lunchroom for coffee tomorrow morning. I didn't see you around at all last week, is everything ok?

    28. Re:Maybe the real problem... by pyrrhonist · · Score: 1

      That's a wonderful link; thanks for pointing me to it.

      You're welcome, Bruce. Mr. Kreinin explains the issues with C++ much better than I could.

      For those who don't know, the main part of his site is the C++ FQA Lite, which is meant as a commentary on Marshall Cline's C++ FAQ Lite.

      I refer to both sites whenever I have to program in C++.

      Note, by the way, that most programming languages have flaws. limitations, and tradeoffs. But I really think that C++ was on the wrong track almost from the get-go, and that it has only gotten worse with time.

      I agree. It was probably not a good decision in the first place to make C++ compatible with C. That's one of the factors that led directly to the entire unwieldy context-sensitive C++ syntax. The sad reality is that if a language is difficult for the compiler to understand, then it will be difficult for the programmer to understand. As the specification grows, I become more and more convinced that C++ is a puzzle where the object is to try to figure out how to be productive using the language.

      I fully believe that the massive 'Taligent' project -- a joint venture between IBM and Apple for a next-generation OS and graphical environment -- failed in large part because of the choice of C++ as the underlying language.

      I don't doubt that it had a definite effect. Making an entire OS in the early days of C++ is not something that sounds like a good idea. I think that most of the blame lies directly with the choice of index card color, however. :)

      --
      Show me on the doll where his noodly appendage touched you.
    29. Re:Maybe the real problem... by bfwebster · · Score: 1

      It was probably not a good decision in the first place to make C++ compatible with C.


      Actually, I'll argue against that point in two ways. First, Objective C was pure ANSI C with about half a dozen syntax extensions to add object support. Because of that approach, it worked incredibly well and you could compile regular ANSI C programs using the same compiler. (In fact, I believe that the first Obj-C implementations were simply preprocessors that produced ANSI C.) Since when I first encountered Objective C I could quote Harbison & Steele chapter and verse, picking up Obj-C was pretty much a cinch.

      Second, I don't know what the current state of C++ is, but IIRC back in the early 90s, it was not ANSI C compatible, i.e., it actually broke ANSI C programs. [Hey, y'all, feel free to correct me if I'm wrong. Oh, wait -- I'm on the 'net. I don't have to ask. :-)]

      The biggest advantages that Obj-C had over C++ (IMHO and in addition to the ANSI C compatibility) were dynamic typing and a generic root Object class, with everything that falls out from that. If you go back and research the history of Java, you'll find that while it borrowed C++ syntax, the underlying object model and behavior was directly inspired by Obj-C.

      Note that I'm not saying that C++ is not an effective or powerful language in the right hands, that other languages [insert current favorites] are necessarily better choices, or that there aren't situations where C++ is indeed the best choice. I've worked on projects where we evaluated various languages and deliberately chose C++ to do our development. What I am saying it what I said at the start: C++ is a brittle and complex language, and that causes ongoing problems for many software engineers and many software projects. ..bruce..
      --
      Bruce F. Webster (brucefwebster.com)
    30. Re:Maybe the real problem... by ubernostrum · · Score: 1

      A decade ago it used to be an argument used by Java advocates, but from what I hear (I don't use Java) that language has grown quite a bit since then.

      Good thing I'm not advocating Java, then.

    31. Re:Maybe the real problem... by Profane+MuthaFucka · · Score: 1

      Actually, I'm a consultant. So while you're busting your hump doing actual work, I don't have to do a damn thing and I still get paid ... by your company!

      Do I win?

      --
      Fascism trolls keeping me up every night. When I starts a preachin', he HITS ME WITH HIS REICH!
    32. Re:Maybe the real problem... by maxwell+demon · · Score: 2

      The C++ standard contains the complete standard library definition. Note that there are complete books just about the standard library (and some even just about the STL subset). And C++0x adds more to it (more STL classes, a random number generator framework, a threading library, regular expressions, ...).

      --
      The Tao of math: The numbers you can count are not the real numbers.
    33. Re:Maybe the real problem... by mrchaotica · · Score: 1

      C macros to simplify stuff

      C macros hardly ever simplify stuff, even in C!

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    34. Re:Maybe the real problem... by Baki · · Score: 1

      Java has not grown much: it has added enums and generics, not much else. Most growth in java has been standard API's, but the language itself has been pretty constant.

    35. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

      No, there is a very good reason for C++ - and that is to stop constant reinvention of the wheel, and to reduce namespace insanity.

      For instance, class derivation makes great sense. Let's say I have a socket object. I can then derive a class for Servers from it, and a seperate one for Clients. I can then write a really neat library implementing HTTP client and server (or something) in really a short amount of code.

      The argument may be made that it is really syntactic sugar. Sure, it is- but it is a lot nicer than trying to do class derivation in C. It makes refactoring just that bit harder - not impossible, just harder.

      Namespace insanity - what do I mean.

      I mean things like this.

      users_join(u, c);

      Fine code, descriptive function name. Except that when each "object" (u or c) ends up with say, 50-100 methods each, you end up writing things like
      users_make_sure_we_are_ready_to_do_blarp(u);
      to make sure that your function is both uniquely and descriptively named.

      In C++, since methods can be class members, that isn't such a worry.
      u->join(c); - that's approximately half the keystrokes.

      Reinventing the wheel, well... if you're wanting to program defensively, you really don't want to do too much linked list management etc directly inside your code. That way, if you decide to e.g. change it into a linked list or whatever later, you don't have to run all through the application changing shit.

      Also, your self-written hashtable or whatever will most likely *not* be as effective as for example __gnu_cxx::hash_map or your platform's equivilant (generally neatly typedef'd out of the way). Of course, in C++0x this will get even easier with unordered_map becoming standard. I'm not saying that you *cannot* write code that's better than STL, of course it's possible- but unless you are doing something very specialised, you need to ask yourself if it's worth the effort to write and maintain all these containers instead of just using pre-rolled ones. Yes, you could also use GObject or mowgli or any other number of thousands of C frameworks which do this, but why on earth not use one that is standardised, crossplatform, and used by thousands?

      I'm not a fan of some features of C++ (templates are ugly in most cases, multiple inheritance is insane, not being able to return an empty reference is a bit annoying..), but to be sure, after 10 years of writing C, and 5 of using C++, I know which I rather.

    36. Re:Maybe the real problem... by Mr+Z · · Score: 1

      Isn't a good part of C++0x's 1200 pages the boost^H^H^H^H^Hstandard library? Saying you need to learn all of that to effectively learn the language is like saying you need to learn all of CPAN to learn Perl, or all the gobs of standardized Java class libraries to learn Java. The fact of the matter is that large portions of any huge library are very domain specific, and are safely ignored by those outside the domain. For example, our compiler guys at work know the Boost Graph Library pretty well. I can't imagine someone writing payroll software cares too much about it though.

      --Joe
    37. Re:Maybe the real problem... by sribe · · Score: 1

      Lets say Pythons List Data type where you can do a Sort on it or a concatenate, or get a sub list off of it, and more too. Yes you can do the same functionality with C++ but you need to make it yourself and build the Data Type and add the functions to do it, or get a library that may not work on an other platform or needs more libraries to work.

      Uhm, no. You use std::list.

      The problem is the students are focused more on getting the damn thing to compile finding where they missed the ";" vs. Understanding the logic and concepts being taught.

      Agreed, completely.

    38. Re:Maybe the real problem... by DerWulf · · Score: 1
      If I where a complete geek I'd use that as my new signature:

      To really understand programming at a lower level, you need at best only a small subset of C++, and unfortunately for C++ that subset is properly called "C".
      --

      ___
      No power in the 'verse can stop me
    39. Re:Maybe the real problem... by jellomizer · · Score: 1

      Yes I have used C++ before. But I am not a full expert on all the libraries they compile in. Old version of C++ didn't have a string class and new versions do. I am talking about creating Universally Compatible C++ Code that will work in Linux, Solaris 4, and windows... The core C++ Languge has a lot of things missing. Even the fact you need to include iostream.h or stdio.h just for basic operations says something about the stupidness of the languge. C++ is so general porpost that it doesn't really do anything well. It is just an object orianted Assambly compiler, if you use it without any additional libraries.
      The reason people so rabidly defend C++ is becuase it is thier first languge that they learned in school, and they took the KoolAid that told them that this is what the professionals use. I have well over 2 dozen languges under my belt. And I havn't really came up with a case where I found C++ to be the best tool for the job.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    40. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

      Unfortunately a lot of people read posts like yours and worse, believe you. You say python has all these nice features and you have to code them yourself in C++ ? Come on. Get your facts together. C++ already has all these features. Its called the STL. C++ does not put in the core language, but in into librarys. The days when C++ programmers were swinging from tree to tree are long gone.

      Honestly, its not harder to learn than python, too. A list ? Sorting ?

      vector vec;
      vec.push_back( 5 );
      vec.push_back( 1 );
      sort( vec.begin(), vec.end() ),

      Ohhhhh that was really hard. Was it ?

      Associative arrays ?

      map m;
      m["apple"] = "green";
      m["orange"] = "orange";

      Ohh that was so difficult, i got to sit down and take a look again.

      String handling ? In C++ ? OHHHH WATCH THE BUFFERS ? DON`T DO IT ! IT WILL ALL GO DOWN IN FLAMES !!!!

      string s1 = "C++";
      string s2 = " is way cooler than you think";

      string message = s1 + s2;

      Honestly, python is not easier. Really. Please be honest, when did you write your last C++ code that did not look like C ???

    41. Re:Maybe the real problem... by Anonymous Coward · · Score: 0

      Your list example doesn't make sense to me. There are lists and vectors in the standard
      library, and an algorithm for sorting anything you want (including lists and vectors). It's absolutely trivial to create a new list for any data type and sort it.

      And, there are lots of excellent libraries out there for handling a good variety of tasks on pretty much any platform you care to look at, so I'm not sure what you mean there, either.

    42. Re:Maybe the real problem... by Nicolay77 · · Score: 1

      They actually simplify stuff.

      OTOH, those are complex macros written by the wxWidgets developers.

      I don't think any of my C macros can simplify anything.

      --
      We are Turing O-Machines. The Oracle is out there.
    43. Re:Maybe the real problem... by mrchaotica · · Score: 1

      They only simplify stuff if you don't count the complexity of the macro itself. On the balance, I don't think they're worth it except possibly in library code that Somebody Else gets to maintain. And even then I think the use of function-like macros should be minimized because a consumer of the library might not necessarily realize the function is implemented as a macro (and therefore could have unintended consequences if its arguments have side effects, e.g. FOO(arg++) expands to { (arg++) * (arg++) })

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    44. Re:Maybe the real problem... by Nicolay77 · · Score: 1
      To me it is actually library code that Somebody Else gets to maintain.

      Also, the arguments in most (if not all) wxWidgets macros are function names, class names and predefined constants.

      Not your usual "Ohh no macros are bad, would somebody please think of the children" macros. Also: macros are ALL CAPS and function names are not. And it is stated clearly in the documentation. I mean, you really try hard to scare young programmers don't you?

      Example (the only macros I have to actually use, all others are optional):

      Header file

      class clipApp: public wxApp
      {
      public:
          virtual bool OnInit();
      };
       
      DECLARE_APP(clipApp)
      Source file

      IMPLEMENT_APP(clipApp)
       
      bool clipApp::OnInit()
      {
      //Whatever the App does.
      }
      The other macros used in wxWidgets are for binding functions to control events, but I don't use them, as I prefer to use the Connect function. They are however necessary if you use a visual editor, just like with MFC.

      Those macros look like this:

      BEGIN_EVENT_TABLE(MyFrame,wxFrame)
          EVT_MENU (wxID_ABOUT, MyFrame::OnAbout)
          EVT_MENU (wxID_EXIT, MyFrame::OnQuit)
      END_EVENT_TABLE()
      Finally macros are used for implementing RTTI in any C++ compiler (not just the most recent ones). This is because wxWidgets exists long before the modern C++ standard appeared. As it compiles fast and runs fast I don't have any problem with it being macros.

      And that's all. Those are the macros I remember using in wxWidgets. No unintended consequences or side effects that I'm aware of.
      --
      We are Turing O-Machines. The Oracle is out there.
  5. C++ needs to improve by Anonymous Coward · · Score: 1, Insightful

    It's way too complex to be managable, resulting in unmaintainable (No IDE can fully go through all typedefs; and if you ever stepped through a program and went into every godam -> operator of boost, you're on my side), unreadable and unneccesary code ("Better declare a private but not implemented copy constructor just to be sure"). It tried to implement all possible paradigmas at once, while trying to be backward compatible at the same time. It's the worst language ever.

  6. more to it by g2devi · · Score: 5, Interesting

    That may be so, but there's more to it. It's only been recently fully implemented and a few years ago Stroustrup himself commented that he's constantly surprised that some things (e.g. template recursion) are even possible in C++.

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

    1. Re:more to it by JohnFluxx · · Score: 5, Informative

      Sometimes you need the more complicated parts of C++ - It would be a very bad idea to simplify c++ to the lowest common denominator.

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

    2. Re:more to it by smilindog2000 · · Score: 4, Informative

      I couldn't agree more! Much of the worst code I've ever had to deal with is C++ code written by smart guys who don't know what parts of C++ to use. How about mixing double inheritance from template classes, with smart pointers and garbage collection, when all you're writing is quicksort? Smart guys can take a 100 line problem and turn it into a 10,000 line C++ solution.

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

      --
      Beer is proof that God loves us, and wants us to be happy.
    3. Re:more to it by Zeinfeld · · Score: 2, Insightful
      The key advice any C++ expert is "restrict yourself to a specific subset of C++".

      Yes, that subset is called C.

      Seriously, at this point it is time to call a halt to C++ education. Treat it like COBOL, Fortran or any other legacy language that still has demand for programmers but is long since past utility. It is a good idea for students to understand that they have to keep current with programming languages and not expect to be employed as a programmer if they can only code in one. But that does not mean we should start by teaching an obsolete language.

      You don't need to tech kids to write in C++ for them to learn how bad an idea lack of GC is. Just give them some existing code and tell them to chase buffer overruns and memory leaks.

      I would not code in any language that does not have a garbage collection feature, period. When I coded C in the 90s I wrote my own garbage collector using macros and some extensions to the memory allocation routines. More importantly I would not allow anyone else to write code without GC because none of them were capable of doing it right.

      Second, do not use the null terminated string handling. This was one of the key coding requirements that Tim Berners-Lee set out in libwww. All string catenation was checked. It is one of the reasons libwww was so widely used, it was buffer-overun error proof.

      I would certainly specify C for use in a low level O/S platform project, but not C++. I think the language is Algol 68 to Algol 60, worse than the original.

      Above that point I would use either C#, Java or objective C. From an education point of view they are interchangeable.

      C# is at least as fast as equivalent C++ code. The code generator used is identical. You can switch in your own GC if you choose.

      --
      Looking for an Information Security student project suggestion?
      Try http://dotcrimeManifesto.com/
    4. Re:more to it by shutdown+-p+now · · Score: 5, Interesting
      Unfortunately, even if you keep away from the more advanced stuff such as template metaprogramming, there's still plenty of surprising (in a bad sense) behavior in the most basic C++ constructs (mostly inherited from C, but exacerbated by C++ pretense at high-levelness, and with some new stuff thrown in for good measure). Pointer arithmetic, unsigned types, silent implicit narrowing conversions, PODs vs non-PODs (which in turn separate into aggregate types and everything else) and the subtle differences in initialization of those, ability to delete void* and pointers to incomplete types (and the wonders of virtual destructors), etc... The language is a mess, really. It is very powerful, and the existing code generators are very good at optimizing stuff, but writing in C++, or any subset thereof, requires a very good understanding of subtle details.

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

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

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

      You don't need to tech kids to write in C++ for them to learn how bad an idea lack of GC is. Just give them some existing code and tell them to chase buffer overruns and memory leaks You don't need to tech (sic) kids to write in C# for them to learn how bad an idea of GC is. Just give them some existing code and tell them to chase memory leaks and finalisation issues.

      There, fixed that for you.
    6. Re:more to it by shutdown+-p+now · · Score: 2, Interesting

      The language is overly complex. The key advice any C++ expert is "restrict yourself to a specific subset of C++". That's the bulk of the difficulty. If C++ were simplified to include only that subset, you'd have a lot less need for training,
      Yeah. That subset could be called something then to distinguish it; say, "Java". And then you could have a slightly larger subset with more advanced stuff, like pointers and value types; let's call that something more C++-like to reflect it: hm, how about "C#"? And sure enough, once you do that, it's much easier to teach people that, and they write more readable code, too.

      This isn't to bash C++; it's still a useful language when you want raw speed of C but with some more decent abstraction mechanisms. It's just not the right language to write high-level stuff in, and it shows now that a lot of GUI applications, which were previously largely written in C++, are being done with C# or even Python.

    7. Re:more to it by Anonymous Coward · · Score: 0

      Very bad example. I consider "using SSE" one of the more simple features of C++. What do you have to understand to use SEE? Using intrinsic functions, which are for the user not more complicated than any other function call. Or you could use inline assembler which is not very complicated.

    8. Re:more to it by Chapter80 · · Score: 0

      You can, for example, make a vector with 4 numbers in it and multiply it with another vector with 4 numbers in it. The result is that the four multiplications are done simulatanously.
      Wow, I thought we had to look to Erlang for concurrency this powerful. Unless "simulataneously" means "nearly simultaneously". Perhaps you meant that the four multiplications can be performed with one operation? Or did you really mean simultaneously? I just find that hard to believe.
    9. Re:more to it by Chapter80 · · Score: 2, Insightful

      I agree. C++ served its purpose in the language world. It was a great FIRST STEP toward object oriented programming, but it has outlived its usefulness. Stroustrup should take pride in his great contribution, and not be discouraged because C++ has been superseded by other, better languages. C++ provided a bridge from the world of no objects in C, to the world of objects. But now that there are languages that are designed with objects in mind from the ground up, it's only academically interesting (and of little practical value) to learn C++ except to support (or port) legacy applications.

    10. Re:more to it by repka · · Score: 1

      Nowadays I code heavily in C# and occasionally have to modify libraries used by other people. C++ has much better facilities to avoid breaking existing code: typedefs, macros, better implicit cast operators. Even though first two are relics from C era and the last one somewhat complicates the language, C++ wouldn't be C++ without them.

    11. Re:more to it by Kjella · · Score: 1

      For example, most people don't use the SSE stuff or even know about it. You can, for example, make a vector with 4 numbers in it and multiply it with another vector with 4 numbers in it. The result is that the four multiplications are done simulatanously. Yes, except I expect the compiler to figure that out. If I make say:

      for(i=0; i<4; ++i) {
          a[i] = b[i]*c[i];
      }
      Maybe I'm being unrealistic, but I don't really want to deal with SSE primitives or whether it has SSE support or not. I guess there are people that really, really need manual control of what's going on but that's a different language than the one I need.
      --
      Live today, because you never know what tomorrow brings
    12. Re:more to it by Talchas · · Score: 1

      He means using the SSE simd instructions, which is as simultaneous as you get using just one processor/core, and is much much faster than doing the four operations separately.

      --
      As the Americans learned so painfully in Earth's final century,free flow of information is the only safeguard against...
    13. Re:more to it by abigor · · Score: 1

      Well, at first glance, std::cin goes into an infinite error loop on invalid input, returning the last valid input over and over. You need to check it before assignment.

      As for the question about the includes, for backwards compatibility, shouldn't you have included iostream.h, rather than just iostream? Or am I confused?

      Anyway, I miss posts like yours on Slashdot, so thanks for making it.

    14. Re:more to it by TheLink · · Score: 1

      I think he meant what a reasonable person would understand about "simultaneous". You, however are free to split hairs down to quantum physics or further if you want.

      http://en.wikipedia.org/wiki/SIMD

      --
    15. Re:more to it by johannesg · · Score: 5, Insightful

      The "restrict yourself" stuff is stupid. It's like saying "tie one hand behind your back while programming". Can you think of *any* other profession where professionals are advised not to use their best tools?

      The correct advice would be, "use precisely what you need and no more".

      I have been programming in C++ for a very long time, and I have needed *every single tool* that some of you nay-sayers would say was unnecessary. And that's needed in the sense of "the best solution was achieved using these tools", not "I padded my CV by adding unnecesary complexity".

    16. Re:more to it by Anonymous Coward · · Score: 0

      How do you do this? For starters, I would think that one of the benefits of C++ would be portability, so if you're talking about vectorized SSE instructions, you're limiting yourself to modern x86 architectures, whereas the grandparent poster mentions national research labs, which often times run different architectures than these. Second, while I don't consider myself a C++ guru, I don't know of any instruction to do this other than using 'asm' to code assembler... and shouldn't optimizations like this be left to the compiler anyways?

      I'm genuinely curious how to do this, so if you've got some sample code, I'd love to see it...

      Thanks!

    17. Re:more to it by nikanj · · Score: 1

      That is Hard for the compiler to figure out.
      Compare this to the python syntax where
      aa=array([[2, 4, 6])
      bb=array([[1, 3, 5])
      cc=aa + bb // cc == [3, 7, 11]
      Guess how hard it is for the compiler to pick SIMD in this case?
      It's really quite amazing how the programmer first has to express "add these two arrays" on a really low level, then the compiler needs to figure out what the programmer is really trying to do in order to generate code that's actually taking advantage of SSE primitives. Why not express what you want to do instead of giving near-assembly-level instructions for doing it? The lower level you program on, the less leeway the compiler has for generating the optimal code.

    18. Re:more to it by noidentity · · Score: 1

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

      And less libraries. A key C++ feature is facilities for library providers to make types that behave as if they were built in. Even though the application developer doesn't use these facilities directly, if taken away the libraries would go with them. It is of great value to be able to effectively extend the language for specialized domains, just by writing (or having someone experienced) write a library. Boost is a great example of what is possible.

    19. Re:more to it by Courageous · · Score: 1

      The key advice any C++ expert is "restrict yourself to a specific subset of C++".

      God forbid we start talking about Perl.

      C//

    20. Re:more to it by Carewolf · · Score: 0, Flamebait

      The major flaw in your program is the same major flaw Stroustrup has in his vision of C++
      - If you need a standard library you shouldn't be using C++
      - If you are using C++ - for the love of god - don't use the standard library
      - If you want portable C++ code, don't EVER EVER use the standard library!!!

      Did I mention using the right tool for the job? Use perl for this example.

    21. Re:more to it by KutuluWare · · Score: 1

      You don't need to tech kids to write in C++ for them to learn how bad an idea lack of GC is. Just give them some existing code and tell them to chase buffer overruns and memory leaks

      You don't need to tech (sic) kids to write in C# for them to learn how bad an idea of GC is. Just give them some existing code and tell them to chase memory leaks and finalisation issues.

      One small mistake there. I just looked it up on m-w.com. In neither British nor American spelling do you spell "Java" with a "C" or "#".
    22. Re:more to it by Anonymous+Brave+Guy · · Score: 1

      But neither intrinsic functions or inline assembler are portable, which is unfortunate if (like many high performance libraries) you need to build on many platforms.

      I think the more relevant thing is that if you use a decent compiler, most of them will pick up a simple optimisation like this and generate appropriate code just from the C++ these days. Optimisers certainly have a long way to go, but we're well past the point of getting this sort of thing right routinely.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    23. Re:more to it by Anonymous+Brave+Guy · · Score: 1

      Now, who'll be the first one to spot and explain the problem here, preferrably without actually running it?

      Probably your static code analysis tool, which would presumably warn you about the potential division by zero, and for that matter the fact that you're dividing using integer arithmetic in the first place.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    24. Re:more to it by gbjbaanb · · Score: 2, Funny

      Oh, I thought the new American spelling of Java was indeed 'C#'. Perhaps its just a Seattle dialect.

    25. Re:more to it by aj50 · · Score: 1

      Very interesting

      Because Vector::size() returns an unsigned int, the division is done with unsigned numbers.

      The code will give a wrong answer if the total is negative.

      C has the same problem:

      #include <stdio.h>

      int main()
      {
      int i = -2;
      unsigned int j = 2;
      printf("%d\n", i/j);
      return 0;
      }

      Output (on my computer): 2147483647
      --
      I wish to remain anomalous
    26. Re:more to it by twistedcubic · · Score: 4, Insightful


      Did I mention using the right tool for the job? Use perl for this example.

      You guys are weird. Someone gave incorrect, convoluted code (in C++) for doing something, and you criticize C++ for this???

    27. Re:more to it by sconeu · · Score: 1

      iostream.h was never an "official" header.

      Also, the GP doesn't need iomanip, as std::endl is declared in ostream.

      Another edge case where this fails is in the case of empty input.

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    28. Re:more to it by larry+bagina · · Score: 1

      if you're using GCC, you can #include mmintrin.h, xmmintrin.h, or tmmintr.h for c bindings to mmx and sse* instructions. Ooh, and it looks like VC++ (and presumably intel's icc) have builtin support for them as well.

      --
      Do you even lift?

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

    29. Re:more to it by truedfx · · Score: 5, Interesting

      I'll admit I had to run the program, and even then it took me a while to see it.

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

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

    30. Re:more to it by LizardKing · · Score: 1

      C++ was not the first OOP language, as even Stroustrup will acknowledge - he was attempting to add Simula like features to C when he came up with C++. Smalltalk also predates C++. I agree that it should be relegated to legacy status though.

    31. Re:more to it by LizardKing · · Score: 1

      How do you know that the grandparent poster was suggesting you don't use the "best tools" in C++? There again, what does C++ do better than a number of other languages? Let's take the iostream classes for example. They were supposed to be "better" than C stdio because, well, for no other reason than they were object oriented. In practice, iostream code is actually more verbose, less intuitive and relies on a dubious use of the overridden left and right shift operators.

    32. Re:more to it by scotch · · Score: 1

      The standard library rocks for some things - C++ would be much diminished without it. Of course, those who don't understand it are also likely to not understand other container libraries (in C or whatever) and also likely to try to code up their own containers and make jillions of mistakes doing so. The example code above is great because it shows that the person complaining would likely have tons of problems with C and just understanding his or her tools in general.

      --
      XML causes global warming.
    33. Re:more to it by mollymoo · · Score: 1

      First step toward OOP? Smalltalk started development in 1969 and was published in 1980. C++ started development in 1979 and was published in 1983.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    34. Re:more to it by SerpentMage · · Score: 1

      A garbage collector is bad idea? How is C++ better? C++ has memory leaks, and on top of it, C++ has GPF's or core dumps. So in the end C# and Java are actually better.

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    35. Re:more to it by jgrahn · · Score: 1

      That may be so, but there's more to it. It's only been recently fully implemented

      Huh? The current standard is ten years old this year, and G++ had good enough support for modern C++ at least in 1999 (gcc 2.95) and good support in 2001 (gcc 3.0). Full support is nothing you should rely on anytime soon; I have given up on the "export" keyword.

      and a few years ago Stroustrup himself commented that he's constantly surprised that some things (e.g. template recursion) are even possible in C++.

      Probably another tongue-in-cheek comment. It is true that a lot of uses of templates were discovered inside C++ rather than designed into it. I don't see how that is a bad thing.

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

      So what part do you suggest removing, and how many decades do you allow for people to adapt to it? Note that removing C compatibility is not an option.

    36. Re:more to it by abigor · · Score: 1

      iostream.h was never an "official" header. Right, but his concerns seem to be about backwards compat, and iostream.h dates from before there was a standard implementation, so I figured he wanted portability with older implementations (wasn't it Digital's C++ lib that broke things? This is all around 10 years old for me now).
    37. Re:more to it by boilednut · · Score: 2, Interesting

      Granted C++ is a complex and feature-rich language; but, the majority of that complexity is not imposed on you -- it there to be used at your discretion. C is a subset of C++; so, it's quite possible to write essentially C code with only the elements of C++ added that you consider useful. For example, templates are a powerful and labor-saving C++ mechanism for writing a family of classes that share a common interface but whose data-members don't have a common parent; however, it's quite possible to do something similar in C++ using the old-hat C constructs of structs and unions.

      I find the contention that because C++ can be complex that it should be restricted a little defeatist. It's analogous to saying, because most people don't use, or understand, math past introductory college algebra, why even teach higher-level mathematics.

    38. Re:more to it by CockMonster · · Score: 1

      SSE is an extension to Intel x86 CPU instruction set and has nothing to do with C++

    39. Re:more to it by JimboFBX · · Score: 1

      Multiplying two vectors together is NOT ISO C++. The meaning of that with even something as simple as integers is ambiguous (is this array math or matrix math?) and wouldn't make sense with most datatypes (how do I multiply a vector of strings together?).

      Jesus, the man is right! People don't know C++!

    40. Re:more to it by shutdown+-p+now · · Score: 4, Interesting

      I know the header is also required to that std::endl is declared. I'm not seeing what could be in that's of interest of your program. Could you explain that last one?.
      Ironically, it's my mistake - std::endl is also a stream manipulator, so I figured it is properly supposed to be in "iomanip" as well, and didn't bother to double-check (let's face it, in real world we usually just include "iostream" or other stream header as needed, and that's it - the rest gets dragged in, even if the Standard doesn't guarantee that it will). But you're absolutely right, std::endl is in "ostream", shame on me. And I've been coding fancy C++ stuff (with templates, STL, and all that) for five years now... *sigh* I guess it sort of serves to reinforce the point I've originally made :)
    41. Re:more to it by Anonymous Coward · · Score: 0

      How was smalltalk a step between C and object oriented programming?

    42. Re:more to it by Anonymous Coward · · Score: 0

      Let's see. Overflow as you sum the integers into an int? Integral division when the average of two integers is not necessarily an integer? Or are you talking about the implicit signed->unsigned conversion that occurs?

    43. Re:more to it by shutdown+-p+now · · Score: 2, Informative

      No, my concern was with Standard compliance. If you merely want this code to run on any existing C++ compiler, half of those includes could be safely removed - just "iostream" would suffice. There's just no guarantee it won't suddenly stop compiling tomorrow on gcc 4.5 ;)

    44. Re:more to it by Anonymous Coward · · Score: 0

      I haven't used C++ enough to know how those functions are supposed to work, but you've got a rather obvious potential division by zero there:
      int avg = std::accumulate(v.begin(), v.end(), 0) / v.size();

    45. Re:more to it by Dun+Malg · · Score: 1

      int avg = std::accumulate(v.begin(), v.end(), 0) / v.size();
      A simple task, and a clean implementation If you overlook the fact that only a complete moron divides integer values and expects a consistently valid integer result, particularly when using standard libraries, I suppose it could be called "clean".
      --
      If a job's not worth doing, it's not worth doing right.
    46. Re:more to it by shutdown+-p+now · · Score: 1

      Well, at first glance, std::cin goes into an infinite error loop on invalid input, returning the last valid input over and over. You need to check it before assignment.
      When operator>> fails to match an int (as in, not a single matching character was read), it'll stop and set failbit on the stream (well, actually it's num_get::get() that does it, if you wish to look it up in the Standard to check). And istream_iterator is considered to be an end-iterator when fail() is true for the stream it's reading from. So that particular line works correctly (perhaps surprisingly enough for a seasoned C++ developer).
    47. Re:more to it by tixxit · · Score: 1

      BLAS is really the best solution here, since there are high performance implementations for most architectures out there (usually written by the manufacturer themselves). Using these libraries are also not limited to C/C++.

    48. Re:more to it by shutdown+-p+now · · Score: 1

      If you overlook the fact that only a complete moron divides integer values and expects a consistently valid integer result, particularly when using standard libraries.
      Integer division is perfectly well-defined in C/C++ (and most other languages, too - Java, Python...), and often used as such. If, say, these int were pixel coordinates, there would be very little sense in doing the int->double->int conversion, since the result would be a 1px difference (and sometimes you want rounding to zero, anyway).

      And, of course, this has absolutely nothing to do with the C++ standard library, since it's not code in it doing the division here.

      The real non-C++-related fubar in the code is lack of check for div by zero, and a potential integer overflow on large inputs.

    49. Re:more to it by benhattman · · Score: 1

      int avg = std::accumulate(v.begin(), v.end(), 0) / v.size();
       
      ...

      And yet, it gives wrong result for certain input data. Now, who'll be the first one to spot and explain the problem here, preferrably without actually running it?


      My vote is for segmentation fault on divide by 0!
    50. Re:more to it by shutdown+-p+now · · Score: 2, Informative

      Did I mention using the right tool for the job? Use perl for this example.
      Why would one in a sane mind want to use a language explicitly designed around string processing for number crunching?
    51. Re:more to it by shutdown+-p+now · · Score: 1

      Probably your static code analysis tool, which would presumably warn you about the potential division by zero
      True.

      ... and for that matter the fact that you're dividing using integer arithmetic in the first place
      It'd probably have to bark at the STL libraries first, since that's what they usually do in sort() and many other algorithms. Integer division is a perfectly well defined and frequently used operation in C/C++.
    52. Re:more to it by Burnhard · · Score: 1

      The language is a mess, really. It is very powerful, and the existing code generators are very good at optimizing stuff, but writing in C++, or any subset thereof, requires a very good understanding of subtle details.

      I couldn't agree more. I've recently returned to C++ after 5 years of VB.NET and am gobsmacked all over again at just how mastery of subtle detail is so important. I'm quite lucky in that I have an "expert" with me, providing the framework I'm using. Even so, there are so many "gotchas" you need to be aware of. The programmer isn't helped by the incomprehensible error messages and lack of intellisense (I'm talking VC++ here of course).

      I honestly believe that compiler technology is at such a stage now where it must be possible to produce a consistent, easy to use language that is also highly efficient, but without all of the potential pain and sufferring involved with C++. The cognitive burden of working with it is far greater than other languages, for little obvious gain.

    53. Re:more to it by benhattman · · Score: 1

      Seriously, at this point it is time to call a halt to C++ education. Treat it like COBOL, Fortran or any other legacy language that still has demand for programmers but is long since past utility.
      In the similar vein, I advocate we halt the manufacturing and sale of automobiles. Treat them like other legacy modes of transportation like the horse-and-buggy and walking.
    54. Re:more to it by Dun+Malg · · Score: 1

      Integer division is perfectly well-defined in C/C++ You're right. I meant to say "divide signed and unsigned integer values". My intended point was about type checking and I failed miserably!
      --
      If a job's not worth doing, it's not worth doing right.
    55. Re:more to it by colinrichardday · · Score: 1

      Shouldn't you use valarray instead of vector?

    56. Re:more to it by shutdown+-p+now · · Score: 1

      You're right. I meant to say "divide signed and unsigned integer values". My intended point was about type checking and I failed miserably!
      That's perfectly well-defined too, just not in a way any sane person would expect it to be (i.e., (-4/2u == -2) && (-1 baffles the smart guys who write the books on C++ fundamentals; what about us mere mortals, then?
    57. Re:more to it by Anonymous Coward · · Score: 0

      I focus instead on restricting programmers to the tools they need, so they focus their creativity on algorithms instead of coding methodology. I've even codified it all, as an extension to C, rather than C++. Works great for team programming. I had a guy last week write two IC placers: simulated annealing, and quadratic placement, in 5600 lines of hand written code, debugged and working. He did it in 6 days while supporting a difficult client, without working weekends or evenings. I'd estimate his productivity at 10X to 100X higher than average. Wow, he did it just like you would have. You should groom this person and fast track him to upper management. He is awesome, and it is obviously all because of you and your focus. You are a true visionary and mentor and would take five days. It took him six because he is still learning your system. Please lecture us.
    58. Re:more to it by 32771 · · Score: 1

      This reminds me of this fascinating Lisp interpreter which is run based on templates during compile time as it seems.

      http://209.85.129.104/search?q=cache:Hc_Bsm4QjkAJ:www.prakinf.tu-ilmenau.de/~czarn/meta/metalisp.cpp+metalisp&hl=en&ct=clnk&cd=6

      Unfortunately people seem to have lost interest in it and the code is now only in the google cache. This was mentioned in the boost paper:

      http://www.cs.ualberta.ca/~graphics/software/boost/libs/mpl/doc/paper/mpl_paper.pdf

      I find this totally interesting even though it seems like C++ has been stretched beyond its limits. I think this is a good example for the complexity you complain about. People are producing useful code and even libraries based on obscure features of the compiler which the inventors never thought about. If you need compile time functionality to support programmable code generation you would expect some more explicit language features to be available for this task.

      Also I always feel that I must learn about these advanced template mechanisms I have no clue about, to really understand C++. Then I notice that the rest of the world thinks that C++ is outdated and Java or something else sluggish is the language of the future. You can't write high performance code in Java (digital signal processing, image processing, real time stuff, ...) however, so I will continue with C/C++. The DSP and uC environments also never support Java and rarely will they have a good C++ compiler. So I feel a bit left behind. Especially since I don't know what the next best high performance programming language will be.

      --
      Je me souviens.
    59. Re:more to it by oldhack · · Score: 1

      C++ shares a problem common with Perl. Both evolved bit by bit willy-nilly and got supersized into incoherent blob. Main thing that keep them limping along seems sunken costs (previous investment in people and code) and legacy inertia. It's painful to watch Strousup once again being defensive about C++.

      --
      Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
    60. Re:more to it by Anonymous Coward · · Score: 0

      >>The programmer isn't helped by the incomprehensible error messages and lack of intellisense

      Error messages are getting better, and VS2005/2008 have really good intellisense features, I would say so good that there is nothing other there on the market commercial or free that even comes close.

    61. Re:more to it by kazade84 · · Score: 1

      I actually knew straight away where the problem was in that code, but only because I have ingrained in me that size() is unsigned thanks to the warnings from GCC (try writing a for loop that uses an int as the loop variable, and compare with something.size() as the condition). The header file thing is because it doesn't specify in the standard which header files an STL implementation must include from another header (e.g iostream is *likely* include istream, but then again it might not). It might work on your compilers implementation, it doesn't necessarily mean that it will work on another.

    62. Re:more to it by Haeleth · · Score: 1

      Well, yeah, but you could do that in C++ too: just use a vector class whose implementation used SSE primitives behind the scenes.

      If what you were insinuating was true, then Python would be being used in preference to low-level languages for high-performance computing, but that doesn't actually happen, because in real life the low-level languages are still vastly faster.

      (At this point the Python fanboys typically trot out the example of Google. Totally irrelevant; the kind of stuff Google does is going to be I/O-bound, so computational performance is of little importance.)

    63. Re:more to it by Burnhard · · Score: 1

      Error messages are getting better, and VS2005/2008 have really good intellisense features, I would say so good that there is nothing other there on the market commercial or free that even comes close.
      You say that, but you are comparing one version of C++ with another. That's a little like saying reading a map is better than navigating by the stars, when you could have a sat nav. Even if the error messages are getting better, a lot of them are still barely comprehensible. I could apply the same argument here I think. My overwhelming feeling is that C++ is the best of old technology and that it shouldn't be beyond the wit of 21st century man to come up with something better.
    64. Re:more to it by nikanj · · Score: 1

      My post wasn't about advocating python, it was about unadvocating learned-this-in-the-70s programming languages and constructs. Vector is so much better than straight loop copying, but I'm quite certain that most of the code "out there" is not using the tools provided. Case in point: grandparent :-)

      High-performance computing is an entirely different area altogether, but even there things are drifting towards high-level languages with just the most critical part written in assembler.

    65. Re:more to it by Anonymous Coward · · Score: 0

      And what does SSE have to do with C++? Assembly or intrinsic functions are not a part of C++

    66. Re:more to it by Viol8 · · Score: 1

      "For example, most people don't use the SSE stuff or even know about it. "

      Why should they? Its inherantly non portable. Not everyone develops for late Pentium x86.

      B2003

    67. Re:more to it by hobbit · · Score: 1

      If they're all done by the time the clock ticks again, whether or not they're actually done simultaneously is an implementation detail, one which you would do well not to make assumptions about.

      --
      "Wise men talk because they have something to say; fools, because they have to say something" - Plato
    68. Re:more to it by Anonymous Coward · · Score: 0
      Hey, I can write convoluted code in other languages, too!

      static void main()
      {
      List<int> arr = new List<int>(new StringTokenizer(Console.In).Numbers);
      int avg = 0;
      foreach(int i in arr) avg += i;
      Console.WriteLine(avg / arr.Length);
      }
    69. Re:more to it by EsbenMoseHansen · · Score: 1

      A garbage collector is bad idea? How is C++ better? C++ has memory leaks, and on top of it, C++ has GPF's or core dumps. So in the end C# and Java are actually better.

      Try writing a Java program that copies one file into another, and then closes both files. Remember to handle exceptions, and don't assume that the file fits into memory. A simple task, no? In C++ pseudocode, that would be

      ifstream source(source_name);
      ofstream target(target_name);
      copy(source.begin(), source.end(), target.end());
      if (!target) throw runtime_error("Fail");

      Now, as an exercise, design a Java class that allows you to perform the given task without having to use finally (you can use it in the class, though).

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    70. Re:more to it by Anonymous+Brave+Guy · · Score: 1

      It'd probably have to bark at the STL libraries first, since that's what they usually do in sort() and many other algorithms.

      Sorry, I don't follow. What does integer division have to do with sorting?

      Integer division is a perfectly well defined and frequently used operation in C/C++.

      Sure it is, but it's still inappropriate to ever use it unless you really do want a particular kind of truncation on the answer.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    71. Re:more to it by jstott · · Score: 1

      It's really quite amazing how the programmer first has to express "add these two arrays" on a really low level, then the compiler needs to figure out what the programmer is really trying to do in order to generate code that's actually taking advantage of SSE primitives.

      gcc -msse2 -mfpmath=sse *.c

      It may be hard, but it can't be that hard because I've been using this flag for a good five years now...

      -JS

      --
      Vanity of vanities, all is vanity...
    72. Re:more to it by Anonymous Coward · · Score: 0

      Very interesting

      Because Vector::size() returns an unsigned int, the division is done with unsigned numbers.

      The code will give a wrong answer if the total is negative.

      C has the same problem:

      #include <stdio.h>
       
      int main()
      {
      int i = -2;
      unsigned int j = 2;
      printf("%d\n", i/j);
      return 0;
      }
       
      Output (on my computer): 2147483647
      While that example in C gives the wrong result for what you are trying to do. It gives the expected result that C should give. Most people probably already know this (or should), but the '/' operator must perform usual arithmetic conversion to bring the operands to a common type, and the unsigned int takes priority so -2 is first converted to an unsigned int (4294967294) and then divided by 2 to give the result it should: 2147483647. A good compiler will warn you when you have a signed/unsigned mismatch.
    73. Re:more to it by Anonymous Coward · · Score: 0

      That's bogus. While you need the right tool for the job and actually know what you do, to accumulate lots of memory is noticable and fixable, while when coding in C or C++ not even a very experienced programmer would rule out not to have created code yielding to a overflow, which might be exploitable, depending on the complexity of the code on the one hand and the time he actually can spend on it on the other hand. To do nasty stuff with a vm underneath it needs some "efforts" in combination with lack of experience - when having to care for memory allocation yourself, doing pointer arithmetics, etc. you just need to be a bit careless and the bomb starts ticking.

    74. Re:more to it by Anonymous Coward · · Score: 0

      I hope you don't mean v.size()==0 causes a division by zero? Because I fail to see how that is a C++ problem.
      You could program that bug in about any language.
      There is also the possibility of integer overflow, but I hope that too isn't counted as a C++ problem.

      Besides that, the algorithm is wrong. You shouldn't waste memory on storing all integers when you're calculating an average. That can cause memory problems. The correct way to do so is to just count your inputs and the running total. To get the average, just divide them. You can easily average 4 billion ints that way on a 32 bit machine. Again, not a C++ problem.

    75. Re:more to it by 2short · · Score: 1

      "C++ has memory leaks, and on top of it, C++ has GPF's or core dumps"

      Isn't it wonderful how you can't code bugs in GC languages?

    76. Re:more to it by SirSlud · · Score: 1

      No fancy language features used - no template metaprogramming, no pointers, no virtual inheritance. The kind of stuff a new C++ programmer might write after reading Stroustrop.

      I think most programmers use the STL when its obvious and readable. My experience is that people will skip 'accumulate' and iterate to be more explicit. The STL is a great path for mental masturbation and lots of problems. The STL is useful like a rope is. You can either use it for where its very clear you're not going to hang yourself .. or you can hang yourself.

      I love the container classes and the like, but I have a very hard time thinking thats what a new C++ programmer is going to write if I ask him or her to write a function that averages ints.

      C++ and STL can certainly offer you tons of ways of writing obscure bugs .. give me a language that doesn't. We could sit here for days and voley obscure "spot the bug" arguments, but I don't think it makes a very good case for the unsuitability of a language.

      --
      "Old man yells at systemd"
    77. Re:more to it by SirSlud · · Score: 1

      Programmers will code memory leaks. Always.

      If your refcount doesn't reach 0, then you have a leak, GC or not. So sure, GCs are nice for certain tasks, convenient, if you will, but theres no way in hell I'd put a newb programmer on coding a hits per second kind of massive function GC or no GC. GC is convenient for programmers who know what they're doing, not some kind of magical solution for programmers who don't understand where the memory is going.

      --
      "Old man yells at systemd"
    78. Re:more to it by pclminion · · Score: 1

      The same problem occurs in C, when types are not treated properly. This problem has nothing to do with C++, actually.

      It's sad that you tout this example, which is an extremely good example of elegant use of generic programming. The problem occurs during the division step when type conversions are performed. Yet this weird behavior taints the entire example. I wish you hadn't..

    79. Re:more to it by Zero__Kelvin · · Score: 1

      "Did I mention using the right tool for the job? Use perl for this example."
      And by the same token, if you want to look more attractive, try pounding yourself in the face with a hammer!

      To be fair, I think Carewolf may be missing the point that this is a code snippet rather than a complete program. Either that or he is thinking of using some high overhead way of calling the Perl code from a program written in a language that isn't deviant and disgusting, without regard for the cost of said binding. ;-)
      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    80. Re:more to it by Zero__Kelvin · · Score: 1

      "Why would one in a sane mind want to use a language explicitly designed around string processing for number crunching?"
      Designed? You mean as in, hey look! I just vomited! Come see the abstract art I just designed! ?????
      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    81. Re:more to it by maxwell+demon · · Score: 1

      Of course if you want to split hairs about "simultaneous", you'll go to relativity instead. Note that with large supercomputers, the order of certain operations on different processors may even physically be undefined. If two multiplications are simultaneous may depend on your inertial system.

      OK, enough hair-splitting for now. :-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
    82. Re:more to it by maxwell+demon · · Score: 2, Informative

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

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

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

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

      Bonus points for explaining why we need "istream", "ostream" and "iomanip" headers here in addition to "iostream" (and we do, if we want this to be portable).

      We don't. Only "iostream" (for std::cin and std::cout) and "ostream" (for operator>, but istream_iterator for input (the fact that istream_iterator internally uses operator>> is irrelevant here; it's the job of the "iterator" header to make sure everything needed in the implementation of the iterator is included; indeed, on a compiler implementing export, might only be included in the corresponding .cc file of "iterator" (and thus not even indirectly in your own translation unit). Moreover "iomanip" isn't needed because you don't use any of the manipulators defined there (you need "iomanip" only for iterators which take arguments).
      --
      The Tao of math: The numbers you can count are not the real numbers.
    83. Re:more to it by maxwell+demon · · Score: 1
      Reminder to myself: If using angle brackets, never forget to preview, even in the middle of the night!

      The last paragraph should have read:

      We don't. Only "iostream" (for std::cin and std::cout) and "ostream" (for operator<< on ostream and std::endl) is needed. "istream" isn't needed because we don't use operator>>, but istream_iterator for input (the fact that istream_iterator internally uses operator>> is irrelevant here; it's the job of the "iterator" header to make sure everything needed in the implementation of the iterator is included; indeed, on a compiler implementing export, might only be included in the corresponding .cc file of "iterator" (and thus not even indirectly in your own translation unit). Moreover "iomanip" isn't needed because you don't use any of the manipulators defined there (you need "iomanip" only for iterators which take arguments).
      --
      The Tao of math: The numbers you can count are not the real numbers.
    84. Re:more to it by maxwell+demon · · Score: 1
      Well, actually for simple file copying, you'd just use

      ifstream source(source_name);
      ofstream destination(destination_name);
      destination << source.rdbuf();
      if (!source || !target) throw runtime_error("Fail");
      (Also note that unlike your code, mine also handles read errors. Finding the error in your call to copy is left as exercise for the reader :-))
      --
      The Tao of math: The numbers you can count are not the real numbers.
    85. Re:more to it by maxwell+demon · · Score: 1

      But with GC, at least your bugs don't stick in your face by creating segfaults or the like. If you have bugs, they at least should be well hidden. :-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
    86. Re:more to it by Mr+Z · · Score: 1

      Here come all the flashbacks involving flashes of lights and boxcars moving at 0.9c. Thanks.

    87. Re:more to it by Mr+Z · · Score: 1

      How much is GCC's autovectorization actually kicking in though? SSE has all sorts of alignment constraints as I recall, and if the compiler can't prove alignment or minimum trip counts, it will often punt.

    88. Re:more to it by Mr+Z · · Score: 1

      I do waaaay more integer divisions than floating point divisions.

    89. Re:more to it by shutdown+-p+now · · Score: 1

      Sorry, I don't follow. What does integer division have to do with sorting?
      It's usually used to find the middle element for partitioning, for example. The code for std::sort in VC++2008 headers contains 6 integer divisions, most of them by 2.

      Sure it is, but it's still inappropriate to ever use it unless you really do want a particular kind of truncation on the answer.
      Yes, and very often it's either precisely what you want, or it's just good enough for the job to not bother with float.
    90. Re:more to it by dookiesan · · Score: 2

      Yikes. Using a 'for' loop you could have actually made the entire thing shorter (I think).

    91. Re:more to it by shutdown+-p+now · · Score: 1
      You should brush up your LINQ skills if you want your C# code to be a mystery to the uninitiated :)

      using System;
      using System.Linq;
      static class Program
      {
      static void Main()
      {
      Console.WriteLine(Console.ReadLine().Split((char[])null, StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)).Average());
      }
      }
    92. Re:more to it by shutdown+-p+now · · Score: 1

      Could be done, but short of summing the elements in a more concise way - v.sum() - what would it give you? The only optimized valarray implementation I know of is macstl, and that has not been maintained for more 2 years, so it seems that noone actually cares.

    93. Re:more to it by shutdown+-p+now · · Score: 1

      Mod parent up, please. He has spotted and explained it all, even the stuff that was genuine mistakes on my part, not deliberate flaws (note though that int division was deliberate - sometimes you want to do just that). Whether the explanations serve to disprove my original point, or rather to reinforce it, is up to you to judge...

    94. Re:more to it by shutdown+-p+now · · Score: 1

      I actually knew straight away where the problem was in that code, but only because I have ingrained in me that size() is unsigned thanks to the warnings from GCC (try writing a for loop that uses an int as the loop variable, and compare with something.size() as the condition).
      Unfortunately, gcc warns about signed/unsigned comparisons, but not about signed/unsigned mix in arithmetic operators. VC++ does the same.
    95. Re:more to it by EsbenMoseHansen · · Score: 1

      What part of "pseudo-code" did you fail to understand? I left out several details, including checking that source was at eof, fixing the whitespace handling if I insisted on using copy and so on. But the important thing was the resource handling, so that was what I emphasized.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    96. Re:more to it by Ed+Avis · · Score: 1

      Others pointed out the size_t versus int problem. gcc -Wsign-conversion will catch it; I am surprised that this isn't included in -Wall.

      In general, I agree that silent signed/unsigned or integer overflows are the biggest problem with C++ (and with C). The standard library really needs to include a safe integer type that throws an exception on overflow rather than silently giving the wrong answer.

      Does any of the code in Stroustrup's book have this bug I wonder?

      --
      -- Ed Avis ed@membled.com
    97. Re:more to it by Kristopher+Johnson · · Score: 1

      I agree completely. I hate seeing so-called "experts" who recommend using some crippled, archaic, pidgin version of C++, then complain that C++ is "too low-level."

      C++ is definitely not for the "I can learn any programming language in a weekend" kinds of people. It's complex, and has many warts, but trying to make it simple and clean is counter-productive. Stick with VB, C#, or Java if C++ isn't your kind of language.

    98. Re:more to it by shutdown+-p+now · · Score: 1

      The standard library really needs to include a safe integer type that throws an exception on overflow rather than silently giving the wrong answer.
      Actually, it's worse than that: signed integer overflow is undefined behavior in C++ (and C). It may wrap around, it may saturate, it may throw an exception, it may abort the program, it may format your hard drive, and it may do everything of the above randomly at any given case. This basically means that, as soon as you add two ints read from a console or a file, there's no saying on how your program might behave for some more creative inputs. Yet unsigned overflow is just fine, you always know what you get. Weird...

      On a side note, I've always thought about how great the checked keyword in C# really is.

    99. Re:more to it by Ed+Avis · · Score: 1

      signed integer overflow is undefined behavior in C++ (and C)
      In that case, why on earth don't C++ compilers generate code that throws an exception when signed overflow occurs? They'd be conforming to the standard by doing so, since any behaviour is allowed, and it would avoid a whole class of bugs, gotchas and security holes.
      --
      -- Ed Avis ed@membled.com
    100. Re:more to it by DerWulf · · Score: 1

      I'd say that leaking memory (which is far easier to do in C or C++) is a lot better then overwriting arbitrary program state or code (which is impossible in java or C#). Of course, C++ fanatics will just reply with "well, if you can't keep track of your memory allocations, array indexes and pointers you are too stupid to be a programmer" or some variation thereof. Which makes me wonder: why is it that most security leaks in databases, operating systems and web servers stem from buffer overflows? Are all those programmers stupid? If so, maybe memory management is a task better left to machines after all?

      Reading the linked article, I found it ironic that back at C++'s conception even C was in the same place as Java is now. "Real programmers" that did "real coding" would only use assembler because higher order programming languages are just too slow and for dummies anyways.

      Thing is, in the last 20 years it never paid of to use brain power where machine power would do. The former is a (expensive) constant while the later still grows exponentially.

      Beware of any one true path and that also goes for programming languages.

      --

      ___
      No power in the 'verse can stop me
    101. Re:more to it by Abcd1234 · · Score: 1

      Much of the worst code I've ever had to deal with is C++ code written by smart guys who don't know what parts of C++ to use

      Those guys aren't smart. They're "clever". There's a difference.

    102. Re:more to it by Abcd1234 · · Score: 1

      If your refcount doesn't reach 0, then you have a leak

      What? No one uses reference counting in modern garbage collectors, and cycles are comfortably handled in virtually all modern GC'd languages.

      That said, if spacetime complexity is something that concerns you, yeah, a GC does add additional wrinkles and is something you should be cognizant of. That said, most programmers can comfortably ignore it (assuming your language has a decent GC, anyway).

    103. Re:more to it by shutdown+-p+now · · Score: 1

      In that case, why on earth don't C++ compilers generate code that throws an exception when signed overflow occurs?
      Because it would be way too slow? On x86, they could use INTO (and I believe some DOS compilers did that when you enabled a certain flag), but even that is pretty slow. Also, a lot of people unfortunately rely on wraparound behavior, usually indirectly by pretending that int->unsigned->int conversion is always valid.
    104. Re:more to it by nuzak · · Score: 1

      using std;

      Seriously, it's actually okay to use in small modules or if you keep it to a block. Once you've done that, it's really not much noisier than Java.

      God forbid, however, you want to map a custom function across your vector. Fear and loathing are known in C++ as binder1st and binder2nd, respectively. Boost can make it tolerable, but introduce an error anywhere and the resulting error messages will fill you with an enduring and consuming hate for C++ and all who ever touched it, including yourself.

      --
      Done with slashdot, done with nerds, getting a life.
    105. Re:more to it by jhol13 · · Score: 1

      the majority of that complexity is not imposed on you Unless, of course, you have to touch code written by others.

      Then the fact that the syntax and semantics of preprocessor, templates and code itself all are different will drive you nuts. Unless discretion is used (no macro nor template meta-programming trickery, etc).

      The problem with C++ is that "most people don't understand" it. Unless you are unbelievably lucky the project you are in will have people who just cannot comprehend what on earth e.g. bind2nd() really does (i.e. how to fix a bug within the construct). And that is very simple compared to the template engine.
    106. Re:more to it by Ed+Avis · · Score: 1

      Way too slow... you know that a program that gives the wrong answer twice as fast is no use. Of course for speed-critical numerical code you'd give a pragma to the compiler to enable unchecked arithmetic. But personally I'd prefer the default to be something sane. You're right though that much existing code may stuff ints into unsigned ints and back again.

      For fun I hacked up a bounded_int class that checks at compile time that arithmetic operations are safe. For example

      bounded_int a = 5;
      bounded_int b;
      b = a;
      b = 2 * a;
      b = 3 * a; // compile time error - you need to use an explicit cast, which might throw

      This could be useful if you want to be completely anal about the ranges of your numbers (I believe Ada has something similar). And it has no run time cost (there is also an unsafe, unchecked conversion you can use if you really want).

      --
      -- Ed Avis ed@membled.com
    107. Re:more to it by Ed+Avis · · Score: 1

      Way too slow... you know that a program that gives the wrong answer twice as fast is no use. Of course for speed-critical numerical code you'd give a pragma to the compiler to enable unchecked arithmetic. But personally I'd prefer the default to be something sane. You're right though that much existing code may stuff ints into unsigned ints and back again.

      For fun I hacked up a bounded_int class that checks at compile time that arithmetic operations are safe. For example

      bounded_int<0, 10> a = 5;
      bounded_int<0, 20> b;
      b = a;
      b = 2 * a;
      b = 3 * a; // compile time error - you need to use an explicit cast, which might throw

      This could be useful if you want to be completely anal about the ranges of your numbers (I believe Ada has something similar). And it has no run time cost (there is also an unsafe, unchecked conversion you can use if you really want).

      --
      -- Ed Avis ed@membled.com
    108. Re:more to it by ChatHuant · · Score: 1

      For example, most people don't use the SSE stuff or even know about it. You can, for example, make a vector with 4 numbers in it and multiply it with another vector with 4 numbers in it. The result is that the four multiplications are done simulatanously

      But that isn't part of the C++ language, is it? It's just the compiler being clever. Is there anything specific to the language that would stop the C# or Java compilers from using a similar optimization?

    109. Re:more to it by aj50 · · Score: 1

      It gives the expected result that C should give. Most people probably already know this...

      All this shows is that C++ requires a similar level of intimate knowledge of it's standard libraries as C does. (Which is true and not a good thing but somehow it doesn't seem to hurt C much.)

      A good compiler will warn you when you have a signed/unsigned mismatch.

      The same good compiler would warn you of the mistake in the original C++ code as well as the return type of Vector::size and accumulate is known at compile time.

      --
      I wish to remain anomalous
    110. Re:more to it by Anonymous Coward · · Score: 0

      I'll be your huckleberry.

      Let's assume that we don't know whether the file is a binary or not, and the output must be binary compatible. We can't read it one char/int at a time because a Java int is four bytes, and what if the last chunk of the file is 3 bytes or less? We must read one byte at a time using a FileInputStream:

      try{

              byte copybyte;

              FileInputStream readItIn = new FileInputStream(new File(inputFilePath));
              FileOutputStream writeItOut = new FileOutputStream(new File(outputFilePath));

              copyByte = readItIn.read();

              while(copyByte >= 0){ // you get -1 at EOF

                      writeItOut.write(copyByte);
                      copyByte = readItIn.read();

              }

              readItIn.close();
              writeItOut.close();

      }
      catch (Exception e){

      /* Whoopsie code here, left out for brevity */

      }
      finally{

      /* Ensure garbage collection by nulling out the vars;
      we might not be passing out of scope right away, right? */
              readItIn = null;
              writeItOut = null;

      }

      Note that I reject your assertion that a finally clause is a bad idea. It's highly convenient. I may have used more lines of code than you did, but my code was more complete than yours, and more readable.

      Satisfied, smartypants?

      Tag! Yer it! MUHAHAHAHA! (Inserts pinky at corner of mouth)

    111. Re:more to it by Anonymous Coward · · Score: 0

      Ah... I typed the above at 80cpm, and missed the fact that both streams DO pass out of scope as soon as they leave the try block.

      How humbling!

      Nevertheless, aside from that little error, the rest of the code should be ok.

      My bad!

    112. Re:more to it by DerWulf · · Score: 1

      and now do it for unicode ;)

      --

      ___
      No power in the 'verse can stop me
    113. Re:more to it by Fulcrum+of+Evil · · Score: 1

      Well, yeah, but you could do that in C++ too: just use a vector class whose implementation used SSE primitives behind the scenes.

      You're missing the part where arrays are a part of python, while vectors are a library class in C++.

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    114. Re:more to it by SirSlud · · Score: 1

      If I have an object that should last the lifetime of an app, and a reference from that to another object, which has a list of other objects, to another object, to another object, to another object, to anther object, to a list of objects with an object that contains a list that is never cleared but just added too every time you hit 'built', thats bad architecture. But its also a reality in some environments.

      A language is only as good as its debugging tools are. A really awesome GC does nothing in with a 5 year old application with 100,000 lines of code when pertaining to a leak you inherited from a programmer who left 2 years ago. 'Most programmers' could mean not programming memory leaks in C++ app even in the absence of smart pointers. In reality, you will have programmers that create leaks, no matter how awesome the GC is. Because its not really a GC issue. GCs clean shit you don't need anymore. Programmers write code that makes the interpreter think you still need something.

      What? No one uses reference counting in modern garbage collectors, and cycles are comfortably handled in virtually all modern GC'd languages.

      Pray tell, how does a modern GC handle a case where you have an object thats still alive by programming standards through a maze of instances, but not still needed by 'design' standards? I know Python's GC sucks, but its not like Python is not in use in many production environments. I'm not under the impression that the Python GC is built on totally outdated architecture. I'm having a great deal of trouble troubleshooting leaks introduced by long gone programmers in a very large codebase. Its not all reference counting obviously - the object has to be accessible from the root, but our application is so large that python code just to analyze the heap is prohibitively impractical. At this point, I'm just trying to backport an extension that can analyse the object heap in C, and not add in the additional complication of actually affecting the refcount.

      --
      "Old man yells at systemd"
    115. Re:more to it by rjshields · · Score: 1
      You'd want to put the calls to close() in the finally block. Otherwise, if an IOException was thrown, the calls to close would not happen. This can cause a file descriptor leak on some systems (at least it does on Linux with a 1.4 or 1.5 JVM).

      Here's how I would write it:

      InputStream in = null;
      OutputStream out = null;
      try {
      in = new FileInputStream(inputFilePath);
      out = new FileOutputStream(outputFilePath);

      byte b;
      while((b = in.read()) != -1) {
      out.write(b);
      }

      } catch (IOException ioe) {
      System.out.println(ioe);
      } finally {
      if (in != null) in.close();
      if (out != null) out.close();
      }
      --
      In this world nothing is certain but death, taxes and flawed car analogies.
  7. MOD PARENT UP (Re:Maybe the real problem...) by jejones · · Score: 0, Redundant

    Would that (1) I had moderator points and (2) I could apply all of them to one article.

  8. Education, even at Universities, needs to Improve by Lord+Byron+II · · Score: 4, Interesting

    I'm continually amazed that the CS majors at my major US accredited university can't program using pointers, object oriented techniques, or parallelism. I think that there is an attitude among the professors that this material is difficult, so it shouldn't be worth a lot of points. As a result, the students don't bother to learn it.

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

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

  9. I got my B.Sc. in Comp. Sci in the 1970s and ... by Anonymous Coward · · Score: 5, Funny

    I think COBOL and Fortran education needs to improve. Nobody knows how to use it nowadays. These kids and their OO languages... HEY! Get off my lawn.

  10. C++ has issues by Anonymous Coward · · Score: 0

    EXCERPT from my blog (I don't want to be slashdotted)

    From my blog you may notice I am an inveterate C++ coder. It was the first language I taught myself after pascal and my preferred language for compact, fast code.The downfall of C++ may not be news to many, but often it is written by opponents of the language rather than those who love it and all of its quirks. So from a fan, C++, the prognosis is poor. I could write a book on this, but I tried to distill it down to article size.

    Principle of Least Surprise

    The first reason is that C++ violates the Principle of Least Surprise regularly and with malice of forethought. What do I mean by this? This compiles:

    class ThreadPool{
    public:
    ThreadPool(int thread_count); ...
    };
    int compute_bleah(int i){ ...
    }
    int compute_blah(ThreadPool pool){ ...
    }
    int main(){ //oops...
    compute_blah(5);
    };

    Why does this compile? Because unless you put the word explicit before the constructor taking an int as an argument C++ automatically converts any int to a ThreadPool whenever given the choice. The C++ community generally blames these sort of errors on the user for not being an expert in the language. This is stupid. In a sane language the language should do the most obvious and least damaging thing by default and require explicit permission to do anything else. In this case the language does the most bizarre and stupid thing unless you explicitly tell it not to.

    This is not an isolated example. If you are a seasoned C++ programmer you probably still run into something like this once every couple of years you hadn't heard of before. In fact, the language does this so much that people created whole careers around coming up with new examples of C++ code that does something stupid and then explaining why.

    Efficiency by default

    This is really more of problem #1, but it deserves its own section because although C++ often does non-obvious things because it hates you occasionally it does stupid and non-obvious things because it is trying to save you memory and/or processing power. A classic example of this is:

    class A{
    public:
    ~A();
    void doSomething();
    };
    class B:public A{
    ~B();
    void doSomething();
    };
    void clean_up(A *a){
    a->doSomething();
    delete a;
    }
    void main(){
    A *b_as_a = new B();
    clean_up(b_as_a);
    }

    This code will call A's version of the doSomething method and the fail to call B's destructor. Why? because virtual functions have a (very) slight cost in memory and performance so C++ does the most efficient thing by default rather than the least stupid. If you want things to work correctly you the coder have to explicitly tell the compiler to make the destructor and method virtual with the virtual keyword.

    Now, don't get me wrong. I know why this is. When C++ came out everyone in the C community was convinced that:

    1. Object oriented code could not be effecient
    2. noone should ever have or need more than 256K of RAM

    As it turns out the C weenies were not convinced on #1 anyway and we all know about #2. Unfortunately this causes a long-term problem for C++: Those who want efficiency have stuck with C regardless (embedded world, GNU UNIX, BSD, etc, etc) and those who don't need efficiency but want and OO language (more and more every year) just use a modern language without all the cruft.

    I would guess that some of those C weenies are looking at this and feeling pretty good about themselves now so let me just interject that if C++ is like the worst kind of coworker that does a lot for you but so poorly you wish they hadn't, C is the coworker who can be relied upon to do nothing for you at all. Yes, C has less of the annoying issues in terms of au

    1. Re:C++ has issues by IamTheRealMike · · Score: 5, Insightful

      C++ isn't going anywhere. Nearly all serious desktop software outside of Mac-land is written in it because the alternatives (Java? C#?) suck rocks. Large amounts of high performance code is written in C++. I don't know where you got the idea that people who care about performance use C from, that's flat wrong in my experience. I agree that D is a very nice language. It will make great strides in the next five yeras. However, maturity counts for a lot.

    2. Re:C++ has issues by EsbenMoseHansen · · Score: 1

      So let's see. While I will readily agree that C++ really needs a sane syntax, which would include having explicit the default, the real problem with the first program is poorly named functions and classes. Explicit would have saved you that time, but the poor naming would have killed you later anyway. The error in the second one is some programmer's inability to read warnings from the compiler, though again I agree that the default is a backwards. Yet, I have never been bitten by the either,eh, feature, though I have programmed C++ for some years now. (5? I forget).

      So will C++ die? Someday, I hope. The problem is that very few languages support the features I need and want. I always forget some, but a short list would be

      1. Ability to make domain-specific libraries reasonable. No, matrixA.times(matrixB) is not good enough, it really must be matrixA*matrixB or similar.
      2. Polymorphy --- static and dynamic, of course.
      3. Lambda functions (closures for extra points) with a simple, inline syntax.
      4. LALR or similar simple syntax (for making programming tools easier to make)
      5. Metaprogramming
      6. Reflection
      7. static typing, divorced from inheritance of course.
      8. target agnostic (the language really shouldn't assume the target. I want to compile to i386, JVM or power5 as I wish
      9. Reasonable performance. Say, no less than a 50% slowdown.
      10. Direct, easy callable to C. JNI is a good example of how not to do this :o)
      11. At least simple lambda calculus. I want to be able to take two functions and make a third from them, given the arguments and return types a compatible.

      I do not think these requirements are unreasonable. Yet no language comes close to doing all of these. I've found C++ to be the closests match, but especially the LALR, reflection and lambda functions are sorely missing.

      I'm always interested in hearing about languages who comes close to this ideal, btw :)

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    3. Re:C++ has issues by Anonymous Coward · · Score: 0

      The only language I ever heard of that comes close to all that is Common Lisp. And yes, it can be statically typed to large extent.

    4. Re:C++ has issues by gzipped_tar · · Score: 1

      Python maybe? It's quite close to your spec I think.

      --
      Colorless green Cthulhu waits dreaming furiously.
    5. Re:C++ has issues by edwdig · · Score: 1

      Why does this compile? Because unless you put the word explicit before the constructor taking an int as an argument C++ automatically converts any int to a ThreadPool whenever given the choice. The C++ community generally blames these sort of errors on the user for not being an expert in the language. This is stupid. In a sane language the language should do the most obvious and least damaging thing by default and require explicit permission to do anything else. In this case the language does the most bizarre and stupid thing unless you explicitly tell it not to.

      That's basic C++, not an expert topic by any means. The language would be a pain to use if it didn't do things like that. For an example in your integer conversion, if you're doing any sort of custom math class (say a Big Number class or a Fixed Point class), you really the compiler to automatically convert ints into the proper class. If you're working with strings, you want the compiler to promote a string literal into an std::string when necessary. You came up with a contrived example to explain your point. If you've got a case like that where the normal behavior doesn't make sense, then go ahead and use the explicit keyword, that's why it's there.

      This code will call A's version of the doSomething method and the fail to call B's destructor. Why? because virtual functions have a (very) slight cost in memory and performance so C++ does the most efficient thing by default rather than the least stupid. If you want things to work correctly you the coder have to explicitly tell the compiler to make the destructor and method virtual with the virtual keyword.

      I resisted C++ for a long time, as I thought not having virtual functions by default defeated the point of using classes. I'm still not thrilled with it, but I've learned to take it as it is. I think C++ is a terrible language for designing core libraries, but it is rather useful when designing applications. At that point you know if it makes sense or not for something to be virtual.

      If everything was virtual, I'm not sure it would necessarily mean C++ was a better language, I think it would just change what projects people use it for. Right now it's a great middle ground for embedded and low end systems - you get to pick and choose what parts of OOP benefit your project. Again, going back to one of my examples before, if you wrote a Fixed Point math class and had everything virtual, that would significantly hurt your performance.

      If you don't believe me take a look at mozilla.org's Portability Guide. I can sum it up for you if you'd like: if you have to write C++ please use as little of it as possible. Oh and another list of all the stupid reminders you have to continually provide to compiler to minimally reduce unexpected behavior. I actually work on embedded software at NASA and they have pretty much the same thing.

      To be fair, a lot of that is due to Mozilla.org's desire to run on old Unix platforms. The big Unix developers stopped putting much effort into their compilers in the early to mid nineties, before a lot of the fancier stuff in C++ existed, let alone was standardized.

    6. Re:C++ has issues by EsbenMoseHansen · · Score: 1

      Python maybe? It's quite close to your spec I think.

      Close (I prefer ruby, but they are very similar on this level). But it is sorely lacking in the static department (metaprogramming and typing and polymorphism). It also falls short on the performance target, though I can and do disregard that for many applications.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    7. Re:C++ has issues by EsbenMoseHansen · · Score: 1

      The only language I ever heard of that comes close to all that is Common Lisp. And yes, it can be statically typed to large extent.

      Thank you (and everyone else) for suggestions. I have never seriously learned Haskell because it's OO support is so poor, and even though I forgot it on the list, this is also important. Is LISP stronger in this area?

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    8. Re:C++ has issues by Anonymous Coward · · Score: 0

      Common Lisp has the most powerful OO system this side of Smalltalk, including Metaobject Protocol and so on. At least I think so, everyone seems to understand the term object orientation differently, so it might not do exactly what you want. (see: http://www.gigamonkeys.com/book/object-reorientation-classes.html http://www.gigamonkeys.com/book/object-reorientation-generic-functions.html )

      Note that LISP usually refers to older dialects of Lisp. There are several dialects of Lisp with varying capabilities. I prefer Common Lisp, although for many it lacks sufficient theorethical purity and suchlike of Scheme...

    9. Re:C++ has issues by SageMusings · · Score: 5, Interesting

      Real Mike,
      you have my full attention. Please, support your assertion that Java and C# suck rocks.

      C++ can be fast at execution time but the development time is prohibitive in many applications where you need to be agile and actually ship code in a hurry. I try not to get hung up on all the esoteric points of different programming languages, although I am quite amused to read other's comments. Yet, I will hazard a post on this topic.

      I learned C++, not all of it to be sure, but the portions 85% of us might need in a given project. It may be intellectually stimulating to code an app form a "purest perspective" but many of us have to earn a living and produce a lot of code in short order. C++ does not fit this bill. Most applications just have to work and work today, not next quarter. Then we have to extend the app after a few months. Since C++ is quite a bit harder to read and I have to learn code I did not write in short order to perform this maintenance, I enjoy Java and C# apps a lot more than ones coded in C++.

      Please, tell me why Java and C# suck compared to C++ in the practical world. Nearly all of us are not writing low-level, time-critical code. Most of us write apps for business transactions. I happen to write business software that is widely distributed and the C++ performance boost is nullified by the latency of remote calls to distant servers.

      Please, tell me the advantage of writing an app in a year vice 6 months.

      There are many languages because there are many problem domains. C++ is not the best language. There is no best language, period.

      Nearly all serious desktop software

      Finally, it has been my observation most "serious" code is no longer constrained to the desktop.

      --
      -- Posted from my parent's basement
    10. Re:C++ has issues by EsbenMoseHansen · · Score: 1

      The orientation is of little consequence. I will have to put it on my todo list, I see. Thanks!

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    11. Re:C++ has issues by Anonymous Coward · · Score: 0

      It's quite sad to see millions and millions of code lines written for Linux desktop using static crap language like C++ and crap frameworks like kde and gnome. Enter Mac world and learn how to make applications easier with dynamic Objective-C and cocoa framework. Cocoa works nicely with Ruby, which is not possible in static languages. Especially, check the Macruby project.

      The most sad part is that Gnustep have been available for Linux for ages. But the opportunity was completely lost with gnome/kde and gnustep became an ugly relic - nothing like cocoa, despite all the similarity.

    12. Re:C++ has issues by Anonymous Coward · · Score: 0

      It depends what type of market you are focused in. Nearly all recent desktop software will be written in .Net with Windows Forms.

      Take a look at the developer jobs available on your local job site. C++ is very much in the minority compared to .Net and Java.

      My employers are slowly phasing out C++ because it is simply quicker to develop in .Net, which has a very powerful framework for developers. There is less code to write as you can usually find something in the framework to work with.

      In business applications the speed difference between C++ and C# is not significant to undermine the fact that C# is quicker to develop in and maintain. The fact it might take 0.3 seconds to render a page as opposed to 0.2 seconds in C++ isn't going to be important in too many systems.

      I worked as a Unix C programmer for 9 years but couldn't get a similar job in my commutable area, so had to go where the money is, and that is mostly .Net and Java nowadays.

    13. Re:C++ has issues by Anonymous Coward · · Score: 0

      C++ isn't going anywhere. Nearly all serious desktop software outside of Mac-land is written in it because the alternatives (Java? C#?) suck rocks.

      I think you mean "on Windows", not "outside of Mac-land". I'm running Linux here, and almost all of the desktop software I'm using is written in C. A few of my desktop apps are in Python; they're impossible to tell from C apps (except possibly by noting that they never crash). The only program I'm running that's written in C++ is Firefox.

      D may be a nice language, but if you're talking about desktop software, I see zero desktop applications written in D today. Even Mono is doing much better in that department, bad as C# may be.
    14. Re:C++ has issues by Nicolay77 · · Score: 1

      And C++ & Lisp are my two favorite languages.

      --
      We are Turing O-Machines. The Oracle is out there.
    15. Re:C++ has issues by Anonymous Coward · · Score: 0

      I absolutely agree that D may not be it now or ever. It just happens to be one of the languages closest to C++ in featureset. My point is that you don't actually need C++ features for almost anything these days and if D matures or a new language provides similar features there won't be any reason to use it at all.

    16. Re:C++ has issues by Anonymous Coward · · Score: 0

      That's basic C++, not an expert topic by any means. The language would be a pain to use if it didn't do things like that. For an example in your integer conversion, if you're doing any sort of custom math class (say a Big Number class or a Fixed Point class), you really the compiler to automatically convert ints into the proper class. If you're working with strings, you want the compiler to promote a string literal into an std::string when necessary. You came up with a contrived example to explain your point. If you've got a case like that where the normal behavior doesn't make sense, then go ahead and use the explicit keyword, that's why it's there. Show me a library where a single constructor argument is more likely to be a conversion than an initialization. Either way,conversions should be explicit not a re purposing of a constructor. The point is not that it is impossible to deal with, it's just stupid. A new programmer can easily miss it and I've seen plenty of libraries that don't use explicit at all. When I do interviews most of the software engineers have never heard of it (Including ones who took C++). When I talk to other C++ programmers a good 50% haven't heard of it. And why should they? C++ is all language and no library so you spend years learning how to use it and then you have to write every damn thing from scratch anyway.

      Again, going back to one of my examples before, if you wrote a Fixed Point math class and had everything virtual, that would significantly hurt your performance. Again this is not the common case. C++ continually chooses optimization over clarity. In the modern programming environment it makes much more sense to make the person who wants extreme optimization to use a final keyword than it does to make everyone else who doesn't care use virtual. I realize there are historical reasons, but frankly when I choosing a language to code in I don't care about it's abused childhood I want to know why to use it now.

      To be fair, a lot of that is due to Mozilla.org's desire to run on old Unix platforms. The big Unix developers stopped putting much effort into their compilers in the early to mid nineties, before a lot of the fancier stuff in C++ existed, let alone was standardized. I appreciate the reason, but from a practical perspective who cares? Embedded developers (the niche that might want C++)have a lot of different compilers. As a result most of the embedded C++ coding standards say the same thing. So the only group that has a good need for C++ features can't use them.
    17. Re:C++ has issues by quigonn · · Score: 2, Insightful

      Hello Mr. n00b, you can fulfill agile requirements in any programming language. And, no, "shipping code in a hurry", as you put it, is not agile, absolutely not. It's more the Dilbert version of agile development.

      --
      A monkey is doing the real work for me.
    18. Re:C++ has issues by MatthewHays · · Score: 1

      My last project for the FX desk (front office trading application) at a top American InvBank, was written by me in under 6 months using C#. It executes easy $500m+ a day in business across multiple exchanges. It integrates with custom keyboards (USB HID), contains plenty custom controls, is built using a pluginable/configurable architecture, deployed across the world, etc etc blah blah.. It was an absolute pleasure to write, it is extremely stable, and the development tools are excellent. I came from a long embedded C/C++/MFC background, and I would never turn back. I have a job to do, traders to keep happy and I consider C++ GUI dev to be completely outclassed by C# (I've even written non-trivial server side C# windows services which are currently performing perfectly).

    19. Re:C++ has issues by Sweetshark · · Score: 1

      Yes, you can be as agile as in "any" programming language in C++ - after you have the whole dev team locked in a chamber for half a year and let them fight out the coding conventions and the language subset and standard libs to use and have written extentions to your CVS to enforce the decisions (because nobody will always remember everything from the 300 page book that was agreed on). But, well, that kinda defeats the purpose.

    20. Re:C++ has issues by IamTheRealMike · · Score: 1

      You misread my post. I said that for desktop applications Java and C# suck rocks. Name me one popular retail desktop application written in Java, that isn't actually related to Java programming in some way. I can't think of any. I quite agree that Java and C# are excellent languages, the right tool for certain domains. But trying to write any serious desktop app in Java is an exercise in pain. The IBM guys managed it with Eclipse, but only by writing a replacement for the entire Java widget toolkit - and it still has "issues" with memory management.

    21. Re:C++ has issues by quigonn · · Score: 1

      You don't need to do that to start a C++ project. I don't know where you have that kind of prejudice or stereotype, but in all the C++ projects that I was involved in, such things never were an issue. In theory, such issues would probably come up with basically every programming language, but in practice (at least in my experience), people are mature enough to stop behaving like some programming.reddit.com pussies, and simply get things done.

      --
      A monkey is doing the real work for me.
  11. C++ too ich and is fast becoming a niche language. by MadHungarian · · Score: 0, Offtopic

    I do believe that most people who learned C++ did not do so in an academic environment. It was more on the job training. When I interview a candidate, one question is "How do you rate yourself as a C++ programmer on a scale of 1 to 10?" It is amazing how many of them in the 8-10 range cannot explain the difference between a reference and a pointer, and how you initialize a reference in a class. Or what mutable means, or what templates are, or even what the three key elements of object oriented programing. C++ is a very (too?) rich language. I think many of the features will become less and less used and atrophy like our appendixes. Eventually C++ will be come the next FORTRAN.

    BTW I've worked with C++ since 1992, but not any more. I can be 5 times more productive in C#. I actually dread having to go back into C++ code to fix a problem. 90% of the code that was done in C++ can now be done in C#.

  12. Re:Education, even at Universities, needs to Impro by IamTheRealMike · · Score: 5, Interesting

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

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

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

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

  13. C++? Er det ikke dødt endnu? by Anonymous Coward · · Score: 0

    Bjarne, du lukker lort ud igen. Dit sprog er så godt som ubrugeligt. Hvad med at starte på en frisk uden al det gylle, du har lukket ud om C i alle de år?

    Det ville også klæde dig, hvis du lærte noget C, før du begynder på at "forbedre" det.

    På forhånd tak.

    1. Re:C++? Er det ikke dødt endnu? by Carewolf · · Score: 1

      I think you have some kind of language problem.

      I can understand your difficulties. C++ is a mucher simpler and much more logical language than English, if you can't even master English, especially in Denmark where we have a mandatory 7 years of English education and everybody speaks and writes fluent English - No wonder you can't understand C++

      Or maybe you just need to study harder.

    2. Re:C++? Er det ikke dødt endnu? by Anonymous Coward · · Score: 0

      Oh, I understand C++ just fine, thank you very much.

      I'll have to wonder how you you are, though, since you talk about 7 years of English in school. I didn't even know it was that much these days. That'll put you somewhere in the late teens?

      I currently fix other people's broken C++ for a living. C++ is great job security! So in that way C++ is indeed 'great'.

      If you claim to understand C++, it means two things to me: 1) You have no clue what you're talking about, because noone fully understands C++, which is one of its bigger weaknesses, and 2) You're way too full of yourself.

      Come back when you've got a few years of practical experience with C++, especially working with other people's C++ code, and then we can talk.

      BTW, I can recommend the C++FQA if you're too 'busy' to actually learn a bit about C++. But no doubt you'll take one look at it and say 'OMG, he's got no clue!' and then go back to trying to figure out how to get rid of those zits.

      Sincerely yours,
      A Dane who didn't receive 7 years of mandatory English education in school and who actually knows enough about C++ to never consider it for a new project.

      P.S. C++ has undecidable gramamr. I think that makes it more complex than English, but suit yourself.

  14. Re:I'm just glad they're teaching C++ actively aga by thetartanavenger · · Score: 5, Informative

    Where are they teaching it actively again? I'm a student on computer science at the moment and all they teach in any depth is Java. The only reason I know c++ is my desire to learn it, despite the fact that various parts of my course have recently required a fairly in depth knowledge of c++.

    My favorite lecturer quote, "Oh, I don't really do any coding at all".

    --
    Who need's speling and grammar?
  15. Programmers needs to improve by Anonymous Coward · · Score: 0

    It's that way because programmers insist on using features they don't have to just because it's there. They read Meyers, and think, "that's cool! I'll do that" I'm guilty of that one.

  16. Right on by Anonymous Coward · · Score: 0

    I am with Bjarne on this one.
    Bjarne Stroustrup, creator of the C++ programming language, claims that C++ is experiencing a revival and
    that there is a backlash against newer programming languages such as Java and C#. "C++ is bigger than ever.
    There are more than three million C++ programmers. Everywhere I look there has been an uprising
    - more and more projects are using C++. A lot of teaching was going to Java, but more are teaching C++ again.
    There has been a backlash.", said Stroustrup.

    He continues.. ..What would the world be like without Google?... Only C++ can allow you to create applications as powerful as MapReduce which allows them to create fast searches.

    I totally agree. If Java ( or Pyhton etc. for that matter ) were fast enough why did Google choose C++ to build their insanely fast search engine. MapReduce rocks.. No Java solution can even come close.
    I rest my case.

    1. Re:Right on by SanityInAnarchy · · Score: 1

      We've seen this before.

      Oh, and I kind of doubt Bjarne himself would've said that about MapReduce, given that MapReduce could be created in many other languages. For that matter, Google extensively uses Python. If C++ were good enough, why is Gmail written in Java? And so on...

      --
      Don't thank God, thank a doctor!
    2. Re:Right on by mollymoo · · Score: 1, Informative

      Most coding in the real world isn't writing performance critical distributed applications which are the cornerstone of multi-billion-dollar corporations. It's writing business apps and websites. For those, Java and C# shit all over C++, because they make not fucking up much, much easier.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    3. Re:Right on by rubycodez · · Score: 1

      there are plenty of other compiled langauges that can produce fast code, some even faster than C or that bloated bolt-on crap to it Bjarne Stroustrup continues to shit out. He's an impediment to progress and should go the way of the dodo

  17. Re:Education, even at Universities, needs to Impro by Anonymous Coward · · Score: 0

    I've seen the same thing at my university, except my skill lies in C rather than C++ (I code ASM and C on a daily basis). Pointers are your best friend when you know how to use them.

  18. Re:Education, even at Universities, needs to Impro by MT628496 · · Score: 1

    Maybe it's not the case everywhere, but here the problems it that the CS department teaches entirely theoretical computer science, expecting you to learn everything else when you get to industry.

    This is a horrible attitude, as many students (including myself) are not going into software development. Now, I took the initiative, bought a bunch of books, read articles and practiced using all of the techniques/design patterns etc for both OO and procedural languages.

    Of course, students can't be taught everything in school, but if you go and ask a classroom of students here what polymorphism is, you'll get a lot of blank looks. The same goes with memory management in C/C++. People just don't know how to do it.

    It's a real problem here and I don't really know the right way to fix it.

  19. He should go work for Microsoft ... by Pinky's+Brain · · Score: 5, Funny

    "The standard will be finished in late 2008, but it takes forever to go through all the hoops of the ISO process."

    They have a solution for that ...

    1. Re:He should go work for Microsoft ... by Anonymous Coward · · Score: 0

      They have a solution for that ...

      Funny you should say that... the chair of the C++ standardization committee is Herb Sutter. He does work at Microsoft.

      (I just thought this was ironic, BTW; this isn't really a bad thing. Microsoft does a lot of work with C++ and C++-like languages, such as C# and managed C++, so this is actually an area where they have some real expertise. It's not like the OOXML situation at all. Besides, Herb Sutter is a nice enough guy, independent of the MS connection.)
  20. Bjarne Stroustrup doesnt have a clue by Anonymous Coward · · Score: 0

    After reading numerous articles from this guy it is clear to me that Bjarne Stroustrup has no idea what he is talking about in regards to C++.

  21. Not just C++ by ErichTheRed · · Score: 1

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

    I came into IT through the back door. I was a science major in college, messed with computers all the time as I was growing up, and realized I could make a better living in IT than I could in science. So yes, I don't have a ton of programming experience. I have picked up a lot of information over the years on how operating systems actually work under the hood though.

      If I'm given another internally-developed desktop application that does simple database calls requiring a dual-core processor and a minimum of 512 MB of RAM to run, I'm going to go crazy.

    I agree with Stroustrup. There really isn't enough good computer science education these days. Computers have gotten so fast and powerful that there's no need to optimize code anymore. This explains why everyone's programming in Java and .NET. Without super-fast computers, any programmer would shy away from compile-at-runtime software. The solution for making a program run faster these days is to throw a bigger box at it. I deal with this every day, trying to explain to project managers and CIOs why we need more money in the hardware budget again.

    And I agree with everyone who correctly points out that this isn't 1981. Sure, we don't have to squeeze an entire video game into a 4K Atari 2600 cartridge anymore. But I've seen stuff written internally that's just total garbage, and all of it could be solved by thinking a little bit before attacking the problem. Most of the stuff I deal with is straight from http://www.thedailywtf.com./ Think of massive switch() statements that check hundreds of possibilities, iterating over each entry in a million-row database query result, etc. Everyone in corporate-land has dealt with apps like these...click the Submit button and wait 3 minutes for a result. :-)

    Some of this can't be avoided. Most corporate IT departments don't understand the difference between good and bad applications. But I think that if we get people interested in embedded systems or something, things may fix themselves. I highly recommend not teaching CS students Java as their first language....

    1. Re:Not just C++ by skrolle2 · · Score: 1

      Computers have gotten so fast and powerful that there's no need to optimize code anymore. This explains why everyone's programming in Java and .NET. I was with you up until the above. What? No, no. Java and .Net are popular because you get the power and flexibility of C++ and other compiled OO languages, but you get the increased productivity that managed code gives you. It is a *lot* easier to create an application in Java or .Net that is good enough, runs fast enough, and has no memory leaks, than it is to create the same application in C++.

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

      That people create stupid applications and don't know the basics of efficient algorithms isn't something you can blame managed languages for, if those people had to do their stuff in C++, it would still be horribly inefficient, only now with more memory leaks.

      I highly recommend not teaching CS students Java as their first language... Me neither, Lisp is a much better choice.
    2. Re:Not just C++ by Anonymous Coward · · Score: 0

      My first language at Univ. was ML.

      C++ outside of SYSTEMS programming is the WRONG choice of tool. It is NOT an APPLICATION language.

      Anyway, there are far better choices for domain specific tools.

      C++ was designed as a SYSTEMS language, not for anything else.

      If you find you pushing or using C++ for applications, then somebody made the WRONG choice. Fanboism does not belong in software development, anyway developement is a BLUE collar job anyway, unless you are a domain specialist in which case these are just tools and fanboism is not a factor.

      What I hear on slashdot regarding C++ is 90% fanboism.

    3. Re:Not just C++ by gbjbaanb · · Score: 1

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

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

      the thing is, if you tell a less-capable programmer that he doesn't have to worry about memory, he'll think christmas has come early and he will stop worrying about memory... as a result his code will become poorer, resource consumption will increase dramatically, performance will tank and scalability will be non-existent. And his code will become even less maintainable.

      Now make him program in a language where he is punished for cocking things up, he will *have* to become a better programmer or nothing he does will get released.

      Now, that's an ideal, in the real world poor code will still get shipped to customers regardless of how it was developed; but the code written in an 'easy' langauge will still contain bugs.

      eg. I saw a recent question on our internal tech mailing list - someone asked why his code was failing to connect to the DB, he was told "oh you have to put gc.collect() in any loop tht connects to the DB to fix that".

    4. Re:Not just C++ by ASBands · · Score: 1

      This is what I love about going to school at Georgia Tech - we work with embedded systems where performance is absolutely critical. For an introduction to real programming class, we started with transistors, built processors, memory and a bus architecture from there, wrote assembly code for that processor architecture and eventually wrote in C for the Gameboy Advance. Performance was a big deal. In the snake game, for example, you were fully capable of drawing each pixel of the snake one at a time, but using the DMA would make your game playable. You didn't have to double-buffer, but you would get a horrible tearing effect if you didn't. Working with a 16 MHz processor where there is no operating system doing any "magic" for you is something every CS major should have to deal with.

      Artificial intelligence is another example of a place where performance matters. Even on a quad-core 3.2GHz machine, solving np-hard problems is quite a task - the method of solution matters much more than individual implementations. For example, in the n-Queens problem, solving with a search takes quite a bit of time, yet the constraint satisfaction solution can solve huge boards in less than a second. In path finding, adding a single operation to an evaluation function can greatly increase the amount of time it takes to solve the problem.

      Coming back on topic - we never really study C++. C++ is the first real language I learned back in middle school when I really wanted to study computing. Sure, I'm fully capable of using C++'s dynamic polymorphism, but the more I used "vanilla"-style C, the more I realized that, even when programming in C++, there is no real need for the vast majority of C++'s features. I could open an ofstream - but what was wrong with a simple fopen? The one thing C really lacks is a try/catch system, but there are alternatives to everything (if ((int*)0 == iArray = (int*)malloc(10 * sizeof(int)))). For systems programming, I'd rather just use C, where I can almost see how the compiler would write the assembly code. For intelligence programming, I'd rather use Lisp, where the reflection is incredibly inherent to the language itself. For almost everything else, where performance is not absolutely critical and a good UI means a lot, I would rather use C# or Java, as the languages prevent me from mucking everything up (Java is much better at it than C#, but C# is more fun to develop in) and polling the user is simple.

      So, what is the best language to teach new computer science students? Well, here, all the CS majors learn Python and all the engineers learn Matlab (the CS majors eventually learn Matlab, too). Is this the right thing to do? My personal experience in the matter is teaching two of my friends Java (one of whom knew Matlab, the other knew Python). There were many issues that came up from what I call a "fundamental misunderstanding of the way computers actually work." Sure, there were minor syntactic things like putting a semicolon at the end of each line as well as more advanced concepts such as real object-oriented programming. However, things like references and scoping, the difference between a "value-type" and "reference-type" completely went over their heads. Is this something people should have to worry about when they're first starting? I think so.

      In my opinion, Java is the best language to teach people who are just starting. Sure, it has its issues, but it manages to hide all the really messy memory-related stuff while ingraining important things like scope and type into a programmer's head. The ability to write your own quicksort and binary tree is much more important than making sure you clean up every single variable as it falls out of scope. Besides, memory management is a logical extension to what someone already knows about the language.

      Just my 3 cents (inflation).

      --
      My UID is a prime number. Yeah, I planned that.
    5. Re:Not just C++ by skrolle2 · · Score: 1

      the thing is, if you tell a less-capable programmer that he doesn't have to worry about memory, he'll think christmas has come early and he will stop worrying about memory... as a result his code will become poorer, resource consumption will increase dramatically, performance will tank and scalability will be non-existent. And his code will become even less maintainable.

      Now make him program in a language where he is punished for cocking things up, he will *have* to become a better programmer or nothing he does will get released. That's a rather elitist and not very constructive standpoint. You want higher barriers of entry to programming so that YOUR job gets easier, but the problem is that you would get much fewer applications done that way, and that in turn means that you wouldn't have that much work to do, and then you'd be fired. :)

      I'm a big fan of low barriers of entry. Yes, you will get five million schmucks producing five billion memory-leaking resource-hogging maintenance nightmares, but you have to remember that those corporate applications are created to make something easier, to save work, and they usually do that, despite being the horrors they are. Also, some of those "programmers" rise to the task and become real programmers, and if not for the low barrier of entry, they might not ever have done so. We need future generations of good programmers as well, and if you say "It's C++ or NOTHING" you'll scare away a lot of presumtive programmers for no good reason other than to satisfy your own elitism.

      And that's bad in the long run.
    6. Re:Not just C++ by gbjbaanb · · Score: 1

      Yes, you will get five million schmucks producing five billion memory-leaking resource-hogging maintenance nightmares, but you have to remember that those corporate applications are created to make something easier, to save work, and they usually do that, despite being the horrors they are Tell that to someone who's just lost his Word document and see how much he agrees with you.

      We do need low barriers for entry, but that is not created by making things easy. Its made by encouraging junior programmers to start off junior and become better. It doesn't have to be hard at first, not if you have work that is within your skills and any form of mentor (usually the more senior programmers who were junior themselves). When I started coding, I didn't think I would be allowed to write the company's entire runtime framework.. and I wasn't. There's no surprise there, and I got better. Others can become "elite" too, but only if we do not accept sub-standard work as good. Imagine if we had the same low-barrier attitude towards nuclear engineering :-)

      Besides, those maintenance nightmares make more work, so much so that you can end up spending all your time fixing them and not creating anything new or useful at all.

      No, we need to encourage programmers to become better themselves, to learn better practices, to improve themselves. There's a place for juniors, and that's making the step towards becoming seniors.
    7. Re:Not just C++ by shyster · · Score: 1

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

      I'd just like to point out that that's not a memory leak, that's by design. The objects *are* still referenced, *are* still reachable, *are* still callable (and, in fact, are called), so therefore should *not* be deleted. What's so hard to understand about that?

      Nobody said Garbage Collection means you don't have to worry about memory (or that it can make up for broken code) - it just means you don't have to worry about *collecting* memory. Do you honestly think those Princeton guys would have had less bugs in C++?

  22. "C++ is a language strongly optimized for liars. " by Anonymous Coward · · Score: 0
  23. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    Perhaps I should have made sure to include some HTML code in there...something like...oh...I dunno...

  24. C++, the assembly language of today by Anonymous Coward · · Score: 0

    The fact is that, in C++, OOP is purely a structural thing, not a conceptual thing that goes through the environment.

    With this freedom, you have to device enormous amounts of information just to cooperate with other programmers, and just so people can begin to do the work.

    OOP hasn't been slow, however, the earliest implementations of this concept was dynamic, and was done in virtual environments, so that would explain slowness.

    C++ is basically the assembly language of today, with its performance-oriented level of interaction with the machine. Throwing more concepts on this platform is not going to improve it, HOWEVER, if you give it at least 20+ years, when people aren't taught the other paradigms from the start, a behemoth framework is has been tacked on it, so it's basically #include and start coding. C++ is basically Windows on MS-DOS.

    I know, I've been programming in C++ for eight years now, and assembly language before that.

    -Ray

  25. Re:I'm just glad they're teaching C++ actively aga by cbart387 · · Score: 3, Informative

    Where are they teaching it actively again? My school is. In fact, C++ is the primary language you learn on. There's some Java classes to expose you to it and even brief exposures to some other misc. languages (ADA/LISP/PROLOG). We also program in C for some of the classes geared towards UNIX system programming. It's a nice balance because with Java EVERYTHING is an object and it's likely to confuse freshman. Heck, it first confused me with these static mains coming from a C/C++ background. At least with C++ you can start with just functional programming to get the basis of what is variable/function/const etc and save objects till the second semester. From my experience that seems to work pretty well.
    --
    Lack of planning on your part does not constitute an emergency on mine.
  26. Note to Bjarne, please stop! by tralfaz2001 · · Score: 0, Troll

    Dear Bjarne,

    Your language is broken. It was broken very early on, but at least it could be described in 200 pages of densely printed text. Now it has grown to insane proportions in ever more elaborate attempts to add feature upon feature in an effort to satisfy every possible programmers syntactic fetish. Until it is at the point where anyone attempting to use the language spends more time trying to master the tool, rather than using the tool to create the end result.

    Because of the absurd feature set, it has become nearly impossible to master the full breadth of the language. This manifests itself in the worst way when you have a group of coders each knowing different features of the language, with only a small subset that makes up the intersection of every coders C++ skill. The end result is that programmer A spends half his/her time trying to figure out what programmer B did with the language, rather than the what problem the code was trying to solve.

    The most important thing to teach about C++ is how not to use it. By that I mean teachers should be telling their students, "This language has a 1000 features (or is it 5000 now I lost count), you should only learn about 100." The key is which 100. It is great for low level coding, an improvement over C if used judiciously. If used to construct complex object systems it is a horrible choice. Higher level dynamic languages are the way to go.

    Bjarne if C++ is to continue to be used, you need to stop dumping more garbage into the putrid landfill that C++ has become. Instead it should be stopped in its tracks, and the programming community should restart a new C extension that takes some of the useful ideas of C++, simplifies them, and carefully limits any attempt to add features without any real value. In short do what you completely failed to do.

    Oh and Bjarne your language deity status is here by revoked due to abuse of power.

    1. Re:Note to Bjarne, please stop! by twistedcubic · · Score: 1

      One of the reasons C++ will never die is that it is extremely useful to people who write highly specialized code. There are A LOT of people/groups who do this (and you will never believe this, but that's your problem). For some things, even doing quick proof-of-concepts in Python/Perl/C/Whateever would be a pain because representing basic objects is so complicated that they can only be expressed easily in certain languages. It seems to me that people who are turned off by C++ see its misuse in corporate environments, where any simple, general-purpose programming language will do. In other areas not as visible to the typical contract/corporate programmers, scientists and engineers need a language powerful enough to reasonably represent almost any concept they need. C++ is the best thing we have.

    2. Re:Note to Bjarne, please stop! by gbjbaanb · · Score: 2

      Seeing as you're counting the STL in that list of features, I trust you do the same for Java or C# - how many do they have if you count the innumerable library features they support?

    3. Re:Note to Bjarne, please stop! by Chapter80 · · Score: 1

      Bjarne if C++ is to continue to be used, you need to stop dumping more garbage into the putrid landfill that C++ has become.
      Agreed. Unfortunately, you are making the classic mistake of closing the bjarne doors after the horses escaped.
    4. Re:Note to Bjarne, please stop! by Anonymous Coward · · Score: 0
      Is he counting STL? I don't see where.

      Fact is, there's 5000 language features not including any libraries...

  27. Too little too late syndrome by thelima · · Score: 0, Troll

    For me it's typical "too little too less" syndrome. C++ played its important role years ago. Since then world has hanged dramatically. Current buzzowords dynamic languages, lambda expressions, clsoures and all this stuff and nobody cares if it makes sense or not. Sure - having known C or C++ it gives a lot advantages - You understand difference between heap, stack and pointers memory management - and gives You *real* understanding what, for example, closure is. But, on the other hand - who cares nowadays, except some really specialized areas like system development (actulally done in C), game development (partially) or HPC development (also partially). Actually nobody. That's said. Noody cares about C++0x or whatever it's named... Having 10+ years of core C++ development I actually even don't wanna read this spec. Word's going forward, languages going forward and nobody cares nowadays about unicodes support build in language or huge and convenient standard library (oh, maybe Ruby still do, last time I checked Ruby lacked unicode support also...). So far well C++ but don't expect people be excited now.

    lima

  28. Still builds too slowly by ahornby · · Score: 1

    C++ header files basically guarantee a slow build due to reparsing. Precompiled headers only help if you don't change a prototype.

    If you could have C++ but pull class/function prototypes out of the object files like with Java or C# it would fix a lot of build time problems as you would never need to reparse a header.

    http://gcc.gnu.org/wiki/IncrementalCompiler may be of use if you still hold out hope of faster C+ builds...

    --
    -- Thorin sits down and starts singing about gold.
  29. Poor use of C++ by MosesJones · · Score: 0, Troll

    I think that most poor use of C++ can be traced to the use of C++. C++ was about the fifth or sixth language I worked with professionally and without a doubt it was the biggest load of crap out I've ever had the misfortune to come across. Things like "friends" which enabled muppets on the project to complete subvert the principles of the project. The brain dead syntax (inherited from C like Java and C#) which values keystrokes over clarity. Unlike PHP or Perl where only the clinically insane would use them on a large scale (30+ developer) project C++ was habitually used on just that sort of development.

    C++ education should be short and sharp....

    If you want speed do C or assembler.

    If you want OO do Eiffel or Smalltalk

    If you want a job do C# or Java

    Don't do C++.

    --
    An Eye for an Eye will make the whole world blind - Gandhi
    1. Re:Poor use of C++ by Anonymous Coward · · Score: 0
      If you want to fuck the world with MS dependency, use Java.

      C and assembler are poor in optimizations, dude. I guess if you really knew shit you wouldn't make these lame mistakes.

  30. Re:Education, even at Universities, needs to Impro by Anonymous Coward · · Score: 0

    You wrote:

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

    This is a nonsense survey. I happen to know what K&R, the 'white book,' and the 'Art of Computer Programming are, but I don't currently know how to program. In fact, I've read the white book several times and read parts of the Art of Computer Programming.

  31. level of abstraction complexity. by 3seas · · Score: 1

    There seems to be a direct relationship between level of abstraction meaning complexity required in application and the learning curve.

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

    In the simplest example and using the basis of common computers:
    When you mark a switch with a symbol of a "0" and a "1" what does it mean? On/Off or a variation inbetween these like standby, sleep, or any other thing besides on/off?
    What is function overloading of this switch? How many users of computers don't know about the 5 second button push? Isn't the symbol consistant with its use on other devices like TV's ...

    I just told my neighbor, who is retired and had been dealing with computers for a long time, how to shut the computer off by holding the switch/button in for five seconds.

    There is a reason why C++ usage is what it is and its not due to failure to explain the way the designer was thinking, but rather that it is to abstract for the pace and change rate of today.
    In other words, those who use it correctly have managed to learn to think like the designer. But not everyone thinks in the same way (i.e. some people think primarily in terms of words, others in terms of numbers and still others in terms of visual images or sounds.)

    Arrogance is hard for one to see of themselves. A matter of inherent subjectivity. That is what he fails to see, Not what others fail to understand of his mindset.

  32. Re:C++ too ich and is fast becoming a niche langua by UtucXul · · Score: 1

    Eventually C++ will be come the next FORTRAN.
    Well, I'm finally moving from working on a FORTRAN 77 project to a C++ project in a few months, so I'm curious what you mean there. Maybe that like FORTRAN, C++ will never go away no matter how much we wish it would. And even worse that after using it for a while you secretly think it does some thing better than the more dominant languages but people look at you like you are crazy if you say so. For example, FORTRAN 77 has a better system for simple file IO than C/C++. There, I said it.
  33. In other news... by 192939495969798999 · · Score: 2, Funny

    Profs. Einstein and Hawking are upset that people don't know more phyiscs, James Gosling is upset that people don't code better Java, and Picasso is upset that more kids don't take art class.

    --
    stuff |
    1. Re:In other news... by Anonymous Coward · · Score: 0

      Picasso is upset that more kids don't take art class

      ITYM Picasso is upset that more kids don't not take art class

    2. Re:In other news... by Anonymous Coward · · Score: 0

      President Bush was largely silent on the poor government and history education in this country, however.

  34. Re:I'm just glad they're teaching C++ actively aga by mcvos · · Score: 1

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

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

  35. OK I'll say it.. by CrazyTalk · · Score: 1

    Does anyone still USE C++ any more? Seems the only ones around where I work who even know C++ are the old timers. Recently, the consulting company I work for had the opportunity to hire a number of C++ programmers for a legacy project - we had one guy on staff, and couldn't find ANYONE else with the necessary skills.

    1. Re:OK I'll say it.. by softwaredoug · · Score: 1

      Yes, I work at a company of mostly 20s and 30 somethings. We use C++ for everything. C++ is huge. Nobody I know knows more than 50% of the language. Also, every C++ project I've looked at is very different. Projects run the gamut between stuff closer to C, with some inline assembly and a few C++ features rolled in, to crazy template metaprogramming, to gazillion-levels-of-inheritance MFC style programming. The huge feature set can be a benefit to the language. I can control/choose what features I use and what is not needed. I can choose to code to tight efficiency or code with more high-level OO design in mind. Its like a giant swiss army knife. Unfortunately its such a huge toolset, and there is a lot of inconsistency in the language, that so many people are intimidated and retreat to a more heavily managed sandbox like Java or C#.

    2. Re:OK I'll say it.. by Anonymous Coward · · Score: 0

      and there is a lot of inconsistency in the language, that so many people are intimidated and retreat to a more heavily managed sandbox like Java or C#.

      s/retreat/progress/


      Neither am I 'intimidated' by C++, I regard it as a badly designed mess and consider proponents insane.


    3. Re:OK I'll say it.. by jgrahn · · Score: 1

      Does anyone still USE C++ any more? Seems the only ones around where I work who even know C++ are the old timers. Recently, the consulting company I work for had the opportunity to hire a number of C++ programmers for a legacy project - we had one guy on staff, and couldn't find ANYONE else with the necessary skills.

      It may be a matter of what business one is in. On Windows, lots of people follow Microsoft's lead and use whatever language they are pushing today. People working on web servers tend to disappear into a maze of Java-based techniques. On Unix, however (especially Linux and BSDs, and this includes many embedded systems these days) everything is C-based, the libraries you need to work with have a C API and so on. Here C is a natural choice, and C++ is just as natural -- provided the people know the language well enough.

      For my hobby use, C++ replaces C on Unix, simply because it's a better language without taking anything away. I don't need to do my own memory management or write my own container types, and I can throw together a small class if I see a use for some object-oriented design someplace, or need RAII to manage some resource.

    4. Re:OK I'll say it.. by nuzak · · Score: 1

      > Does anyone still USE C++ any more?

      Played any computer games lately?

      --
      Done with slashdot, done with nerds, getting a life.
  36. Java put you on Skid Row? by Latent+Heat · · Score: 5, Insightful
    Let me get this straight, that some wieners at Purdue decided to teach Java instead of C++ in their Intro to Programming course, and that you had a wiener of a prof who was teaching you Java without adequate experience, this all put you on the path to dropping school, dropping your CS major, and taking courses at community college without finishing a degree?

    I will grant you that if you or the parents are shelling out the Purdue tuition, maybe their CS department should find a better professor for their intro course. I am sorry to hear that this experience dissuaded you from completing a CS degree, and there is probably a lot more to your personal story than can be shared on Slashdot.

    But I would like to communicate to others out there that you will have a few good teachers in your educational career who are really inspiring, a vast group of average teachers, and a number of who you consider to be really, really bad teachers. The "bad" teachers are that way (in your opinion) for a number of reasons -- they may be "nice guys or gals" who don't have enough preparation or smarts to teach, they may have admitted to you gaps in their preparation that you have taken upon yourself to hold them in disrespect for, or maybe they assign too much HW and work you too hard.

    If one is going to take a passive approach, show up to class and demand, "Here, educate me", that is a good way to fail at getting a degree and also to fail at every other opportunity that presents itself down the road. If one is going to take an active approach, working as hard as one can at learning from all teachers, the good and the bad, supplementing gaps in instruction with self-study, working coding jobs, group study, one is going to be successful at college and everything else.

    To suggest that a person can have one "bad" prof means that they are on the street drinking methyl antifreeze out of a jar wrapped in a paper bag, this suggests a very passive approach to not just education but life in all its aspects.

    1. Re:Java put you on Skid Row? by Anonymous Coward · · Score: 0

      All true, but if someone's goal is to "work with computers", a CS degree is arguably a big waste of time. College ain't for everyone.

    2. Re:Java put you on Skid Row? by GrayNimic · · Score: 1

      supplementing gaps in instruction with ... group study...
      While I agree whole-heartedly, and have found group study to be one of the most effective ways of gaining long term mastery of material, Group Study has been all but expressly prohibited in CS at both colleges I attended. CS departments seem excessively concerned about cheating and copying/taking credit for work which is not your own, and as such *any* discussion with *anyone* about material related to assignments (which, naturally, includes most of the material covered) is a violation of academic integrity (and potentially grounds for expulsion). A few individual professors would relax those rules, but that was the official department policy and was followed in most courses I took.
    3. Re:Java put you on Skid Row? by sribe · · Score: 1

      Your little diatribe deserves to be printed out, laminated, and hung on the door of every placement office of every college in the country.

  37. Re:C++ too rich and is fast becoming a niche lang. by MadHungarian · · Score: 1

    C++ will continue to be used in very few specialized applications, but it popularity will decline. Like FORTRAN or COBOL, it will live on. Not like some languages that died a well deserved death (anybody remember APL?)

  38. Re:I'm just glad they're teaching C++ actively aga by mcvos · · Score: 1

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

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

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

  39. Re:I'm just glad they're teaching C++ actively aga by GringoCroco · · Score: 2, Informative

    >> you can start with just functional programming to get the basis of what is variable/function/const
    That's imperative programming.
    You get functional programming with lisp, scheme, python, ocaml, haskell.

  40. A waste of time by Anonymous Coward · · Score: 0

    The paradigm is changing.
    People define problems.
    Computers develop code.

    Evolutionary computation trumps computer language development.

    If you want to be a star in the next decades "obsolete skills",
    then waste your time learning C or C++ or . . . .

    1. Re:A waste of time by bfwebster · · Score: 1

      People define problems.
      Computers develop code.


      ROTFL. I've been coding for 34 years (actually, I can make arguments back to 1971 or even back to 1969, but I'll go for consecutive years). Do you know how often I have heard the "programming is dead/program generators will do it all" mantra? (Here's on clue, an article from 27 years ago about "The Last One", as in "the last program that anyone will ever need to write".) This is a canard that gets dragged out every decade or so, and then is quietly put away again.

      As for evolutionary computation -- for which I actually hold out great long-term hopes -- let me know when you can 'evolve', say, a word processor or a mission-critical corporate business application.

      And since COBOL and Fortran still aren't 'obsolete' and still run a sizable percentage of the world's applications, I'm not sure how soon C and C++ will become 'obsolete'. ..bruce..
      --
      Bruce F. Webster (brucefwebster.com)
  41. Re:I'm just glad they're teaching C++ actively aga by cbart387 · · Score: 1

    My bad. I meant to say procedural, I guess I haven't had enough coffee yet.

    --
    Lack of planning on your part does not constitute an emergency on mine.
  42. I wholeheartedly agree with Stroustrup by rolfwind · · Score: 1, Flamebait

    C++ education needs to improve.

    The best way to go about it is to stop teaching it. That would be a major improvement right there.

  43. Coding a C++ compiler... by GNUPublicLicense · · Score: 1, Interesting

    ... even a basic one, non optimizing one, is an insane task (compared to a C one for instance). Around me, computer science students have to code a fully featured toolchain to reach for their diploma... and quite strangely, only C is able to make it... as soon as you talk C++ (not even its runtime library...), usually it is followed by "mentally ill" or "crazy" or "monstuous project" or ... well you get the idea. The C++ (or any similar language/framework) price in term of toolchain complexity (I'm not talking about gcc complexity but the complexity of writing a full featured one from scratch) is, for many coders, unreasonably high.

  44. Visual J++ an obvious dead end? by Latent+Heat · · Score: 0

    I fail to see how Visual J++ was a dead end. Although they don't call it Visual J++ -- it is now called Visual Studio .NET C#. I had looked at Visual J++, and it is .NET version 0.8 in so many ways.

  45. I've written some educational C++ articles by MichaelCrawford · · Score: 4, Informative
    They're at GoingWare's Bag of Programming Tricks, and are more in depth than most online tutorials.

    The articles are:

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

    --
    Request your free CD of my piano music.
    1. Re:I've written some educational C++ articles by turgid · · Score: 1

      Ooh Betty! I've wet my trousers.

      As my mother used to say about C++, "A trouble shared is a trouble doubled!"

  46. Re:Education, even at Universities, needs to Impro by DoofusOfDeath · · Score: 1

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

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

    Having programmed in C++ for many years, and having lived through its evolution to include its nightmarish template system with its nearly incomprehensible error messages even for types as simple as strings, I'm ready to at least blame the language design. Feel free to also blame CS education if you've seen bad examples of it.

  47. Re:I'm just glad they're teaching C++ actively aga by cbart387 · · Score: 2, Insightful

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

    --
    Lack of planning on your part does not constitute an emergency on mine.
  48. Re:I'm just glad they're teaching C++ actively aga by skroll82 · · Score: 5, Insightful

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

  49. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 5, Funny

    Hello Gentlemen,

    I'm a first year programming student at an Ivy League school and I've just finished my Visual Basic classes. This term I'll be moving onto C++. However I've noticed some issues with C++ that I'd like to discuss with the rest of the programming community. Please do not think of me as being technically ignorant. In addition to VB, I am very skilled at HTML programming, one of the most challenging languages out there!

    C++ is based on a concept known as Object Oriented Programming. In this style of programming (also known as OOPS in the coding community) a programmer builds "objects" or "glasses" out of his code, and then manipulates these "glasses". Since I'm assuming that you, dear reader, are as skilled at programming as I am, I'll skip further explanation of these "glasses".

    Please allow me to make a brief aside here and discuss the origins C++ for a moment. My research shows that this language is one of the oldest languages in existence, pre-dating even assembly! It was created in the early 70s when AT&T began looking for a new language to write BSD, its Unix Operation System (later on, other companies would "borrow" the BSD source code to build both Solaris and Linux!) Interestingly, the name C++ is a pun by the creator of the language. When the first beta was released, it was remarked that the language would be graded as a C+, because of how hideously complex and unwieldy it was. The extra plus was tacked on during a later release when some of these issues were fixed. The language would still be graded a C, but it was the highest C possible! Truly a clever name for this language.

    Back to the topic on hand, I feel that C++ - despite its flaws - has been a very valuable tool to the world of computers. Unfortunately it's starting to show its age, and I feel that it should be retired, as COBOL, ADA and Smalltalk seem to have been. Recently I've become acquainted with another language that's quite recently been developed. Its one that promises to greatly simplify programming. This new language is called C.

    Although syntactically borrowing a great deal from its predecessor C++, C greatly simplifies things (thus its name, which hints at its simpler nature by striping off the clunky double-pluses.) Its biggest strength is that it abandons an OOPS-style of programming. No more awkward "objects" or "glasses". Instead C uses what are called structs. Vaguely similar to a C++ "glass", a struct does away with anachronisms like inheritance, namespaces and the whole private/public/protected/friend access issues of its variables and routines. By freeing the programmer from the requirement to juggle all these issues, the coder can focus on implementing his algorithm and rapidly developing his application.

    While C lacks the speed and robustness of C++, I think these are petty issues. Given the speed of modern computers, the relative sluggishness of C shouldn't be an issue. Robustness and stability will occur as C becomes more pervasive amongst the programming community and it becomes more fine-tuned. Eventually C should have stability rivaling that of C++.

    I'm hoping to see C adopted as the de facto standard of programming. Based on what I've learned of this language, the future seems very bright indeed for C! Eventually, many years from now, perhaps we'll even see an operating system coded in this language.

    Thank you for your time. Your feedback is greatly appreciated.

  50. He could start in his own department... by Anonymous Coward · · Score: 0

    At Texas A&M University (where Stroustup is), the professor who "teaches" C++ could use a lot of improvement. I took it several years ago, and it was mainly just Dr so-and-so rambling on about general topics to programming and trying his best to ensure there is not a moment of silence in the room.

    The half-dozen assignments were mostly to make small changes to an existing program that took maybe 3-4 hours to complete in TOTAL. And the program itself was badly factored, with a mismash of header files that did not match the .cpp files, no error reporting whatsoever, no clear pattern of which parameters are input vs output, etc., in other words a code style that I would have been physically beaten for using in the Real World.

    The prof has such a low bar that anyone with two neurons can get an A, so naturally his ratings at pick-a-prof and whatnot are very high.

  51. 32 year programmer -- use C++ by mlwmohawk · · Score: 0, Troll

    I have been programming computers since 1976, and back then it was BASIC on a PDP-8e. Depending on your perspective, that either makes me experienced or a dinosaur. Keep your opinions, and enjoy them. Unless tragedy strikes, you too will hopefully gain some experience in life and be forced to listen to those who don't know 1/10th of what you do, and be forced to look back on your own behavior and wince about things you've said and thought to be right that were actually misinformed.

    OK, "off my lawn" speech over.

    IMHO everyone who complains about C++ is a pedantic fool. Nothing is perfect, no language, no computer, nothing. I loved what Stroustrup said in the article about becoming "language lawyers," rather than programmers. I am frequently amused about java vs c++ or .net vs c++ arguments. With the [java | .net] proponents focusing on ambiguities in C++ or (gasp) pointers.

    I come from a more renaissance period of computer science. Practitioners found it both necessary and valuable to know and understand "how" their programs actually worked. We needed to know how macros in the assembler worked. How addresses in labels got fixed up by the linker. How machine instruction permutations were constructed based on the assembler instructions. How to write an efficient "divide" function because the processor only added and subtracted. Forget floating point. Not to mention the mathematical efficiency of algorithms and so forth. Most of this stuff is black magic to most programmers today.

    C++ has its flaws, absolutely. However, if you use "C" constructs, it is as efficient and as readable as C. If you conceptualize the logical constructs of your application as a hierarchy of objects, it can do that too. You can even easily and efficiently use assembler and pure C functions.

    The root cause of bad C++ is bad C++ programmers. It is not COBOL and it will not protect you from doing something stupid. Just because you can do something syntactically correct, doesn't mean it is logically correct. A good rule of thumb to think about is this: If you don't understand how it will work, don't do it.

    The argument that some features shouldn't be in C++ because of these problems sort of misses the point. A bicycle falls over without training wheels but is useless for serious riding with them. C++ without the features that can be misused would merely be a bicycle with training wheels.

    Stop wanting everything to be "easier" to learn, some things become "easier" with learning.

    1. Re:32 year programmer -- use C++ by SanityInAnarchy · · Score: 2, Interesting

      Nothing is perfect, no language, no computer, nothing.

      True. Some, however, are hideously worse than others.

      With the [java | .net] proponents focusing on ambiguities in C++ or (gasp) pointers.

      Pointers are a powerful tool, in the very few cases where you actually need them. Otherwise, they're just a buffer overflow or segmentation fault waiting to happen. (And there are languages which can't have either.)

      Practitioners found it both necessary and valuable to know and understand "how" their programs actually worked.

      That is still useful, to some extent. However...

      We needed to know how macros in the assembler worked.

      Really? In what way is that valuable? I can see how it would be interesting, but I can't imagine how it would make my programs better in any measurable way.

      C++ has its flaws, absolutely. However, if you use "C" constructs, it is as efficient and as readable as C.

      And slower to compile, for no good reason. And still might have some syntactical surprises. If you use 'C' constructs, why not just write C?

      The root cause of bad C++ is bad C++ programmers. It is not COBOL and it will not protect you from doing something stupid.

      All programmers, good or not, do stupid things from time to time.

      There was a study done once. I don't remember which languages were covered, but I do remember that some were very low-level, and some very high-level.

      What they found is that the ratio of bugs to lines of code remained constant across all languages. Therefore, a higher-level language, which results in fewer lines of code to perform the same task, will likely result in a less buggy program -- not to mention a much more maintainable one.

      Stop wanting everything to be "easier" to learn, some things become "easier" with learning.

      Come back when you've done anything significant in LISP, or any language which supports closures.

      Yes, especially in programming, it's better to focus on making things easier for an expert to use, rather than making the learning curve easier. Unfortunately, C++ is neither, and most experts will tell you to use a subset of the language. In today's world, the main place where C++ is invaluable is for code which must perform well, especially when you need enough of it that writing it all in assembly is out of the question. But as someone else posted, the proper subset of C++ to fill that role is C.

      --
      Don't thank God, thank a doctor!
    2. Re:32 year programmer -- use C++ by mikec · · Score: 1

      I've been programming since 1974 -- I started with a PDP 7 and an Altair 8800 and I'm currently writing code (C++, Java, Python) for Google. And I have a 4-digit slashdot ID, so get off my lawn! :-)

      I guess I'm a pedantic fool, because it's obvious to me that C++ is a mess, and it's not the fault of programmers. It's not that it's impossible to write good C++. But compared to more modern languages it takes a lot more expertise, discipline, and especially time, so it's a lot more expensive than it should be. And, of course, there's always the temptation to cut the expense a little and then you have crappy code.

      The problem is that C++ was initially a bit of a hack (remember cfront?) and then it was taken over by vast committees that used it as a vehicle to rationalize all their pet features. To see what can be done with a fresh start, take a look at the programming language D.

    3. Re:32 year programmer -- use C++ by mlwmohawk · · Score: 1

      I've been programming since 1974 -- I started with a PDP 7 and an Altair 8800 and I'm currently writing code (C++, Java, Python) for Google. And I have a 4-digit slashdot ID, so get off my lawn! :-)

      It's good to see that dinosaurs still roam.

      I guess I'm a pedantic fool, because it's obvious to me that C++ is a mess

      I never said it wasn't. It is far from perfect, of course.

      It's not that it's impossible to write good C++. But compared to more modern languages it takes a lot more expertise, discipline, and especially time, so it's a lot more expensive than it should be. And, of course, there's always the temptation to cut the expense a little and then you have crappy code.

      I have a very different perspective. A "good" programmer/developer will naturally want a more powerful language.

      The problem is that C++ was initially a bit of a hack (remember cfront?) and then it was taken over by vast committees that used it as a vehicle to rationalize all their pet features. To see what can be done with a fresh start, take a look at the programming language D.

      It is always tempting to let the problems on which you focus to distract you from the advantages you have, i.e. the grass is always greener on the other side of the fence.

    4. Re:32 year programmer -- use C++ by mikec · · Score: 1

      Yes, the grass is always greener. The pony express was good enough, but then they invented the telegraph, then they insisted we needed telephones, and then email, and now the web and IM. Think how great the pony express would be if we had just concentrated on perfecting it instead of getting all distracted by new-fangled innovations?

    5. Re:32 year programmer -- use C++ by mlwmohawk · · Score: 1

      Yes, the grass is always greener. The pony express was good enough, but then they invented the telegraph, then they insisted we needed telephones, and then email, and now the web and IM. Think how great the pony express would be if we had just concentrated on perfecting it instead of getting all distracted by new-fangled innovations?

      It is an absurd strawman argument. *All* progress is not good and *all* progress is not bad. The merits of "good" vs "bad" progress is based on fact and reason. The mere fact that you try to invoke this sort of nonsensical argument means you have no real factual argument to support your opinion.

      Is HDMI better than DVI? Of course not, it only serves *AA interests. Is margarine better than butter? No. Is Monosodium glutimate better than salt? I's hydrogenated oil better than natural oil? Is ".NET" better than "java?" many of these "progress" issues are never really or clearly obvious and are often much more complex.

      When you can articulate an opinion that means something, come back and post again little boy.

    6. Re:32 year programmer -- use C++ by mlwmohawk · · Score: 2, Interesting

      We needed to know how macros in the assembler worked.

      Really? In what way is that valuable? I can see how it would be interesting, but I can't imagine how it would make my programs better in any measurable way.


      Well, in those days, with absurdly small limits on program size, you absolutely needed to know how many bytes your function would take. It sometimes meant being more than the 2K eprom. That requirement of knowledge make for better engineers, IMHO.

      C++ has its flaws, absolutely. However, if you use "C" constructs, it is as efficient and as readable as C.

      And slower to compile, for no good reason. And still might have some syntactical surprises. If you use 'C' constructs, why not just write C?


      Well, C++ has some programming advantages that C does not have. Better type semantics and checking, default parameter values, etc. If it is as efficient and is as predictable in implementation as C, but has additional features that help you write code, why not use it? The C++ compiler can actually make "C" type programming safer with no cost.

      Unfortunately, C++ is neither, and most experts will tell you to use a subset of the language. In today's world, the main place where C++ is invaluable is for code which must perform well, especially when you need enough of it that writing it all in assembly is out of the question. But as someone else posted, the proper subset of C++ to fill that role is C.

      "C" isn't a proper subset of C++. The "class" construct makes all the difference. Using classes to represent logical hierarchies is very important to good software design.

    7. Re:32 year programmer -- use C++ by SanityInAnarchy · · Score: 1

      That requirement of knowledge make for better engineers, IMHO.

      I'd argue the only real reason it did is that it filtered out the people who couldn't grasp those concepts. I don't believe that knowledge is useful today, except applied in the same context -- filtering out people who have no skill.

      If it is as efficient and is as predictable in implementation as C, but has additional features that help you write code, why not use it?

      That's a LOT of assumptions in one sentence. Let me enumerate them:

      • If it is as efficient
      • and is as predictable in implementation
      • but has additional features that help you write code
      • features that help you write code are desirable (as opposed to features that help you write better code, or help you write more efficiently)
      • Or, alternately, the features C++ adds help you write better code, or help you write it more efficiently.

      And why not to use it? Because the language is much more complex, has many hidden surprises, and the compiler is slower. If you are using mostly C-like structures anyway, I don't think it's worth it, especially when there are many people out there developing C. You'd be stuck between two communities -- those who use C, and those who use C++.

      "C" isn't a proper subset of C++. The "class" construct makes all the difference. Using classes to represent logical hierarchies is very important to good software design.

      Which has nothing to do with it being a subset or not.

      Besides, while I'd agree object-oriented programming is important, you don't need C++ classes to do it, or even anything vaguely resembling C++ classes. The logical hierarchies you're talking about don't need to be rigidly applied as a language feature.

      --
      Don't thank God, thank a doctor!
    8. Re:32 year programmer -- use C++ by mlwmohawk · · Score: 1

      That requirement of knowledge make for better engineers, IMHO.

      I'd argue the only real reason it did is that it filtered out the people who couldn't grasp those concepts. I don't believe that knowledge is useful today, except applied in the same context -- filtering out people who have no skill.


      You may think that, but that is an opinion about knowledge based on ignorance. Even today, there are times when various old bits of knowledge come in handy for explaining why certain things happen that are not immediately obvious.

      If it is as efficient and is as predictable in implementation as C, but has additional features that help you write code, why not use it?

      That's a LOT of assumptions in one sentence. Let me enumerate them:

              * If it is as efficient
              * and is as predictable in implementation
              * but has additional features that help you write code
              * features that help you write code are desirable (as opposed to features that help you write better code, or help you write more efficiently)
              * Or, alternately, the features C++ adds help you write better code, or help you write it more efficiently.


      If you compile code written as basically "C" code in C++ and make use of default parameters and the stronger type checking, it is as efficient, is is as predictable, does have the features that help (default parameters, type checking), it does make code better.

      You should dump out the assembler to prove it to yourself. Oh, wait, isn't that one of those knowledge things you say you don't need?

      Besides, while I'd agree object-oriented programming is important, you don't need C++ classes to do it, or even anything vaguely resembling C++ classes. The logical hierarchies you're talking about don't need to be rigidly applied as a language feature.

      No thanks, I've done my time, in the '80s, hacking out structure based object oriented frameworks in C. C++ is far better and more efficient and allows the compiler to do "early binding" and be more efficient.

    9. Re:32 year programmer -- use C++ by Weedlekin · · Score: 1

      You're missing the fact that the Pony Express could carry packages, which none of the other technologies you mention were or are capable of. The modern equivalents of the Pony Express are therefore the likes of DHL and UPS, who still transport physical things around, and will continue to do so until somebody comes up with a way of replicating matter at a distance.

      NB: American Express, who ran the pony express, are still around, and doing very well for themselves, although they aren't in the transport business anymore.

      --
      I'm not going to change your sheets again, Mr. Hastings.
  52. Re:I'm just glad they're teaching C++ actively aga by RockoTDF · · Score: 2, Informative

    Keep in mind that Computer Science is *not* coding. It's a subfield of mathematics that deals with the theory of computation. The lecturer might have been a theorist.

    --
    There is more to science than physics!

    www.iomalfunction.blogspot.com
  53. Sadly... by Kingrames · · Score: 2, Funny

    When trying to point the blame, his pointers went everywhere, and his program terminated abruptly.

    --
    If you can read this, I forgot to post anonymously.
  54. Re:I'm just glad they're teaching C++ actively aga by ericferris · · Score: 2, Funny

    Too bad this was posted as AC, it deserved some funny mod points.

    --
    Fantasy: http://ferrisfantasy.blogspot.com/
  55. Re:I'm just glad they're teaching C++ actively aga by SageMusings · · Score: 1

    At least with C++ you can start with just functional programming

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

    --
    -- Posted from my parent's basement
  56. Strostrup is the problem by Animats · · Score: 5, Interesting

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

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

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

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

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

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

    1. Re:Strostrup is the problem by vectra14 · · Score: 2, Insightful

      Wow, how were you modded "Troll"? I'd mod you up if I could.

      Yeah, array/pointer ambiguity is a key "broken" feature of C++, although at the same time it's exactly the kind of thing that makes it possible to use the same language for code running on a microcontroller and for a full-blown GUI. But yes, for most things it would be incredibly useful to have proper arrays with index checking and so on. Most templated solutions that I've seen (Boost?) are just butt-ugly and make the code that much more difficult to understand.

      I think anyone that's used C++ a lot (this is probably a truism for all things) develops a strong love/hate feeling towards it. So it goes.

    2. Re:Strostrup is the problem by ceroklis · · Score: 2, Insightful

      I think the main problem of C++ is that people who know C assume they automatically know C++ as well. They don't. You might want to read up on this std::vector thing.

    3. Re:Strostrup is the problem by Animats · · Score: 3, Interesting

      Yeah, array/pointer ambiguity is a key "broken" feature of C++, although at the same time it's exactly the kind of thing that makes it possible to use the same language for code running on a microcontroller and for a full-blown GUI.

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

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

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

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

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

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

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

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

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

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

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

    4. Re:Strostrup is the problem by david_thornley · · Score: 1

      Mod that guy up! Anybody who thinks arrays are important for users of C++ (as opposed to library writers), or who has raw pointers leaking out of abstractions, is too ignorant about C++ to have a credible opinion. Read a good book. Stroustrup's is excellent, although dense.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    5. Re:Strostrup is the problem by vectra14 · · Score: 1

      Wow, cool! I've actually written a compiler for C++ in the past but I didn't look into index checking so this is cool to hear about. Yeah, I always wished that sizeof could be more useful for arrays.

      It's interesting how C# had a lot of similar problems (well, not with arrays, though because of its fundamental design it's not exactly very fast for numerical stuff) but because it's owned by a single company it evolves so incredibly fast... I really love C# at this point (yeah so kill me, etc... I've recently concluded that extension methods are indeed awesome); I do sometimes wish that the C++ standard evolved much quicker. I guess MS kind of tried to evolve C++ on its own via Managed C++ but the managed C++ syntax (carrots (^) anyone?) makes me want to vomit.

    6. Re:Strostrup is the problem by Animats · · Score: 1

      I guess MS kind of tried to evolve C++ on its own via Managed C++ but the managed C++ syntax (carrots (^) anyone?) makes me want to vomit.

      Yes, "Managed C++" was awful. It's the ultimate demonstration of the fact that destructors and garbage collection do not play well together. Microsoft implemented all the hard cases, including "re-animation", which means an object can be destructed more than once. Sometimes I think "Managed C++" was created to kill C++ in favor of C#, which is sort of Microsoft's Java.

      We do need better hard-compiled languages, for when you don't want all the excess baggage of ".NET" or Java. Modula 3 was probably as good as it ever got, but Modula 3 came from DEC Research, which did some great work but was killed off after the Compaq acquisition.

    7. Re:Strostrup is the problem by epiphani · · Score: 1

      The fundamental cause of the trouble comes from C's "pointer=array" equivalence. That was a terrible mistake, borrowed from BCPL.

      Borrowed? Sorry, I don't know much about programming languages, but I do know C. The whole "pointer=array" thing is bunk. Pointers are NOT arrays. You're misunderstanding whats happening. Pointers only point to memory locations. Arrays are only a different way of referencing the same memory locations. There are dozens of other ways to look at the same area.

      The trouble is that the compiler knows neither which variables are arrays nor how big the arrays are. You can't even talk about arrays properly. I mean, of course,
      int read(int fd, char* buf, size_t len);
      That's just trouble waiting to happen. "read" has no information about how big "buf" is.


      Actually, the compiler knows exactly how big buf is. Its the size of a pointer on that system. Of course, if you want to copy data into the memory space POINTED to by buf, then you should tell it how far to write. Thats what len is for.

      C works how computers work. It is not a language that tries to hide it from you. If you want to code in C, you should understand this. Realize that in terms of CPU operations, having a language track every begining and end of every separately allocated memory space is very expensive. Try compiling a C app with the bounds checking GCC extensions sometime (its a separate gcc patch), and see how well your app performs while it is checking every single allocation and memory reference.

      Oh, and before you say that the compiler should figure out if that happens, think about how much flexibility would be lost if every single allocation was static in size.

      --
      .
    8. Re:Strostrup is the problem by Kooshman · · Score: 1

      The fundamental point of parent is not brought up nearly enough-- Stroustrup *is* C++. For those who are satisfied, it's nice to see where he's steering the ship. For everyone else, these kinds of interviews are just wanking, and tend to leave important questions unraised.

      This /. post is the perfect example of fallout of such kid-glove treatment. Why make any noise over Stroustrup's intended educational goals with C++ until you know if he's any good at that? I attended the august institution and department where he is now a professor. While I never had the pleasure first-hand, I heard stories from some who experienced his freshman-intro computer programming course. The stories were not good. While always impressed by the sheer mastery Stroustrup had over the subject, he was most certainly not a shining beacon of pedagogy. Thus, no matter how great his direction of C++ is, why do we care about his teaching of it?

      Of course, such questions are hard to raise because of Political Weight. The intro course for CS majors at aforementioned institution magically got set back to C++ after having been Java (sometimes with C++) for years. If they thought Java too high-level, straight C would have been a good intro language, given its simplicity. But then with Stroustrup thrown in the pot, it was literally a bygone conclusion. As in, I objected at the curriculum revision committee and got entirely cut off. I started in C++ (several times) and I think doing so damaged my programming education. But these people who learned to program in the era of punchcards thought the pedagogical input of Stroustrup was more valid. And then they complain about how students don't have the skills when they leave.

      So yes, there are problems with C++, yet some people just don't seem to mind, and the product has become quite popular. That doesn't mean we give the creator a free ride on the subject, or any other.

    9. Re:Strostrup is the problem by mrchaotica · · Score: 1

      Personally, when I'm coding C I just don't use arrays (except string literals) at all and instead dynamically allocate everything that's not a scalar. The mechanical complexity of having to keep track of more pointers is worth the conceptual simplicity of having only one kind of thing to worry about instead of two.

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    10. Re:Strostrup is the problem by mrchaotica · · Score: 1

      Realize that in terms of CPU operations, having a language track every begining[sic] and end of every separately allocated memory space is very expensive.

      Yeah, but on the other hand, the allocator itself does keep track of it. Although I agree it would be horribly inefficient to add automatic bounds checking, I think it'd be nice to have a (standardized) function called something like size_t lengthof(void *) that, when passed a pointer to any address within a dynamically-allocated buffer, would return the number of bytes from the location given to the end of the buffer or return 0 and set errno if passed a pointer to any address not within a dynamically-allocated buffer.

      (Ideally, I'd also deprecate the use of sizeof() on arrays and define lengthof() to be valid on static arrays too, but that wouldn't be possible because too many people would insist on backwards compatibility.)

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    11. Re:Strostrup is the problem by master_p · · Score: 1

      Totally agreed, and not only Stroustrup, but also the other members of the C++ standards committee.

      Their latest monstrosity is move semantics, i.e. data allocated on the heap are moved around and freed by the last object that has their ownership. Move semantics work just like auto_ptr, i.e. a newly constructed object gets the ownership of the data...this guarantees disaster, because in a complex expression/statement block you will not be able to tell which destructor really destroyed the data...

      And all this because they deny to fix the language and put garbage collection in! with GC, move semantics would not be required, as the shared data structures would be deleted only when not referenced by any code. And their excuse for not putting garbage collection in C++ is just as lame: "some people will react against it!" even if GC is totally optional!!!

      You want a list of C++ applications that have crashed on me one time or another? here it is:

      U-torrent, Deluge, Firefox, Internet Explorer, Windows Explorer, Microsoft Word, Microsoft Visual Studio 6, a lot of games, MAME32, and many others!

      On the other hand, I can't remember a Java app that regularly crashed on me now or in the past.

      The only reason for this situation is that C++ is a horrible mess of a programming language! Stroustrup's denial has cost million of dollars in the industry, and quite a few thousands in my company from bugs resulting from the horrible C++ mess...

    12. Re:Strostrup is the problem by Animats · · Score: 1

      Their latest monstrosity is move semantics,

      auto_ptr is on, what, standardization try #4? It sucks less, but it's still not airtight. The fact that you can't make it airtight indicates some of the fundamental problems in C++.

      Garbage collection isn't a panacea, though. It introduces a sort of concurrency into otherwise sequential programs, leading to timing jitter (at least), stalls (maybe), and nonrepeatable bugs. Garbage collection and destructors do not play well together. See "Managed C++". Concurrent garbage collection requires some support from the memory management unit and operating system, so the hardware can detect "dirty pages". Not all target machines have that hardware; most handheld devices don't, for example. Calling destructors from another thread in the garbage collector can introduce race conditions or deadlocks. Conservative garbage collection can result in memory leaks, and offers a new avenue for denial of service attacks if someone can send you buffers full of carefully constructed junk.

      Garbage collection is fine for programs at a somewhat higher level, like Java, but you probably don't want it inside your operating system kernel or media player.

      There's something to be said for reference counts. In C and C++, memory management gets much attention. In Java, programmers worry about garbage collection and finalizers. But in Perl and Python, which are reference counted, programmers seem to mostly ignore memory management without problems. With reference counts, destruction is deterministic. Reference counts have three problems - keeping them correct (C++ reference count template packages tend to leak raw pointers, leading to bugs), updating cost (many reference count updates could be hoisted out of loops if the compiler understood reference counts, but few implementations of any language do that), and cycles. The answer to cycles may be to provide weak pointers, then simply prohibit cycles, with a debug tool to catch them. If you need some complex structure with heavy interlinking, like a window manager, make all the window objects owned by some collection, then make all the inter-widget links weak.

      The "move semantics" mess arises from the fact that parameter passing in C++ is an assignment, invoking the "=" operator. This leads to a temptation to redefine the "=" operator. If you have reference counts, though, you don't have this problem.

    13. Re:Strostrup is the problem by master_p · · Score: 1

      Although you start off on the right track, you make some mistakes on the way. Let me please point them out for you.

      It introduces a sort of concurrency into otherwise sequential programs, leading to timing jitter (at least), stalls (maybe), and nonrepeatable bugs.

      Not at all. IBM even has a real time Java (hard real time).

      Garbage collection and destructors do not play well together. See "Managed C++".

      No, that's not true either. C++ has RAII, so the point is not valid.

      Concurrent garbage collection requires some support from the memory management unit and operating system, so the hardware can detect "dirty pages"

      No, it does not. All that's required is CAS operations.

      Calling destructors from another thread in the garbage collector can introduce race conditions or deadlocks.

      It depends on what your destructor is doing. Under GC in C++, resource management would be managed with RAII, so there is no problem with deadlocks and stuff.

      Conservative garbage collection can result in memory leaks, and offers a new avenue for denial of service attacks if someone can send you buffers full of carefully constructed junk.

      Agreed, GC needs to be integrated with the language.

      Garbage collection is fine for programs at a somewhat higher level, like Java, but you probably don't want it inside your operating system kernel or media player.

      You mix two totally unrelated domains. A OS kernel can have GC, but usually it is too low level to have one. On the other hand, a media player can have GC, since a media player does not constantly allocate and deallocate memory blocks.

      In Java, programmers worry about garbage collection and finalizers.

      They don't, in 99% of the cases. I belong to a group of programmers that make Java applications (as well as C++ apps) and that Java programmers worry about GC is all but a myth. It's only when there are libraries that are not well thought out that GC is a factor.

      But in Perl and Python, which are reference counted, programmers seem to mostly ignore memory management without problems. With reference counts, destruction is deterministic.

      That's because their stuff does not contain cyclic references.

      (C++ reference count template packages tend to leak raw pointers, leading to bugs)

      Not if the reference count is embedded into objects.

      The answer to cycles may be to provide weak pointers, then simply prohibit cycles, with a debug tool to catch them. If you need some complex structure with heavy interlinking, like a window manager, make all the window objects owned by some collection, then make all the inter-widget links weak.

      Don't underestimate the power of cycles! cycles can be introduced indirectly, through inheritance, and then it's very very difficult to track them...trust me, I've been hunting a memory leak introduced by a subclass which obtained a shared ptr from a factory interface, only to discover that the the base class was already already referenced somewhere from the object returned by the factory; the cycle was not obvious, until the program accumulated lots of craft after a long operation.

      The "move semantics" mess arises from the fact that parameter passing in C++ is an assignment, invoking the "=" operator. This leads to a temptation to redefine the "=" operator. If you have reference counts, though, you don't have this problem.

      In my opinion, move semantics arises from the fact that Stroustrup thinks complex data structures can have value semantics.

    14. Re:Strostrup is the problem by Animats · · Score: 1

      >It introduces a sort of concurrency into otherwise sequential programs, leading to timing jitter (at least), stalls (maybe), and nonrepeatable bugs.

      Not at all. IBM even has a real time Java (hard real time).

      That's WebSphere Real Time Java, a research effort from IBM. You can order it (with mandatory and expensive technical support), but it's more of a semi-custom product. They had to make some drastic compromises to get that to work. Arrays are split into "arraylets", so that no one chunk is so big that it can't be moved during the garbage collection freeze. This allows them to get the freeze time down below a millisecond. There are still freezes, but they're shorter.

      >Garbage collection and destructors do not play well together. See "Managed C++".

      No, that's not true either. C++ has RAII, so the point is not valid.

      That's the problem. Resource Allocation as Initialization and garbage collection do not play well together. Do you want to wait until the next GC before a window closes?

      > Concurrent garbage collection requires some support from the memory management unit and operating system, so the hardware can detect "dirty pages"

      No, it does not. All that's required is CAS operations.

      If you want to avoid freezes during garbage collection, you need more than that. IBM's concurrent collector for Java still has brief freezes for the "mark" phase. Microsoft's patented approach (U.S. Patent #6,502,111) has a freeze: "The application is paused after the marking act is complete. Next, a second marking act of marking all reachable memory objects...". Boehm's collector is "mostly concurrent", and requires "the write protect facilities that are now widely available". The general idea is to write protect pages while the program is running, then run the marking phase of garbage collection on them. If the running program writes to a write-protected page, the page is unlocked and the write performed, but the garbage collector has to do that page again.

      Page level write protection/dirty page bit hardware, or periodic freezes. Pick one.

      > Calling destructors from another thread in the garbage collector can introduce race conditions or deadlocks.

      It depends on what your destructor is doing.

      And that's the problem. There are some subtle no-nos in destructors called from garbage collectors. C++ doesn't prevent them. Errors here result in very intermittent bugs that are very hard to find. Garbage collection is fine for programs at a somewhat higher level, like Java, but you probably don't want it inside your operating system kernel or media player. You mix two totally unrelated domains. A OS kernel can have GC, but usually it is too low level to have one. On the other hand, a media player can have GC, since a media player does not constantly allocate and deallocate memory blocks. In Java, programmers worry about garbage collection and finalizers.

      Don't underestimate the power of cycles! cycles can be introduced indirectly, through inheritance, and then it's very very difficult to track them...trust me, I've been hunting a memory leak introduced by a subclass which obtained a shared ptr from a factory interface, only to discover that the the base class was already already referenced somewhere from the object returned by the factory; the cycle was not obvious, until the program accumulated lots of craft after a long operation.

      I'm arguing for a debug mode in which cycles are detected at the moment of creation. Cycles are typically a design time problem; if a program generates cycles, it will probably generate cycles on every execution. This tells you when you need weak pointers.

      If your data structure is anything like a tree, the cycle problem can usually be fixed

    15. Re:Strostrup is the problem by neutralstone · · Score: 1

      Their latest monstrosity is move semantics, i.e. data allocated on the heap are moved around and freed by the last object that has their ownership. Move semantics work just like auto_ptr, i.e. a newly constructed object gets the ownership of the data...this guarantees disaster, because in a complex expression/statement block you will not be able to tell which destructor really destroyed the data...

      You are misinformed.

      Move semantics are enabled by rvalue references (i.e., references that bind to rvalues, as opposed to the existing references in C++ '98 that bind to lvalues).

      Rvalue references and move semantics solve a performance problem, not a memory management problem.

      The typical use case is to have a constructor (called the "move constructor", which is like a copy ctor but takes rvalues instead of lvalues) bind to the temporary class objects that are often created in a complex expression. By pilfering the resources of an object that's guaranteed to exist only until the end of the full-expression in which it's created, you can avoid successive calls to expensive allocators of resources (like heap memory).

      If you want to understand this, read The Fine Paper. Note especially the std::string example. (This is an early version of the proposal; subsequent versions polished the proposed wording changes to the actual normative wording of the C++0X Working Draft.)

      And all this because they deny to fix the language and put garbage collection in!

      You are appallingly misinformed.

      First, note that you do not get move semantics without rvalue references. And move semantics are meant to apply only to rvalues (not lvalues -- although you can explicitly force an lvalue-to-rvalue conversion and then do a move, but generally there is no need to).

      Second, the performance gained from compiling existing C++ programs against rvalue-ref-enabled libraries is quite measurable, and in many cases the speed gains are close to a factor of ten over the version of the same library without move semantics.

      Third, when the committee accepted the proposal for rvalue references, *nobody* claimed that it would be used as a substitute for garbage collection. They are totally separate things that solve different problems. If and when Garbage Collection is accepted, you can look forward to programs that use *both* rvalue references *and* GC (and with good reasons for using both). On the other hand, if GC ultimately does not make it into C++0x, you should be aware that

      (a) it will not have been the fault of proponents of ravlue references (who are also mostly proponents of GC) and

      (b) work toward GC will continue so that it can be adopted into the following C++ (probably C++13).

      I have a fourth point, but first:

      with GC, move semantics would not be required, as the shared data structures would be deleted only when not referenced by any code. And their excuse for not putting garbage collection in C++ is just as lame: "some people will react against it!" even if GC is totally optional!!!

      Fourth: the committee has not rejected garbage collection.

      Programmer-controlled GC (i.e., GC that can be explicitly disabled or explicitly enabled) is being worked on by some smart people whose names you should recognize if you really care about this stuff, and the chances of it being accepted are looking good. It's taking longer to put in than rvalue references because it's considerably more complicated than rvalue references.

      There is so much more written in this thread that should be publicly corrected. Suffice to say, if you really want to know what's true about the developments of C++0x, you should honestly read about some of the topics. And if you think Stroustru

    16. Re:Strostrup is the problem by neutralstone · · Score: 1

      The big problem with C++ is Strostrup. He's in denial about the fact that the language is fundamentally broken.
      [...]
      The fundamental problem with C++ is that it has hiding ("abstraction") without memory safety.

      I don't think you introduced the concept of "hiding", so I don't understand what you mean.

      Also, you say that hiding is the "fundamental problem", but later you say:

      The fundamental cause of the trouble comes from C's "pointer=array" equivalence.

      But you say that C doesn't have "hiding", so I guess that "hiding" does not result from the implicit array-to-ptr conversion.

      C++ added references to C, and should have added syntax like
      int read(int fd, char& buf[len], size_t len);
      to go along with it, so that arrays became first-class objects with sizes.

      Well, that syntax probably wouldn't fly. If this feature were adopted you'd probably have to write:

      int read(int fd, size_t len, char (& buf) [len] );

      I.e., 'len' must be declared before it is referenced, and you must use the proper declarator syntax so that you have a "ref-to-array" as opposed to "array of references to char" (which is what you wrote).

      Also note, you can almost do this in C++98/03, except that len must be a constant:

      template < std::size_t len >
      void f( char (&buf)[len] ) // Ok in C++98/03
      {
      // the compiler knows that in this scope,
      // the length of buf is len.
      }


      You can of course further generalize this to:

      template < class T, std::size_t len >
      void f( T (&arr)[len] )
      {
      // ...
      }

      But [the committee] didn't [add run-time array lengths and/or variably sized arrays to C++0x].

      Well, the Evolution Working Group (which considers proposals for core language enhancements) is closed to new submissions for C++0x, but there is going to be another C++ after that ("C++13", some say). So if you think better array support is really worth pursuing, then write a proposal and submit it when EWG opens again (which should only be a couple of years from now).

      There are some other things that have to be done to the language to make this concept work, but this is the general idea. This is the elephant in the living room of C++, and Strostrup is in denial about it.

      Try to remember a few things about the committee:

      - They're all volunteers. No one gets paid directly for their committee work (although some advertise their committee involvement, and that may help them in the marketplace).

      - Every committee member has very little time to actually work on C++0x. Everyone tries his or her best to squeeze that in between company work and family time. Some highly industrious members even take vacation time to show up at committee meetings.

      - Almost everyone involved in Evolution and Library development has their own interests (either personal interests or interests expressed on behalf of an organization) in the two or three features that *they* want or need to see in the next revision. You think C++ desperately needs a particular feature? Join the club. (No, really, join the club. Show up at a meeting. You too can be a voting member of J16 and make your voice heard.)

      - Stroustrup does *not* always get what he wants. He's the EWG chair (and puts a hell of a lot of time into both running that part of the committee as well as refining his own proposals), but it's EWG itself that decides on specific motions, not Stroustrup -- except that his vote counts as much as anyone else's. So in order for any proposal to be considered, someone needs to show up, make their case, and address question

    17. Re:Strostrup is the problem by master_p · · Score: 1

      You are misinformed.

      And you don't know how to read.

      Move semantics are enabled by rvalue references (i.e., references that bind to rvalues, as opposed to the existing references in C++ '98 that bind to lvalues).

      I never said otherwise.

      Rvalue references and move semantics solve a performance problem, not a memory management problem.

      I never said that they don't. I know and understand very well how and what rvalue references and move semantics solve. You don't seem to understand how problematic move semantics are.

      By pilfering the resources of an object that's guaranteed to exist only until the end of the full-expression in which it's created, you can avoid successive calls to expensive allocators of resources (like heap memory).

      Allocation/freeing is expensive because garbage collection is not used.

      First, note that you do not get move semantics without rvalue references. And move semantics are meant to apply only to rvalues (not lvalues -- although you can explicitly force an lvalue-to-rvalue conversion and then do a move, but generally there is no need to).

      Nothing is saved by that. If you examine the examples given by Stroustrup himself (for example, on artima.com), you'll see the exact same problems that plagued auto_ptr. I guarantee you a massive outcry against move semantics by most C++ programmers.

      Second, the performance gained from compiling existing C++ programs against rvalue-ref-enabled libraries is quite measurable, and in many cases the speed gains are close to a factor of ten over the version of the same library without move semantics.

      But that's only because (in current STL), heap data are not shared! Your logic is circular: "new STL with move semantics is way faster than the old STL because of data moved around". Well, if there was garbage collection, your data could be moved around without any problem, wouldn't they?

      Third, when the committee accepted the proposal for rvalue references, *nobody* claimed that it would be used as a substitute for garbage collection.

      I don't understand why you keep telling me that rvalue references are connected with garbage collection. I never said that. All I am saying is that move semantics is bad, and if gc existed, there would be no issue to solve.

      If and when Garbage Collection is accepted, you can look forward to programs that use *both* rvalue references *and* GC (and with good reasons for using both).

      If GC is accepted, then move semantics will not be required, and hence rvalue references will not be of much use, since value copying would be pointer copying.

      On the other hand, if GC ultimately does not make it into C++0x, you should be aware that (a) it will not have been the fault of proponents of ravlue references (who are also mostly proponents of GC) and

      I don't believe that the C++ committee really likes garbage collection. It's obvious, from their replies in the various forums. They believe in manual memory management, no matter what everyone else (provably) says.

      (b) work toward GC will continue so that it can be adopted into the following C++ (probably C++13).

      Yeah, there are two things I'd like to see before I get too old to be a programmer: a) Duke Nukem Forever and b) C++ with garbage collection!!! Let's not kid ourselves, it will not happen.

      Fourth: the committee has not rejected garbage collection.

      This kind of double speak is meaningless to me: until I see GC in the language, it is in a rejected state. What I care about is for my programs to work without a problem, I don't give a dime about the C++ committee.

      Programmer-controlled GC (i.e., GC that can be explicitly disabled or explicitly enabled)

    18. Re:Strostrup is the problem by master_p · · Score: 1

      There are still freezes, but they're shorter.
      But the changes are transparent to the user of the language, and that's what counts.

      That's the problem. Resource Allocation as Initialization and garbage collection do not play well together. Do you want to wait until the next GC before a window closes?
      Actually, they do. I would not have to wait for a window to close until the next GC if a locally allocated object closes the window automatically in its destructor. RAII is one of the best concepts ever.

      Page level write protection/dirty page bit hardware, or periodic freezes. Pick one.
      Embedded systems should have their own C++. C++ is not a systems programming language, as it is erroneously being put forward. All major apps are build with C++ (and they suffer from the same problems). So, to answer your question, since all systems now have page level write protection hardware, there is simply no problem with me. Even if a garbage-collected C++ was used in an embedded environment, manual memory management could be emulated by the use of custom allocators.

      And that's the problem. There are some subtle no-nos in destructors called from garbage collectors.
      You exaggerate. The problem is minimal, actually, and it mostly involves thread synchronization primitives. No major frameworks exist (that I know of) that have objects that they lock/unlock critical sections in their destructors. I've read such cases in custom code though. Well, destructors should not lock things, and if GC ever comes in C++, this code should have to be changed. Other than that, there are no problems with destructors whatsoever.

      I'm arguing for a debug mode in which cycles are detected at the moment of creation. Cycles are typically a design time problem; if a program generates cycles, it will probably generate cycles on every execution. This tells you when you need weak pointers.
      So you prefer an extraordinary solution, highly improbable of being implemented, one that needs support from 3rd party tools, to the simple solution of garbage collection??? I am amazed. Furthermore, the general case of recognizing cycles is an unsolvable problem, thanks to the halting problem. If it was a solvable problem, it would have already been solved at run-time.

      If your data structure is anything like a tree, the cycle problem can usually be fixed by making pointers towards the root weak. I did this last year for Python's BeautifulSoup HTML/XML parser, which generated trees with pointers both backwards and sideways. By making pointers towards the root and towards previous elements "weak", I made the trees loop-free. Now they go away when the root element does, and parts can be cut out of the tree without creating loop problems.
      That's a trivial case. What about the case I described to you? programmer A writes a subclass Y of class X with a pointer to object C produced by a factory F (and F keeps a pointer of the new instance). Then another programmer B goes and changes the factory F to keep a pointer to X...and this happens not only by another programmer, but after a year programmer A did the original interface. You now have a cycle (X->Y->C->F->X) which is undetectable until performance is hurt and people notice it.
    19. Re:Strostrup is the problem by amn108 · · Score: 1

      All your fragmented heap are belong to us now.

    20. Re:Strostrup is the problem by Animats · · Score: 1

      Furthermore, the general case of recognizing cycles is an unsolvable problem, thanks to the halting problem. If it was a solvable problem, it would have already been solved at run-time.

      No. Recognizing cycles is not unsolveable. It's not even hard. See this introduction to graph algorithms. See section 1.4: "In order to detect cycles, we use a modified depth first search called a colored DFS. All nodes are initially marked white. When a node is encountered, it is marked grey, and when its descendants are completely visited, it is marked black. If a grey node is ever encountered, then there is a cycle."

    21. Re:Strostrup is the problem by mrchaotica · · Score: 1

      Well, the C programs I've written to date haven't needed to handle large data sets or run super-efficiently, so it hasn't been a problem. Besides, it's no worse than the case of something like LISP or Java, where everything is allocated on the heap...

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

    22. Re:Strostrup is the problem by master_p · · Score: 1

      You don't even need colors to detect cycles; all you need is a flag.

      But I was talking about cycle detection at compile time, i.e. statically.

      Even if cycles can be detected at run-time, it's still not as good as a solution as garbage collection, because if cycles are detected only in debug mode, then it means testing should have 100% coverage, which is something impossible in practice.

      And doing it in C++ is very difficult, because it needs support from the compiler.

    23. Re:Strostrup is the problem by Anonymous Coward · · Score: 0

      Why use C if you don't need the performance of static binding and a mature code generator?

      malloc/free have to do enough bookkeeping to free any single object and be instantly ready to reuse its memory. A GC can allocate memory by bumping one pointer, then copy only the minority of live objects (improving locality) at any time and reclaim the rest of the heap without extra work.

      If you actually have reason to worry about the cost of the heap, Lisp (not an acronym) has dynamic-extent declarations that put pretty much anything on the stack. As always, if you create any dangling references to the stack, you're doomed and deserve it.

  57. Why? by EddyPearson · · Score: 1

    Why? Market forces dictate demand for a skill or service, this is simply shameless promotion of his own language.

    If we really DID need better/more C++ coders, then they would appear.

    --
    You feel sleepy. Close your eyes. The opinions stated above are yours. You cannot imagine why you ever felt otherwise.
    1. Re:Why? by IntlHarvester · · Score: 1

      Or the market would respond by creating Java and C#.

      Not to mention that the little supply/demand graph in your Econ 101 textbook doesn't operate on "internet time". Even if there was a serious attempt at improving C++ education, you wouldn't see the effects until 5 years from now, long after the deadline of your current project.

      --
      Business. Numbers. Money. People. Computer World.
  58. Re:Education, even at Universities, needs to Impro by dkf · · Score: 1

    Pointers are your best friend when you know how to use them. Umm, it's probably fairer to say that pointers are the professional power tools of the computing world. When you need them, they'll do wonders, but they'll just as happily chew big holes in both yourself and passing bystanders. Use with caution, but do use when needed.
    --
    "Little does he know, but there is no 'I' in 'Idiot'!"
  59. So long its not Matlab by Latent+Heat · · Score: 4, Interesting
    The trend we need to fight is not teaching programming using Java, C, or C++, but defaulting to Matlab as a programming language of choice. This is what is happening in Engineering colleges and other non-CS places at the U.

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

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

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

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

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

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

    1. Re:So long its not Matlab by William+Stein · · Score: 5, Informative

      > What the community needs right now is a Python distro with enough of a
      > numerics and graphics package rolled in to do 90 percent of what is in
      > Matlab.

      Good idea. This is what both Sage and the Enthought Python Distribution are
      shooting for.

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

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

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

      There is Matplotlib for
      matlab like numpy graphics, and Chaco for more dynamic 2d graphics. MayaVi and Sage both provide powerful 3d graphics.

    2. Re:So long its not Matlab by Anonymous Coward · · Score: 0

      Yeah. I think people should realize that practical day-to-day programming for most programmers has almost nothing to do with mathematics. It's brain dead to teach programming using math examples.

      Also, come on. Drop C++, it should never have existed. For low-level languages, there has been a better alternative for very long. It's called Objective-C and it is supported by gcc.

    3. Re:So long its not Matlab by JaBob · · Score: 1

      It's funny to me that you mention MATLAB and how some people want to use it for everything. It is required as part of my undergrad engineering curriculum (and yes, the prof was versed in FORTRAN) and everyone in engineering seems to love it, but when you talk to anyone with even a hint of CS background, they all hate it. My friend just got his MS in mechanical (his panel said that he did enough work to get a PhD, but they couldn't just jump and give it to him), and has past experience managing SQL stuff, has a bunch of MS certs, and some experience in programming FPGAs and camera electronics, and blah blah blah. Basically he's the guy I go to when it comes to anything electronic. I asked him how much to concentrate on MATLAB and he said... don't... use it for making pretty pictures of your data, but do everything else in C++ or C#, whichever I feel more comfortable with as it would run a few orders of magnitude faster. He says that sure, MATLAB is stupid easy to use, so it's alright for a one off quick thing, but if you ever need to program for a real project that needs to run more than a handful of times or needs to run quickly, do the work and program it in a real language. YMMV though.

    4. Re:So long its not Matlab by Anonymous Coward · · Score: 0

      There is at least one such distro already.

    5. Re:So long its not Matlab by Chris+Pimlott · · Score: 1

      You seem to mention it with some disdain, but my numerical methods (in ~2002) class was in Fortran and the language is well suited for it.

    6. Re:So long its not Matlab by sciurus0 · · Score: 1
    7. Re:So long its not Matlab by jstott · · Score: 0

      Researchers (including myself) us Matlab because:

      1. Despite what your students say, my experience has always been it's easier to debug Matlab code than compiled code, if you know anything about programming. Being interpreted and having good graphics routines built-in, I've found it especially handy for prototyping algorithms where the code changes quickly and most changes are one-offs.
      2. It's got library routines for 99% of what I need.
      3. It's fast enough for 85% of what I need.
      4. Data types of float, int, and string are 99% of what I need (this is a research lab, not a software shop, after all). Object-oriented is just another place for the bugs to hide.

      Why should I wait for someone to re-write all this in Python, and then put up with some else's buggy numerical code? Matlab is available, well-supported, actively devloped and maintained, and it lets me do the job I need to do faster than anything else.

      -JS

      --
      Vanity of vanities, all is vanity...
    8. Re:So long its not Matlab by dascandy · · Score: 1

      The problem with teaching to students is this:

      Whatever language you teach, they'll pick it up so badly that the average grade will be about a D, pumped up under pressure from management to a C average. If you change to an easier language, students will become dumber, restoring the balance.

      I suggest, let's switch back to a language that lets you deal with algorithmic trouble and that is commonly usable. I really don't care which. Just make sure that you don't get management pressure for a number of passing students - just let those pass that know what the hell they're doing.

    9. Re:So long its not Matlab by Arnonymous+Coward · · Score: 1

      Matlab (and/or Octave) rock. It's great - you spend a few hours at a whiteboard solving your problem, and finally get it down to a matrix computation like A*B*C, then you spend all of 5 minutes in Matlab, and your problem is solved.

      You don't need to worry about trivial stuff that is unrelated to your problem like including libraries, or floating point issues, or reading up on the fastest matrix diagonalization methods, or memory management, etc. That is all done under the hood, so you can concentrate on solving your problem. If you have a bug, its probably because you did the math wrong before starting to code. This is why scientists and engineers like Matlab so much.

    10. Re:So long its not Matlab by Anonymous Coward · · Score: 0

      How about SAGE http://www.sagemath.org/ or matplotlib?

      Both Python based.

    11. Re:So long its not Matlab by MajroMax · · Score: 0

      Our required Numerical Methods course is in CS, it uses Matlab, our faculty is complaining that the students are complaining that they hate the course because they are spinning their wheels trying to get programs to run (in Matlab of all things), and we have guys in our department we want to teach Numerical Methods (in Matlab, of course), in the context of a watered-down Intro to Engineering offering.

      Speaking as a math grad student with a CS undergraduate degree, Matlab is the best program/language to use for numerical programming. For ODEs and PDEs -- the numerical applications I've seen most often -- numerical methods boil down to matrix/vector manipulation, with little in the way of data structure manipulation. That is Matlab's forte, and it works extremely well.

      I'll be the first to agree that Matlab is quite limited. The thought of any kind of data structure manipulation in the language makes me shudder. But for a Numerical Methods class, it's definitely the right language.

      Matlab started around wrapping calls to LAPACK and BLAS libraries. For those things, it is fast, efficient, and elegant. For most everything else, Matlab is slow, cumbersome, and inelegant. But that's fine, it's a very specialized language.

      One side note: personally I found the experience of working with Matlab to be broadening as a programmer. It's not often that you see a language where vectors and matrices are first-order datatypes, in some ways even superior to scalars.

      --
      "Evil company X is threatening to restrict our rights! Let's all get together to stop--OOOH! SHINEY!!!" -- AC
    12. Re:So long its not Matlab by Anonymous Coward · · Score: 0

      Also, PyTrilinos looks really good for parallel sparse linear algebra +++

      The FEniCS project provides advanced finite element functionality, but the Python interface PyDOLFIN is still a bit immature.

      Sympy, sympy-core and swiginac are symbolic algebra packages.

      Paraview can also be scripted from Python.

  60. Re:I'm just glad they're teaching C++ actively aga by mikael · · Score: 1, Offtopic

    Sometimes, when you want to prototype something quickly, being able to edit a test.cpp file with a basic int main( int argc, char *argv[] ) { } and compile it with a g++ test.cpp is the way to go. I would hate to forced to have to open up a IDE window, create a basic application, edit and register a couple of derived classes, a project build file, all to test something simple like some library functions.

    --
    Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
  61. Re:Education, even at Universities, needs to Impro by Seferino · · Score: 1

    It's a simple thing, really. I'm a university lecturer and I have explicit instructions to grant the degree to as many people as possible, 100% ideally -- and that's independent from their actual skill level, because some of them are barely able to understand simple questions or simple mathematics. The only solution is to lower down the expectations for the whole class -- and single out the brightest students to teach them more advanced topics whenever the mass is still trying to solve the easy exercises. Not very flattering, but then, I don't have much of a choice.

  62. Re:I'm just glad they're teaching C++ actively aga by cbart387 · · Score: 1

    Agreed, others have already corrected me (see above) and I have acknowledged it. I have used some Lisp so I am (at least tiny bit) familiar with functional programming. Just a slip of the fingers :/

    --
    Lack of planning on your part does not constitute an emergency on mine.
  63. Re:Education, even at Universities, needs to Impro by Anonymous Coward · · Score: 0

    I agreed with you up until you complained that people didn't know K&R or Knuth. There are a ton of books out there now - why should people favor the oldest ones? The most important problems in computer programming have changed a lot in the last twenty or thirty years. K&R? Why use a C book to teach C++ when you could use a C++ book? Knuth? It was esoteric beyond belief even when it came out (there's a reason it's 4 volumes long), and it's even more so now.

    Yes, yes, I get it. You want students to learn "real" programming, not wishy-washy stuff. But uh, a modern book can cover pointers too. And K&R or Knuth is not where to turn for object-oriented programming.

  64. Mod parent up! by mcvos · · Score: 1

    I think that most poor use of C++ can be traced to the use of C++.

    This is an extremely important point. Use the right tool for the job. C++ is not the right tool for most jobs it's being used for. It's probably fine for low-level systems programming (the same stuff you'd use C for), but the only excuse to use it for large applications is if you're stuck in the late '80s and there's nothing better availlable. Now there are far superior languages availlable, so learn to pick the right one for the job.

  65. Re:Education, even at Universities, needs to Impro by Anonymous Coward · · Score: 0

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

    I don't doubt that at all. The best programmers always came from physics departments and other disciplines. The CS department spends way too much of their time masturbating to their own topics that matter once or twice in a career.

  66. Re:Education, even at Universities, needs to Impro by rolfwind · · Score: 1

    AoCP is excellent, but K&R is a overrated piece of shit. It's hard to learn from, for a decent book on C -- it should be "Pointers on C" by Kenneth Reek or something similiar.

    K&R is fine once you actually know C, but to learn from it's a horribly terse non-self-explanatory PoS. I'm rather interested in how many people know the Unix Haters Handbook, as that is more worthwhile.

  67. Re:I'm just glad they're teaching C++ actively aga by mcvos · · Score: 3, Insightful

    For quick prototyping, use Python or Ruby. Or even Perl, if you really can't help yourself.

    Yes, the lack of top-level functions in Java is well-known criticism (at least from the Python/Ruby crowd), but personally I've never had any problems with that, mostly because I don't use Java for quick scripts. The constant need to cast everything is a much bigger problem, IMO.

  68. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    And with C++. That is actually a good point in favor of C++, you can start with imperative, go to object oriented and have some functional programming in between. Allthough it lacks most syntactic features that make functionall programming in a language like haskell easy.

    But that might be the main problem of C++. To use C++ effectively you should have used other languages that are more specialized to a single programming paradigm.

  69. Re:I'm just glad they're teaching C++ actively aga by med1972 · · Score: 1

    Queen's University here in Kingston (Ontario, Canada) is dropping C++ from their 2nd year intro CS course this fall. It is Java only now. And the first year intro CS course is switching to from Java to Python.

  70. Re:I got my B.Sc. in Comp. Sci in the 1970s and .. by siwelwerd · · Score: 1

    I learned FORTRAN first semester of my freshman year, way back in 2003...

  71. Change of heart? by Anonymous Coward · · Score: 0

    Stroustrup really seems to have changed his views on this. In a suppressed interview to IEEE's "Computer" magazine from 1998, Soustrup said "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." The rest of the interview has not yet made wikileaks but can be found at http://www.netfunny.com/rhf/jokes/98/May/stroustrup.html.

  72. langugage fragmentation and forking by NynexNinja · · Score: 1

    I think that all Bjorne has really done to the C language is cause more and more fragmentation, forking and division... He created fragmentation with C++, and he again created more fragmentation with "C++0x". This guy should be banned from creating languages. Instead of making new languages, why not improve on the C language standard? He doesn't want to do that, he wants to make a name for himself by creating all these different languages... I don't think what he has done has done anything to better the world of computer science.

    1. Re:langugage fragmentation and forking by jgrahn · · Score: 1

      I think that all Bjorne has really done to the C language is cause more and more fragmentation, forking and division... He created fragmentation with C++, and he again created more fragmentation with "C++0x". This guy should be banned from creating languages. Instead of making new languages, why not improve on the C language standard? He doesn't want to do that, he wants to make a name for himself by creating all these different languages... I don't think what he has done has done anything to better the world of computer science.

      You are posting gibberish, or trolling. Either that, or Stroustrup has been dating your sister, or kicked your dog.

      All Bjarne (sic!) has done to the C language is basing one (1) language on it. That was 25 years ago so K&R have probably forgiven him by now.

  73. Re:I'm just glad they're teaching C++ actively aga by mollymoo · · Score: 1

    It is annoying and slow, but the fact that you can't as easily just hack together a quick and dirty test makes writing a proper unit test comparatively less unattractive. Annoying, but perhaps not such a bad thing in the long run.

    --
    Chernobyl 'not a wildlife haven' - BBC News
  74. Linus Torvalds on C++ by Scareduck · · Score: 3, Interesting
    After agonizing over a problem that in theory should have been made simpler by operator overloading (I'm trying to do some numerical integration using a multi-precision library), I typed "c++ sucks" into Google. Lo and behold, but Linus Torvalds agrees with that sentiment:

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

    ...

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

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

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

    --

    Dog is my co-pilot.

    1. Re:Linus Torvalds on C++ by sega01 · · Score: 1

      I agree completely. C is my language of choice. In the case of GCC and G++, smaller and faster binaries are usually produced with C, and IMO it is so much more elegant to write in. Sure, you may spend a little more time initially coding a project for certain "petty" functions, but they will be so much easier to expand upon and improve later on. C++ just pains me to read. I enjoy Lua for scripting, though I am not yet very proficent with either C or Lua (I have mostly just read of the differences and benchmarks).

    2. Re:Linus Torvalds on C++ by shplorb · · Score: 1

      But then Torvalds is hardly one to talk. Linux is written in C and he is firmly rooted in its ways. Personally, I think the Linux code looks like shit and is a mess because I'm a C++ programmer and it doesn't match my normal style. That's not to say it's not good and doesn't work well though. I agree that there's a lot of shitty C++ code out there written by people who don't know what they're doing. These are the sort of people who hear about some hot new thing and decide to apply it to everything. Java, XML, .NET, OOP, generic programming, etc.

      I work in games, we write them in C++, as do hundreds of other studios around the world. The Joint Strike Fighter has all its software written in C++. How do we do it and manage to write high-performance and reliable code that works in embedded environments? We do it because we know what we're doing and only use the features of the language that are necessary. E.g. STL, exceptions? Fuck that! We assume it's C and then use the extra features of C++ as they suit the task at hand. Just because the language lets you do it, doesn't mean you should.

      The extraordinary breadth and depth of the language and its features are what I believe make it so great. I fully agree with Stroustrup in the article. People just need to harden the fuck up and realise that life ain't easy and neither is writing code. It takes time to learn and master the tools. You don't throw someone a "Teach Yourself Carpentry in 21 Days" book and expect them to be able to craft furniture like someone who has worked as an apprentice for four years. Why should programming in C++ (or any serious language for that matter) be any different? I've been coding in C++ for about 14 years now - when I started I don't think there was such thing as templates, and I'm still willing to admit that there are things you can do with the language that I don't know about and that's because I haven't found a need for it yet.

      Anyway, I can't really remember the point of this rant... must be going senile in my old age (and I'm not even 30 yet!)

    3. Re:Linus Torvalds on C++ by try_anything · · Score: 1

      No one should take Linus seriously on this. There is one and only one reason there is no C++ in the kernel: continuity of technical leadership. Linus and the other top kernel guys, and the guys they trust, are C gurus who have much less experience with C++. The success of Linux has a lot to do with the people acting as technical directors and gatekeepers, and it would be insane to create a path into the kernel that bypassed all of their expert critical ability. But Linus loves to stir things up, so he didn't say that. Instead, he said a bunch of snarky things about C++ to ingratiate himself to C programmers and dissuade anyone from pressing him further on the issue.

      To address only one issue from his litany of complaints, his criticism of C++ abstraction mechanisms is unjustified. C++ abstractions are just as efficient as the C alternatives; Stroustrup kept a lot of potentially useful things out of the language to make sure that was the case. The few exceptions involve C++ language features that can and would be disabled in a kernel dialect. Also, abstractions are just ways of expressing design decisions. There are just as many design decisions in C as in C++, and design decisions in C get enshrined in code just like in C++. C++ abstractions do not embed design decisions into code more deeply than C abstractions.

      I think Linus and many other C coders look at simple, elegant C code and think, "The 'right' way to write this in C++ would involve a inheritance and templates and a bunch of ungodly stuff." It isn't so. To the best of my knowledge, every C++ language feature (with the possible exception of exceptions) was invented to support a recurring design pattern that large-scale systems programmers were being forced to express badly in C. C macros (and other macro languages) were being used to create hackish, broken versions of inheritance, destructors, and templates. C++ language features were created to replace heinous macro and longjmp hackery, and to replace ad-hoc homegrown code generators, not to replace the simple, elegant kind of C code that actually works.

      Of course C++ would be wrong for Linux. Continuity of technical leadership is a compelling reason to keep it out, but it would have sounded kind of lazy and conservative to say so. Bashing C++ sounds much more 1337. Frankly, I think it's pretty childish to bash a language just because you don't personally have a use for it. I think if someone abducted Linus into slavery and forced him to write corporate middleware systems in C, he would cry for a little while and then beg for permission to use a more suitable language, even if it was C++.

  75. Re:I'm just glad they're teaching C++ actively aga by LizardKing · · Score: 2, Insightful

    Err, are you saying that you *have* to use an IDE to generate a class to run a Java app? The equivalent of your C++ main would be:

    public class Test {
    public static void main(String[] args) {
    // ...
    }
    }

    Why do you need an IDE to write that?

  76. Ruby? by SanityInAnarchy · · Score: 1

    I feel your pain -- I don't agree with everything you've listed, but it seems most languages provide maybe half.

    Let me try what I know -- Ruby does this:

    1. DSLs in Ruby are pretty reasonable. Operator overloading and syntactic sugar make it easy to do things like... well, look at Rake or Capistrano for examples.
    2. Polymorphic by default.
    3. Tricky -- Lambdas are just slightly awkward, but it has a "block" syntax which works well for the most common uses of lambdas -- that is, one lambda passed to one function. In fact, the inline lambda syntax is a specific example of block syntax.
    4. I don't know what this means. (I've read the Wikipedia article, but I don't grok it enough to know at a glance.) Personally, I'd be willing to sacrifice compiler/tool simplicity for language readability.
    5. All classes are open. Everything's an object. There's so much metaprogramming you can do that much advice is written about when not to apply it.
    6. I'm not entirely sure how this differs from the above, but I'm going to say it's possible. It's possible to get a list of method names as strings, and possible to retrieve a method by its name. Not quite as much as LISP, I imagine.
    7. Static typing, but implicit typing. The term is "duck typing." However, if you really want to, you can build your own static type checking.
    8. Ruby seems to run pretty much everywhere C does, and I've developed on x86_64 Linux in parallel with people on 32-bit Windows or some flavor of OS X.
    9. Performance sucks. It's getting better, but it still sucks. I keep looking for something with at least most of the features I like from Ruby, but with reasonable performance.
    10. I'm going to say yes.
    11. I'm not quite sure what this means, I'd need to see an example. I suspect it's a yes, or at least a "you can implement it yourself".

    So, by my count, 7 yes, 2 maybe, 1 no, and 1 I don't know at all.

    I probably have a slightly longer list, but I am constantly frustrated by just these three:

    1. Reasonably powerful language, such that I can implement any missing features (including reasonable syntax) myself. (Also, bindings should be sane, but I'm operating under the assumption that most bindings I care about will already be written.)
    2. Reasonable performance -- should be at least 80-90% of what I could expect from C/C++. I don't want to have to write C extensions purely for performance, except in very rare and isolated situations where I actually do need another 10%. And yes, I do think this is possible.
    3. Platform independence, or at least support for platforms I care about. Lack of x86_64 support is a deal-breaker.

    I can occasionally get two. Ruby is #1 and #3. Squeak/Smalltalk seems to be #1 and #2. Java/C# might be #2 and #3. I write Ruby because I'm currently writing web apps, and I can actually just throw more servers at the problem to make it go away.

    But I keep finding new ideas that I wish I had elsewhere -- Erlang's parallelism, though it isn't much, still contains features I find missing from most languages. Haskell's lazy evaluation shouldn't require a purely functional language.

    But if I could ever find a language which supported all three of those core ideas, I'd happily implement the rest on top of it.

    --
    Don't thank God, thank a doctor!
    1. Re:Ruby? by EsbenMoseHansen · · Score: 1

      I feel your pain -- I don't agree with everything you've listed, but it seems most languages provide maybe half.

      Let me try what I know -- Ruby does this:

      Ruby is definitely my choice when performance is not an issue. It tends to be though :/ Where ruby is lacking is in the static department. Static polymorphism, static typechecks, metaprogramming and that stuff. Otherwise, it is a very strong language, including a lot of good features.

      DSLs in Ruby are pretty reasonable. Operator overloading and syntactic sugar make it easy to do things like... well, look at Rake or Capistrano for examples.

      This is one of the strongest points in Ruby. Natural and strong. Just wish they had used unicode as the compiler language, then we could have gotten real less-than-or-equal operators :)

      Polymorphic by default.

      Indeed, but only dynamic. Not overloading, specialisation or anything like that. :(

      Tricky -- Lambdas are just slightly awkward, but it has a "block" syntax which works well for the most common uses of lambdas -- that is, one lambda passed to one function. In fact, the inline lambda syntax is a specific example of block syntax.

      It is plenty close. I'm not asking for perfection, if a language support as much of lambdas as Ruby does, I'm more than satisfied.

      I don't know what this means. (I've read the Wikipedia article, but I don't grok it enough to know at a glance.) Personally, I'd be willing to sacrifice compiler/tool simplicity for language readability.

      For big projects, code completion, class summaries and refactoring support is very nice. It's not Java, so it doesn't need quite as much support. C++ is actually and actively held back because of the very complex parse.

      All classes are open. Everything's an object. There's so much metaprogramming you can do that much advice is written about when not to apply it.

      Another strong point in Ruby. Real constants and constant functions would be nice, though. (Damn, another point I forgot on my list :( ) Anyway, this is not metaprogramming, but reflection, as I understand it. Rather, I'm thinking of stuff like "you write a grammar, and the compiler+library builds the parser from that." This is a point very C++ is extremely strong, though far from perfect. In practice, it requires the compilation part of the language to be Turing complete.

      Static typing, but implicit typing. The term is "duck typing." However, if you really want to, you can build your own static type checking.

      Duck typing does not require the typing to be implicit. I want the compilation to fail if and only if the type passed does not meet the required abilities. E.g, a method that (only) calls one method should accept all parameters that have that method. Hope I make myself comprehensible :o) C++ does this with templated methods.

      Ruby seems to run pretty much everywhere C does, and I've developed on x86_64 Linux in parallel with people on 32-bit Windows or some flavor of OS X.

      Yes, but it relies on a virtual machine. I do not like that requirement, and I don't think it is strictly necessary.

      I'm not quite sure what this means, I'd need to see an example. I suspect it's a yes, or at least a "you can implement it yourself".

      It is merely that if I have a function that adds to numbers, I should be able to make a function that computes a number + 4. Of course, the compiler should infer the parameters and return values. In C++, you cannot do this in the general case, though the one I mentioned is supported (through std::bind1st). I don't think it is directly possible in Ruby, though you could make limited library support for it ala C++. Without a static type system, though, the result is not so useful.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    2. Re:Ruby? by SanityInAnarchy · · Score: 2, Insightful

      Where ruby is lacking is in the static department. Static polymorphism, static typechecks, metaprogramming and that stuff.

      You can still use the === operator, or the kind_of? method. And I'm fairly certain metaprogramming is supported.

      I've just found that static type checking is about all that's missing, and it isn't incredibly useful, especially when you're doing unit tests.

      Just wish they had used unicode as the compiler language, then we could have gotten real less-than-or-equal operators :)

      I'd assumed they did? After all, Ruby is from Japan...

      It is nice that it really only uses ASCII for the language itself, though. I should add that to my list.

      Indeed, but only dynamic. Not overloading, specialisation or anything like that. :(

      I'm feeling a bit lost in this jargon... Can you give me some specific examples?

      For big projects, code completion, class summaries and refactoring support is very nice.

      When these are done for me, via things like Eclipse plugins, I don't worry too much about how complex they are under the hood, so long as they work.

      Real constants and constant functions would be nice, though.

      For what, though?

      The existing constants are difficult enough to override without at least a warning, and I think that's really all you need. The same could be said of the private/protected methods -- there is a bit of a mess with the usage of 'send', but in a language which truly supports reflection and metaprogramming, private/protected is effectively only a warning anyway, as there's always a way around it.

      Rather, I'm thinking of stuff like "you write a grammar, and the compiler+library builds the parser from that."

      Ruby is at least as strong as C++, I'd think, due to how easy lambdas are. This seems to be about DSLs again, right?

      The syntax for calling functions, and for passing them blocks, is simple and clean enough that it almost feels like defining your own language directives. Yet it's all still valid Ruby, which means it's usually readable by anyone who understands Ruby, and it's easy to mix and match.

      This is a point very C++ is extremely strong, though far from perfect. In practice, it requires the compilation part of the language to be Turing complete.

      In other words, LISP.

      Duck typing does not require the typing to be implicit. I want the compilation to fail if and only if the type passed does not meet the required abilities.

      I'd argue that the sanest way to do this is to just make the typing implicit.

      C++ does this with templated methods.

      Which still means that you have to put everything (somehow) into the type system, in order for the template to match, if I understand it. It also means that you have that extra template syntax in order to give you something that I think should be on by default.

      Yes, but it relies on a virtual machine. I do not like that requirement, and I don't think it is strictly necessary.

      Why don't you like that requirement?

      It is merely that if I have a function that adds to numbers, I should be able to make a function that computes a number + 4.

      In the simplest case, I suppose you can define such a function explicitly:

      def add(a, b)
      a + b
      end
      def add_four(x)
      add(x, 4)
      end

      But I suspect that's not what you want. I suspect you're talking about bind variables, which Ruby can do. (Even JavaScript can do those.)

      That is, you want something like:

      a = generate_add(4)
      a.call(3)

      And this can be

      --
      Don't thank God, thank a doctor!
    3. Re:Ruby? by EsbenMoseHansen · · Score: 2, Interesting

      Where ruby is lacking is in the static department. Static polymorphism, static typechecks, metaprogramming and that stuff.

      You can still use the === operator, or the kind_of? method. And I'm fairly certain metaprogramming is supported.

      That would still be runtime. I want it to be compile time, so that I don't pay a runtime overhead for something that could be precomputed, and so that type errors and other such trivia is out of the way before I begin testing. It's like getting a free peer review :o)

      I've just found that static type checking is about all that's missing, and it isn't incredibly useful, especially when you're doing unit tests.

      I think we just have to disagree there. Unit test doesn't always save you from odd corner cases. Strict and static typing helps there.

      Just wish they had used unicode as the compiler language, then we could have gotten real less-than-or-equal operators :)

      I'd assumed they did? After all, Ruby is from Japan...

      It is kind of ironic, but until recently ruby's unicode support sucked.

      Indeed, but only dynamic. Not overloading, specialisation or anything like that. :(

      I'm feeling a bit lost in this jargon... Can you give me some specific examples?

      Hmm. I hate giving examples in slashdot code. For specialization, std::hash is a nice example. std::hash is specialized for all object that want to support hashing. So if you have a class that can't or won't hash, the compiling fails. In ruby you'll fail at compile time. In Java, you'll get a weird behaviour, as i recall. Overloading is simple... instead of a function starting with a bunch of test to find out what sort of argument you got, the correct function will be inferred by the type. So operator/(double) is a completely different method than operator/(complex).

      For big projects, code completion, class summaries and refactoring support is very nice.

      When these are done for me, via things like Eclipse plugins, I don't worry too much about how complex they are under the hood, so long as they work.

      Try getting that to work properly for C++. KDevelop is the best, and far from perfect in my experience.

      Real constants and constant functions would be nice, though.

      For what, though?

      Again, for those compile-time checks. In C++ I can return a constant reference and *know* that it won't get modified. Or call a constant member and know that the method doesn't modify the object. (Like the conventions of ! and non-! in ruby, but more general).

      The existing constants are difficult enough to override without at least a warning, and I think that's really all you need. The same could be said of the private/protected methods -- there is a bit of a mess with the usage of 'send', but in a language which truly supports reflection and metaprogramming, private/protected is effectively only a warning anyway, as there's always a way around it.

      I agree, but constants variables are just the beginning. It's the constant methods and return values that are truly valuable.

      Ruby is at least as strong as C++, I'd think, due to how easy lambdas are. This seems to be about DSLs again, right?

      Dynamically, ruby is stronger. Statically, C++ is stronger.

      The syntax for calling functions, and for passing them blocks, is simple and clean enough that it almost feels like defining your own language directives. Yet it's all still valid Ruby, which means it's usually readable by anyone who understands Ruby, and it's easy to mix and match.

      I love that featu

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    4. Re:Ruby? by SanityInAnarchy · · Score: 1

      That would still be runtime. I want it to be compile time, so that I don't pay a runtime overhead for something that could be precomputed

      My answer to that would be, eventually, smarter compilers could be built. If you expect to do a lot of differentiation based on the actual type you receive, you could define a DSL for that, which, if it became popular enough, could be implemented natively by future compilers, without actually doing anything to the base language.

      And a more general answer: I want to get the language right first, in terms of what is most efficient to code in. Occasionally, I can see designing it so that it supports future optimizations -- Ruby's symbols are an example of this, even if they're curently implemented as strings (I think). But only if such modifications leave the language at least as clean and readable as it was before -- Ruby's symbols are actually one less character to type than using a string instead.

      and so that type errors and other such trivia is out of the way before I begin testing.

      I see type errors as just another thing to write unit tests for -- assuming they become an issue at all. If I already have unit tests covering most of my code, I probably don't have to think about types there, either.

      It's hard to measure objectively, but how much time do you spend thinking about type hierarchies, or building additional code which wouldn't be needed with implicit typing? And how much time would you spend tracking down type errors?

      I think we just have to disagree there. Unit test doesn't always save you from odd corner cases. Strict and static typing helps there.

      Static typing won't always save you from odd corner cases, either. I'd argue that static typing in the absence of unit tests is significantly less robust than unit testing in the absence of static typing.

      There's an additional argument that if you're getting such odd corner cases that your tests don't cover, either you're not very good at writing tests, or your architecture is too complex, and needs to be redesigned.

      You may be right, though, that we have to disagree. This isn't exactly a new debate. I know I'm never going back to explicit typing, at least.

      std::hash is specialized for all object that want to support hashing. So if you have a class that can't or won't hash, the compiling fails....Overloading is simple... instead of a function starting with a bunch of test to find out what sort of argument you got, the correct function will be inferred by the type. So operator/(double) is a completely different method than operator/(complex).

      Well, again, this is something which can be dealt with (kind_of?, ===, case/when) -- and something you could write a DSL for. It just ends up getting dealt with at runtime, instead of compile time.

      Since I don't like external DSLs -- that is, a preprocessor that is, itself, a completely different language/syntax -- I have to accept that there's a very good chance that the line between compiletime/runtime might get blurred. And since I do believe in a robust test suite, I don't mind that as much as you would.

      In C++ I can return a constant reference and *know* that it won't get modified. Or call a constant member and know that the method doesn't modify the object.

      I don't think these are guarantees you can have in a dynamic language.

      I agree, but constants variables are just the beginning. It's the constant methods and return values that are truly valuable.

      Constant methods being, by your own admittance, just a stricter form of the bang convention in Ruby.

      Actually, let me take that a step further: If you wanted to do some static code analysis, this is almost as simple as grep. Any method that doesn't end in a bang (!) may not call any other method on the object or its properties which

      --
      Don't thank God, thank a doctor!
    5. Re:Ruby? by EsbenMoseHansen · · Score: 1

      That would still be runtime. I want it to be compile time, so that I don't pay a runtime overhead for something that could be precomputed

      My answer to that would be, eventually, smarter compilers could be built. If you expect to do a lot of differentiation based on the actual type you receive, you could define a DSL for that, which, if it became popular enough, could be implemented natively by future compilers, without actually doing anything to the base language.

      I think that would amount to solving the halting problem, which is impossible as far as we know. I'm all for making the compilers do the hard work, but asking the impossible is never going to get us anywhere. E.g, it is in general not possible for a compiler to see what parameters a function will be called with, as the function could be called with the result of an arbitrary function, which would be the same as solving the halting problem.

      And a more general answer: I want to get the language right first, in terms of what is most efficient to code in. Occasionally, I can see designing it so that it supports future optimizations -- Ruby's symbols are an example of this, even if they're currently implemented as strings (I think). But only if such modifications leave the language at least as clean and readable as it was before -- Ruby's symbols are actually one less character to type than using a string instead.

      Most efficient is of course the goal, though I maintain that efficiency must be both in coding and maintenance. Anyway, the important thing is that the programmer can express intent as clearly as possible. Thus, I find

      (1..10).each{ |i| puts i }

      to be slightly better than a straight for loop, though the puts is a terrible function name. The stuff I mention is not (only) about execution efficiency, it's also about expression intent.

      and so that type errors and other such trivia is out of the way before I begin testing.

      I see type errors as just another thing to write unit tests for -- assuming they become an issue at all. If I already have unit tests covering most of my code, I probably don't have to think about types there, either.

      So you think. However, a unit test cannot possible cover all possible interactions between all functions in any reasonable application. Thus, there will be cases not covered by your unittest, and those will fail horrible. Consider code like

      "cheese".+ (myfunc()).

      . Both this code and myfunc() might be behaving as they should, but their interaction could result in a type error, which would be trivial to catch for a statically typed language. Instead, you will be debugging a production problem with some helpful message ala "type error: cannot convert Fixnum to String".

      It's hard to measure objectively, but how much time do you spend thinking about type hierarchies, or building additional code which wouldn't be needed with implicit typing? And how much time would you spend tracking down type errors?

      A lot less than I spend writing unit test for type errors, not to mention debugging type errors. Like looking up in a hash table, but accidentially using a converted form (say, to string) of the key instead of the intended key.

      I think we just have to disagree there. Unit test doesn't always save you from odd corner cases. Strict and static typing helps there.

      Static typing won't always save you from odd corner cases, either. I'd argue that static typing in the absence of unit tests is significantly less robust than unit testing in the absence of static typing.

      I never claimed they did, but they do catch some problems immediately that unit cannot catch.

      There's an additional argument th

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    6. Re:Ruby? by SanityInAnarchy · · Score: 1

      it is in general not possible for a compiler to see what parameters a function will be called with, as the function could be called with the result of an arbitrary function

      It is, however, possible for a VM to watch what parameters a function is actually called with. I'm afraid I've fallen into the habit of calling any tool a "compiler", occasionally.

      Both this code and myfunc() might be behaving as they should, but their interaction could result in a type error, which would be trivial to catch for a statically typed language.

      That is one example. I haven't had enough sleep for a proper reply, so I am not sure if I can find a good code example, but I'm going to suggest that you can have things like this occur in an explicitly-typed language. Templates and anywhere you typecast are places you could have potentially interesting interactions.

      And that would likely be caught by a functional test -- though you're right, you can't catch everything.

      More importantly, you have to wonder at the wisdom of myfunc returning these incompatible types in the first place -- what is so complex about myfunc that it can't return something predictable? Is this something which could be helped by simplifying the design?

      I'm not sure I can say much more, though, without context.

      Instead, you will be debugging a production problem with some helpful message ala "type error: cannot convert Fixnum to String".

      And a healthy stacktrace.

      Like looking up in a hash table, but accidentially using a converted form (say, to string) of the key instead of the intended key.

      I honestly cannot ever remember doing that. Not once.

      It's simple stuff, and they could be prevented with good pre and postcondition checks, but I know that everyone forgets at least some of those. Besides, it clutters the code.

      Well, I find explicit typing to be that much more clutter. I don't need pre and postcondition checks everywhere.

      Of course you can :) You even write it yourself with the grep below, integrate your grep with the language and you've got it.

      It's not a guarantee, just a test. Unless I've also got a grep which blocks all 'eval' statements, for instance -- not that I use many of those, but they do have legitimate uses.

      There is a keyword for handling that case. mutable, if you want to check up on it.

      I'll have to let that digest for a bit. My initial reaction is that this is still less flexible -- I realize that's on purpose, of course.

      But one thing I love about accessors in the first place is the ability to shift the implementation around underneath of whatever's using it. I'm not sure mutable covers everything I might want to do with a former accessor.

      Yeah, I read that article too. As I recall, The author was incapable of writing even remotely efficient C++, and mistook that for VM efficiency

      You're thinking of a different article.

      Imagine, instead, that you write an emulator for x86 -- like virtualization (running multiple OSes at once), only it actually emulates instead. And you find that Windows inside this emulation is faster than Windows on the bare metal -- of the same machine that's running the emulator.

      Now, it wasn't x86, and again, I can't find the article. (Probably some flavor of RISC?) But I think that, if anything, proves that VMs could be written which would beat native code, current implementations notwithstanding.

      compare this to equivalent Java, and the Java runtime will realize that it doesn't need to create the object on the heap. Of course, if you write the C++ naturally void func() { MyObject obj; }

      It looks as if that wasn't testing runtime optimizations, but compiler optimizations

      --
      Don't thank God, thank a doctor!
    7. Re:Ruby? by EsbenMoseHansen · · Score: 1

      it is in general not possible for a compiler to see what parameters a function will be called with, as the function could be called with the result of an arbitrary function

      It is, however, possible for a VM to watch what parameters a function is actually called with. I'm afraid I've fallen into the habit of calling any tool a "compiler", occasionally.

      Ok, sorry for the confusion. It is, however, not possible for a VM to predict future calls either, and anyway, the VM would then have to waste clockcycles during every run, instead of having it calculated once and for all.

      That is one example. I haven't had enough sleep for a proper reply, so I am not sure if I can find a good code example, but I'm going to suggest that you can have things like this occur in an explicitly-typed language. Templates and anywhere you typecast are places you could have potentially interesting interactions.

      You can't. That's the point about type-safety, it's a strong garantee. The code might fail, but it will be during compiletime. Barring bugs in the compiler or language, of course :)

      More importantly, you have to wonder at the wisdom of myfunc returning these incompatible types in the first place -- what is so complex about myfunc that it can't return something predictable? Is this something which could be helped by simplifying the design?

      The compiler cannot assume a sane design :) Besides, it's a complex world, and sometimes you will need a complex design to solve the issue at hand. You yourself mention using evals at times, something which might return *anything*.

      Like looking up in a hash table, but accidentially using a converted form (say, to string) of the key instead of the intended key.

      I honestly cannot ever remember doing that. Not once.

      Of all the problems I have debugged in Java, that and comparing strings with == is the most common in both my code and in other peoples code. If you have not seen it yet, count yourself lucky, it can be very hard to spot :)

      Well, I find explicit typing to be that much more clutter. I don't need pre and postcondition checks everywhere.

      Many people would say they don't need unit test everywhere :p I do get that you don't want to specify types, and that is fine by me. It still means that ruby is not the perfect language for me.

      There is a keyword for handling that case. mutable, if you want to check up on it.

      I'll have to let that digest for a bit. My initial reaction is that this is still less flexible -- I realize that's on purpose, of course.

      I have used it for years, and I'm pretty sure you can do anything you want with it, while still preventing lots of errors. Besides, it allows you to specify intent in a very clear way --- the ! sometimes means constant, but sometimes it is more like "watch out, dangerous function".

      But one thing I love about accessors in the first place is the ability to shift the implementation around underneath of whatever's using it. I'm not sure mutable covers everything I might want to do with a former accessor.

      It covers all instances of accessors I have ever seen. It does not cover everything people write as accessors, but is really something else, of course.

      Now, it wasn't x86, and again, I can't find the article. (Probably some flavor of RISC?) But I think that, if anything, proves that VMs could be written which would beat native code, current implementations notwithstanding.

      When those magic VMs comes, my hypothetical language will merely change the output target to compile to the VM rather than to bare iron. That is my point.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    8. Re:Ruby? by SanityInAnarchy · · Score: 1

      It is, however, not possible for a VM to predict future calls either, and anyway, the VM would then have to waste clockcycles during every run, instead of having it calculated once and for all.

      I'd say that gathering statistics of what's actually being done is probably a strong enough indicator of future calls. Consider the following:

      source = 'some really long string of source code, possibly generated'
      eval source

      Will the code be compiled every time? I'd argue that a reasonably intelligent VM might notice that the source string isn't changing, and cache the result of that call. And if it's a sufficiently long string, it absolutely would be a net win in efficiency, even including VM overhead.

      You can't. That's the point about type-safety, it's a strong garantee. The code might fail, but it will be during compiletime. Barring bugs in the compiler or language, of course :)

      Or logical bugs in your type system design. Certainly, anywhere you typecast can fail at runtime.

      It catches a lot of errors at compiletime, yes. But not all; that's what tests are for.

      The compiler cannot assume a sane design :)

      No, but it should optimize for a sane design, right?

      Or we can say that COBOL optimizes for an insane design. I don't want to write that!

      Besides, it's a complex world, and sometimes you will need a complex design to solve the issue at hand.

      Which is why you break it into simple chunks.

      You yourself mention using evals at times, something which might return *anything*.

      The most appropriate time to use eval, I think, is early in the program -- during what would be the "preprocessing" stage in other languages. For instance, Rails has a "constantize" function which takes a string and returns the constant with that name -- and it uses eval to do so. But this is rarely done after program startup -- it's mostly used so that your source code can contain such strings, and so that the Rails environment can do things like read a file name "foo.rb", and do string manipulations (capitalize it to Foo), then look for a constant by that name.

      Many people would say they don't need unit test everywhere :p I do get that you don't want to specify types, and that is fine by me. It still means that ruby is not the perfect language for me.

      There are other reasons why I don't consider it the perfect language. Even syntactical reasons.

      And I think I could make a strong argument for unit tests everywhere -- again, I see a type check as just another form of unit test. But tests in general make it that much easier to make larger changes -- because after making the change, you can just run the test to see if it worked.

      There's even test-driven design, but that takes discipline.

      Besides, it allows you to specify intent in a very clear way --- the ! sometimes means constant, but sometimes it is more like "watch out, dangerous function".

      Well, it actually means "non-constant", but yes, I've seen it abused that way. One thing I've seen it overloaded to is raising errors instead of returning them, but I'd usually rather raise errors by default.

      Example: Calling foo.save! in Rails will throw exceptions on validation errors, but what is the point of foo.save, which simply returns true or false depending on whether it was successful? If I just want to see if the object is valid, I can call .valid?

      I do get what you mean now about expressing intent, and why that's important -- and I think that's what a high-level language is about. I'm also considering subverting it into an argument against explicit typing -- I don't intend for something to be any given type, I only intend for it

      --
      Don't thank God, thank a doctor!
    9. Re:Ruby? by EsbenMoseHansen · · Score: 1

      I'd say that gathering statistics of what's actually being done is probably a strong enough indicator of future calls. Consider the following:

      source = 'some really long string of source code, possibly generated' eval source

      Will the code be compiled every time? I'd argue that a reasonably intelligent VM might notice that the source string isn't changing, and cache the result of that call. And if it's a sufficiently long string, it absolutely would be a net win in efficiency, even including VM overhead.

      No VM is needed for that. Any decent implementation of eval will check the input string against a cache. Branch prediction is another example of what you are talking of, and again, no VM is required. I can see where VMs theoretically can give a small boost to performance in some cases, but so far I've not seen a VM that performs better than 50% of bare iron.

      The compiler cannot assume a sane design :)

      No, but it should optimize for a sane design, right?

      Of course, but that doesn't help it if it trying to detect errors at the compile time. You cannot have false positives here.

      Many people would say they don't need unit test everywhere :p I do get that you don't want to specify types, and that is fine by me. It still means that ruby is not the perfect language for me.

      There are other reasons why I don't consider it the perfect language. Even syntactical reasons.

      Anything specific?

      And I think I could make a strong argument for unit tests everywhere -- again, I see a type check as just another form of unit test. But tests in general make it that much easier to make larger changes -- because after making the change, you can just run the test to see if it worked.

      I agree -- to a point. At some point, the code is either too trivial to test or requires too much scaffolding to test.

      There's even test-driven design, but that takes discipline.

      I know, I use it extensively for writing parsers and such. It's excellent when you have some good testcases up front. Unfortunately, in my line of work, we often have to make up the test data as we go along, and anyway, the problem we set out to solve is seldom the problem that turns out to be solvable.

      Besides, it allows you to specify intent in a very clear way --- the ! sometimes means constant, but sometimes it is more like "watch out, dangerous function".

      Well, it actually means "non-constant", but yes,

      Woops, you are correct, of course.

      I've seen it abused that way.

      To be fair, const can be misused with a bit of effort as well. But the thing is, people usually agree on what const means, while ! means sort of dangerous to some, destructive to others and apparently constant to a third group. Besides, string concatenation is no way to store information :/

      Example: Calling foo.save! in Rails will throw exceptions on validation errors, but what is the point of foo.save, which simply returns true or false depending on whether it was successful? If I just want to see if the object is valid, I can call .valid?

      Totally agree. Silly design, really. Not really the language's fault, though.

      I do get what you mean now about expressing intent, and why that's important -- and I think that's what a high-level language is about. I'm also considering subverting it into an argument against explicit typing -- I don't intend for something to be any given type, I only intend for it to be able to do a certain thing.

      I worry that you have misunderstood me. It's the compiletime checki

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    10. Re:Ruby? by SanityInAnarchy · · Score: 1

      No VM is needed for that. Any decent implementation of eval will check the input string against a cache. Branch prediction is another example of what you are talking of, and again, no VM is required.

      And also garbage collection, and other things.

      I suppose the proper word is "runtime", because I do believe there are optimizations which can only be done effectively at runtime.

      Anything specific?

      Probably the biggest thing that bothers me right now is the fact that any sufficiently complex file is going to end like this:

      end
      end
      end
      end
      end

      That's something I can get around with a preprocessor, though, and people have -- basically, to make Ruby behave like Python. But that's a minor irritation anyway -- I type fast, and it has the advantage of having most editors understand C-like syntax (and be able to jump from start to end tags and back).

      There's also the lambda/block syntax -- it's very good for when you only need to pass a single block, but I do wish it was easier to pass a pair or more.

      And there's the fact that unlike JavaScript, methods are very much stuck to a class. It's something a lot of people seem to hate about it, but I loved -- I can rip a function out of anywhere, any class, any object, and apply it to something completely different. I can assemble a class not only from modules explicitly specified as such, or from direct inheritance from multiple other classes, but from, well, anywhere I want. I can completely make up my own class system.

      Most of that is available through things like Object.extend in Ruby, but that's not as easy to build classes with, and is complicated by the difference between "extend" and "include".

      I suspect that the main things I prefer about Javascript (instead of Ruby) is that Javascript is prototype-based, whereas Ruby is traditional class inheritance with mixins. It seems to me that a prototype system is a simpler set of primitives than a class system, even if it might be possible to build one from the other.

      I agree -- to a point. At some point, the code is either too trivial to test or requires too much scaffolding to test.

      I find that I mostly get into the latter situation out of my own lack of discipline. But at the same time, there's a lot of scaffolding out there -- there are browser-based unit tests for webapps.

      Unfortunately, in my line of work, we often have to make up the test data as we go along, and anyway, the problem we set out to solve is seldom the problem that turns out to be solvable.

      True. That makes for more test-driven development, rather than test-driven design. I know that certain projects won't accept patches unless they include tests, no matter which came first.

      But the thing is, people usually agree on what const means, while ! means sort of dangerous to some, destructive to others and apparently constant to a third group. Besides, string concatenation is no way to store information :/

      I'd agree that it's bad that it gets abused. But I'm beginning to appreciate naming conventions -- even when enforced in code -- like how a Constant in Ruby is anything Capitalized -- although perl $scalars, @arrays, and %hashes got annoying, especially when the scalars were more often a reference to a more complex type.

      Totally agree. Silly design, really. Not really the language's fault, though.

      Right, although it does stress the need for code conventions in any sufficiently flexible syntax.

      I worry that you have misunderstood me. It's the compiletime checking that interest me, not that you have to put types everywhere.

      I probably have. However, most implementations of compiletime checking do end up being verbose...

      --
      Don't thank God, thank a doctor!
    11. Re:Ruby? by EsbenMoseHansen · · Score: 1

      No VM is needed for that. Any decent implementation of eval will check the input string against a cache. Branch prediction is another example of what you are talking of, and again, no VM is required.

      And also garbage collection, and other things.

      Garbage collection is on the verge of being included in C++. So it must be possible to do without a VM. (Personally, I think garbage collection is only good for covering up bad design, but let's do that another time --- but anyway, that's my excuse for only knowing the big picture as garbage collection goes. )

      I suppose the proper word is "runtime", because I do believe there are optimizations which can only be done effectively at runtime.

      So you claim :) I disagree, though. Or at least, it seems to me that the penalty for those optimizations outweights the benefits. Also, for security reasons, I prefer the executable part of an application to be in a non-writable segment.

      Anything specific?

      Probably the biggest thing that bothers me right now is the fact that any sufficiently complex file is going to end like this:

      end end end end end

      That's something I can get around with a preprocessor, though, and people have -- basically, to make Ruby behave like Python. But that's a minor irritation anyway -- I type fast, and it has the advantage of having most editors understand C-like syntax (and be able to jump from start to end tags and back).

      Hm. I would prefer having endmethod, endclass and so on, but otherwise I'm find with something like this. Python style blocks I never liked.

      There's also the lambda/block syntax -- it's very good for when you only need to pass a single block, but I do wish it was easier to pass a pair or more.

      I always assumed I just didn't get how to do this simply :o)

      And there's the fact that unlike JavaScript, methods are very much stuck to a class. It's something a lot of people seem to hate about it, but I loved -- I can rip a function out of anywhere, any class, any object, and apply it to something completely different. I can assemble a class not only from modules explicitly specified as such, or from direct inheritance from multiple other classes, but from, well, anywhere I want. I can completely make up my own class system.

      Most of that is available through things like Object.extend in Ruby, but that's not as easy to build classes with, and is complicated by the difference between "extend" and "include".

      I would imagine it would also make your code hard to read or understand.

      I suspect that the main things I prefer about Javascript (instead of Ruby) is that Javascript is prototype-based, whereas Ruby is traditional class inheritance with mixins. It seems to me that a prototype system is a simpler set of primitives than a class system, even if it might be possible to build one from the other.

      That is an old battle. On the balance, I prefer the class system, again because I find it easier to express my intent clearly. Not a huge deal for me either way, though.

      I agree -- to a point. At some point, the code is either too trivial to test or requires too much scaffolding to test.

      I find that I mostly get into the latter situation out of my own lack of discipline. But at the same time, there's a lot of scaffolding out there -- there are browser-based unit tests for webapps.

      Webapps are easy for many reasons. Make sure that a method that is supposed to tighten a linear constraint in a linear system is worse. Sure, you can make a test for the simple cases, but most of the code is about stuff like numerical instability. Scaffolding stuff lik

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    12. Re:Ruby? by SanityInAnarchy · · Score: 1

      Personally, I think garbage collection is only good for covering up bad design, but let's do that another time

      Very briefly, I think garbage collection is one of those things which can be faster on average. But yes, it is doable without a VM, and there are libraries to do so.

      Also, for security reasons, I prefer the executable part of an application to be in a non-writable segment.

      I think it's possible to lock down a VM much tighter than simply locking the executable part of an application.

      I always assumed I just didn't get how to do this simply :o)

      Well, the trick is, every method can have a "block" -- exactly one. It is possible to map this to an argument (a Proc object), which is slower, but it lets you pass it to other methods, store it in a data structure, and so on.

      It is also possible to simply pass Proc objects around anyway. This is the more Javascript-like approach:

      def twofuncs(first, second); first.call; second.call; end
      twofuncs lambda{puts 'first callback'}, lambda{puts 'second callback'}
      # sorry, lameness filter wants me to have more characters per line.

      Although the more syntactically elegant thing to do here is probably to create an object:

      class TwoFuncs; def setFirst(&block); @first = block; end
      def setSecond(&block); @second = block; end
      def callBoth; @first.call; @second.call; end; end

      obj = TwoFuncs.new; obj.setFirst { puts 'first callback' }
      obj.setSecond { puts 'second callback' }; obj.callBoth

      The problem I have with it is that blocks, while they can be treated as Proc objects, are really subtly different -- most visibly syntactically, but also in implementation. For instance,

      def callTheBlock; yield; end

      is more efficient than

      def callTheProc(&block); block.call; end

      Even though both of them are called exactly the same way.

      I would imagine it would also make your code hard to read or understand.

      No more than any other DSL-ish trick. That is: Being effectively a dialect means that you can't just go pick up some random blogger's JavaScript tutorial and expect to understand what I'm doing -- but it also means that once you get it (especially if I have decent variables and function names), it's probably easier to read.

      Especially if it's good at expressing intent. I like that concept, thanks!

      And I'm the second-most unit test fanatic in our office :o)

      Something for your coworkers...

      (As an aside, perl's is really a type system in the variable names, which is something else again).

      Well, except it's limited to the primitives, as is Ruby's. And Perl's is much less useful, as after awhile, just about everything's going to be a scalar reference to something.

      Yes, but some, like C++, seems to be trivially convertible to a simpler syntax.

      Looks like you're right... except, of course, it would now generate exactly the same kind of errors that a similar method in Ruby would. The only difference is, as you say, yours catches them at compiletime -- which means a lot more must be known at compiletime.

      Eval could be encapsulated so that type errors in that case would be found at runtime. (Nearly) every eval is a failure of the language anyway.

      I would consider eval to essentially be a shortcut for certain kinds of reflection.

      Of course, this is all about duck typing. (If you mean the quacks and walks like a duck.) C++ has had duck typi

      --
      Don't thank God, thank a doctor!
  77. Re:I'm just glad they're teaching C++ actively aga by orlanz · · Score: 1

    That's a very good move. Our Institute in the ATL did the same a few years ago. It is a good path to take. I feel Java (intro to OOP) & Python (intro to prog)are excellent introductory languages that ease newbies into building a pretty good solid starting foundation to programming. And I think the 1st intro is required for everyone irrelevant of their major, and the second is recommended.

    I don't think a language or tool should ever be taught (if you must, leave that to post college overly expensive "seminars" and "workshops"), but the concepts behind their field should be embedded into students. The students should come out with a knowledge base and a thought process that can be used to gain specific insight into any language or tool on their own.

    Of course, over here, once you get past the intros, the weed out classes start up with C, C++, assembly, and whatever the professor's flavor of the quarter is (sometimes, its left up to you)!! And although I feel for the students who need to go through this gauntlet; I can't think of a better way to do it.

  78. Re:Education, even at Universities, needs to Impro by Anonymous+Brave+Guy · · Score: 1

    I studied CS in academia and worked in industry for a while, and I don't know what the "white book" is either. I guess I'd better give up and become a lawyer. :-(

    Or, just maybe, CS education is about more than name dropping...

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  79. Re:I'm just glad they're teaching C++ actively aga by R.Mo_Robert · · Score: 1

    For simple projects (or even complex, if you're a masochist), you can compile at the command line using javac. No need to fire up an IDE or make a build file.

    --
    R.Mo
  80. Re:I'm just glad they're teaching C++ actively aga by SerpentMage · · Score: 1

    I wish I had mod points here. So many people get this wrong. Computer Science != Computer Engineering. I studied engineering and we build things to get things done. In Science you don't necessarily want to get things done, but want to understand why things get done and how they get done.

    I always use the example of LaPlace transforms. Engineers devised them and used them to solve problems. The scientists at a later point in time figured out why they work.

    Though I do take issue with the code monkey aspect because in essence that is what an engineer is. Nothing wrong with being a code monkey, though I don't think I would get a code monkey to devise a new relational database model.

    --

    "You can't make a race horse of a pig"
    "No," said Samuel, "but you can make very fast pig"
  81. Re:I'm just glad they're teaching C++ actively aga by gplus · · Score: 1

    Yeah but if we don't start coding in C# the theorists win!

  82. Give it up Bjarne by betelgeuse68 · · Score: 3, Interesting

    I spent 2-1/2 years at MS and if it is one thing that disappointed me it is how indifferent most developers were about learning C++... which prevented them from writing great code. Afterwards, I worked with some *NIX snobs in a dotBomb and all they ever did was trash C++ (somehow Java was "great" though).

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

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

    Sayonara C++,
    -M

    PS: C++ has become niche Bjarne.

    1. Re:Give it up Bjarne by Anonymous Coward · · Score: 0

      C++ completely failed to supplant C as a systems language and even application development is moving on. Talented engineers look at C++ and see a poorly designed language. For these guys, wanting to ship great code and being forced to work in C++ are mutually exclusive. Why bother? Then there's code monkeys who don't care to understand anything apart from easy bananas.

      C++ created far more problems than it ever solved, I certainly won't be lamenting it's passing.

    2. Re:Give it up Bjarne by betelgeuse68 · · Score: 1

      I'm with Joel Spolsky... most software developers are mediocre... except they don't know it. But then mediocre is contextual. If your only motivation is to collect a paycheck on account of filling in event handlers with business logic, hey, more power to you. But that's not what shall we say drew me to CS.

      I interviewed many people who said they knew C, some of these people had had jobs and were not fresh out of college, I was pretty shocked to find few could write "strcpy". It was an eye opening experience for me - all I ever wanted to know was if a person understood pointers. To heck with the prototype and boundary checking, show me pointers.

      I don't buy many people's arguments against C++. Many arguments were made for Java when it came along but then the language expanded to make up for the fact that, well, people did utilize some of the things C++ offered.

      It's easy to bash C++ now that there really isn't a strong business case for it, computers have grown so powerful the need to work at that level has been greatly diminished. If I'm a hiring manager I have to weigh in the fact that the code has to be maintained and as attrition happens, I have to replace people and C++ doesn't exactly have the mindshare it once did. Not to mention that few CS graduates have any experience with it.

      The only bastions left for C++ are commercial products and trading applications, like I told Bjarne - niche.

      -M

      PS:

      while( *dst++ == *src++ );

    3. Re:Give it up Bjarne by Sweetshark · · Score: 2, Interesting

      Few could tell you why you necessarily want to make your destructors virtual, why not doing "delete [] array" is not necessarily a memory leak, where must references be initialized, why it's good practice to use (at the time) the new cast notation... the list went on. This exactly highlights the problem of C++:
      Either you are doing low-level system programming in which case C++'s OOP abstractions wont help you anyway.
      Or you are doing high-level coding in which case C++ doesnt help you because its abstractions are so leaky, they arent making stuff easier but unfortunately even more complex (manual management of virtual/nonvirtuals, memory/resource management, etc.).

      C++ always was a kludge, its only raison d'etre was that many other languages weren't there yet and others made the migration for C coders too uncomfortable.
      In Hindsight, its a shame that Objective-C didnt play the role C++ did, for example.
    4. Re:Give it up Bjarne by Shados · · Score: 1

      I interviewed many people who said they knew C, some of these people had had jobs and were not fresh out of college, I was pretty shocked to find few could write "strcpy".
      Honestly, thats almost like asking a particle physics theorist to do a division with large numbers with a pen and paper. They could do it, but its been so freagin long (decades!) that they had to, that they completly forgot. Too busy trying to solve problems that haven't been solved in their own field. Case in point: My girlfriend (yes yes, I have one) is a software engineer for a company that makes a backoffice dynamic data engine for e-commerce and/or data mining applications. She works pretty close to the bare metal, because they advertise that software as being able to run very complex queries on douzans or hundreds of gigs in a couple of seconds (its used on web pages, so it has to be fast). Very CS-y, and all, she can juggle with C++ and pointers like no one.

      On my side, I'm a software developer and architect for corporate applications and ERP systems, though right now I'm working on portfolio management systems for financial companies and banks. The only time since 1995 that I've played with low level stuff is when generating bytecode dynamically to add dynamically typed language-style features (like duck typing) to C# or Java (and even then, its just patching assembly-style codes together, not much CS stuff there, though its a challenge in its own right). Structuring applications to be able to change at a customer's whim, cutting edge software architecture methodologies, trying to integrate disparate environments together... While I used to be quite good at C++ with all of its subtleties, I moved on, and while I can still read it and debug it, I'd be hard pressed to write a full application with it or do my girlfriend's job. In the same way, she'd never dream about doing mine.

      What I'm saying is that the world of programming is a lot wider than it was 20 years ago... and its still about solving unsolved problems. Part of these unsolved problems are of the same category as they were in the beginning. That keeps people like you and my girlfriend happy... But there's a whole new world out there, with a lot of new challenges and problems to solve... The pointer arithmetics have been replaced by software design patterns, the memory management has been replaced by SOA, and the problem with managing strings across 3rd party librairies have been replaced with trying to get the difference web service stacks to talk to each other nicely :)
    5. Re:Give it up Bjarne by Anonymous Coward · · Score: 0

      I interviewed many people who said they knew C, some of these people had had jobs and were not fresh out of college, I was pretty shocked to find few could write "strcpy".

      Honestly, thats almost like asking a particle physics theorist to do a division with large numbers with a pen and paper.



      int strcpy(char * dst, const char * src) {
          int i;
          for (i = 0; src[i] != 0; i++) {
              dst[i] = src[i];
          }
          return dst;
      }


      (snarky) Yeah, that's just like dividing 93248547643540943 by 32324 by hand.

      Seriously, strcpy() is one of the easiest "do you really know what you're doing" kind of tests there is.

    6. Re:Give it up Bjarne by tknd · · Score: 1

      while( *dst++ == *src++ );

      Syntax mistake? I haven't written C/C++ for almost a decade but the == operator is still the equivalence operator so all you are doing is comparing two portions of memory from (possibly) different starting points. If dst and src are equivalent (the same pointer) you could potentially run forever.

      Perhaps this is what you wanted? (strcpy)

      while( *dst++ = *src++ );

      The src is copied into dst until a 0 (null character) is encountered (after the assignment operation).

    7. Re:Give it up Bjarne by Anonymous Coward · · Score: 0

      while( *dst++ = *src++ );

      There, fixed it for yah!

    8. Re:Give it up Bjarne by betelgeuse68 · · Score: 1

      What AnonCoward said. Writing strcpy is basic.

      Programming may be a lot wider now but that doesn't excuse anyone from not knowing pointers if such a person claims to know C. It would be like me saying I can play music without ever having played any instrument. It makes no sense.

      -M

  83. Re:I'm just glad they're teaching C++ actively aga by tomz16 · · Score: 1

    The thing is that Java is extraordinarily similar to C++. If you are a competent C++ programmer, you can learn Java in an afternoon (or less). If you are a competent Java programmer, it will take you a little bit longer to learn C++. At least a few days by my estimation.

    In fact, when I was an undergrad, our CS department transitioned from C++ to Java. I did about 30 minutes of reading on the internet, and was up and running in java. There was a document called something like java for C++ programmers, which had a list of about 20 language differences that you needed to be aware of. The rest was just poking around in the java SDK documentation to figure out the standard classes that ship with java.

    Despite this relatively easy transition between java/c++, I am still a HUGE advocate of teaching C++ (and perhaps even a separate class specifically on C). It's hands down the most versatile language out there for most things, and a HUGE stepping stone in easily learning any other practical language. In fact, I see no real advantage in teaching Java over C++.

    I do a lot of development in python, bash, php, and matlab, but still see C++ code on a monthly basis. In my field it's particularly useful for interfacing with hardware. My colleagues without a similar C++ background (but who are very competent programmers in other languages) just throw up their hands at the first sign of C++.

  84. Why I quit using C++ by SerpentMage · · Score: 2, Interesting

    I look at your example and think, Huh? I used to code C++ (about 4 years ago) and since then shifted completely to C# and Java. And if I need some low level code I will write it in C.

    I talked to another individual about C++ and what he hates with C++ is that you are taking too much time thinking about infrastructure and not solving problems. Whereas in Java you think more about solving problems and less about infrastructure.

    --

    "You can't make a race horse of a pig"
    "No," said Samuel, "but you can make very fast pig"
    1. Re:Why I quit using C++ by pherthyl · · Score: 1, Insightful

      That example is complete bogus. Sure you can write some horrible code in C++, but I write C++ code for a living, and it's at least as clean as any Java or C#. You just need to use the right libraries. Qt provides a class library at least as good as those shipped with C# and Java, and you don't get any of the disadvantages of a virtual machine, with most of the advantages.

    2. Re:Why I quit using C++ by Anonymous Coward · · Score: 0

      It's hard to avoid C++, user interface really works well with it. There arent many "good" UI toolit that doesnt requires C++.

      Is it just me? I cant help thinking I was translating Latin into English while programming in C++ (English is my second language!). The other day I was trying to solve compile problem with vector of objects and I keep hitting the wall. Eventually I solved it, but it really waste a lot of time. The language should let me concentrating on the problem instead of the language itself, but with C++ it just not going to happen.

    3. Re:Why I quit using C++ by shutdown+-p+now · · Score: 1
      The point of the example was not to demonstrate the inadequacy of the C++ standard library (although that's there, too). Its point was to demonstrate a fundamental quirk of the language, namely, the implicit silent signed->unsigned coversion that happens in any arithmetic operator with mixed arguments. Qt won't help here. Well, it will help somewhat, since at least the size() method for its containers returns signed int, so the chances of mix-up are reduced. Even so, some of that stuff is in the core language - e.g. sizeof() returns unsigned, no matter what.

      Also, you often can't write the entire application using Qt only. That's the beauty of C++ - that it has a lot of code already written in it (note that 99% of all C code also counts) that can be immediately reused. But of course, you can't expect it all to use Qt, or even to adhere to the same guidelines.

    4. Re:Why I quit using C++ by pherthyl · · Score: 1

      >> Also, you often can't write the entire application using Qt only. That's the beauty of C++ - that it has a lot of code already written in it (note that 99% of all C code also counts) that can be immediately reused.

      True. Although in my experience (having written ~100kloc of C++/Qt code), Qt covers 95% of what I need. The only time I really need to stray outside is if I particular system integration needs, which might require some WinAPI (MSAA parsing for example). The only other major library I use on a regular basis is OpenCV, since I do a lot of image processing work.

  85. Sad... by SerpentMage · · Score: 1

    You are labeled a troll, but you are talking straight talk here.

    For example your garbage collection comment. I think it is only C++ and C that don't have garbage collection. Yet in Python, Perl, Ruby, Java, C#, etc, etc there is garbage collection. For crying out loud even D has garbage collection. This tells me that maybe C++ is missing the point.

    I would prefer more people learn about C in combination with C# or Java.

    --

    "You can't make a race horse of a pig"
    "No," said Samuel, "but you can make very fast pig"
    1. Re:Sad... by Zeinfeld · · Score: 2, Insightful
      The GC point is very simple. My experience is that less than 5% of C++ programmers can write code that does not have memory leaks and buffer overruns. So even though I can write code that I memory leak free, I typically have to rewrite other people's code written in C or at the very least spend time working out if they have a clue or not. With Java I can at least know that they will not deplete resources.

      And anyone who is saying 'learn to use the leak detection tool', testing programs for correctness is a total lose. You can never test every state of anything but the simplest programs. A good GC will guarantee that there are no memory leaks without needing to test. Better code safety and better performance as well, memory leaks are the most common cause of performance problems that I see.

      --
      Looking for an Information Security student project suggestion?
      Try http://dotcrimeManifesto.com/
    2. Re:Sad... by maxwell+demon · · Score: 1

      With Java I can at least know that they will not deplete resources.

      You can't.
      --
      The Tao of math: The numbers you can count are not the real numbers.
    3. Re:Sad... by Anonymous Coward · · Score: 0

      Unfortunately people actually think in these terms without stopping to concider how shallow and fundementally wrong it really is. Unless your code is unimportant and does not communicate with the outside world automatically freeing memory is the *least* of your resource management concerns. Most memory problems can be systemtically discovered or detected with a number of avaliable profiling and anyalysis tools.

      Not cleaning up memory is of no consequence compared to the chaos that would ensue from extending "I shouldn't have to care" to proper handling of events/synchronization objects, network connections or distributed transactions.

      Who cares if a few bytes get cought on the bad side of some GC reachability graph or their cleanup is delayed for a few minutes?

      Take the same scenario except replace memory (virtually free) with a resource that is actually precious and very important such as an open transaction handle and see where that leads you.

      I would rather have our people design systems that account for everything by design putting a handful of simple patterns into action ensuring small probobility of screwups that have a good chance of being detected.

      The alternative -- having people treat resource management as a second class citizen or even something beneath them (Java exception handling depends on GC to clean up the mess their dressed up GOTO statements cause). Maybe *YOU* can afford that. Our customers can't.

    4. Re:Sad... by Zeinfeld · · Score: 1
      People have a limited number of issues they can to attend to at once. If people are attending to memory leaks they are much less likely to get everything else right.

      Memory leaks will eventually kill any program if it runs long enough. My experience is that people still make goofs when they use profiling tools.

      If we are going to play 'people should learn' then why not use assembler or better machine code like real programmers do?

      --
      Looking for an Information Security student project suggestion?
      Try http://dotcrimeManifesto.com/
    5. Re:Sad... by metamatic · · Score: 1

      The cited article uses the term "memory leak" incorrectly.

      The example given is a UI element instantiated by class B, that class A retains a reference to, causing the UI element to remain in memory even after class A reaches a point where it will never again display that piece of UI.

      That is *not* a memory leak. It's merely failing to release memory as soon as it could be released. Unfortunately, some people call any sub-optimal use of memory a "leak", even if it isn't. Firefox keeps 10 pages cached in memory for a while even after you've closed their tabs? OMG MEMORY LEAK!

      --
      GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
    6. Re:Sad... by soliptic · · Score: 1
      (Emphasis mine)

      My experience is that less than 5% of C++ programmers can write code that does not have memory leaks and buffer overruns. So even though I can write code that [is] memory leak free...

      I don't mean to pick on you personally, since I obviously don't know you from Adam, but...

      It must be said, EVERY. SINGLE. TIME. C / C++ vs Java etc, pointers / manual MM vs GC comes up on slashdot, I see comments like this. "The problem is that the vast majority of C developers are crap, present company excepted of course..."

      I can't help feeling this is ... uh ... telling. Everybody thinks they're A-OK, and the problem is with everybody else. 5% can do perfect code, 95% can't?

      :shrug: well I never even got hello world to compile in C, so what do I know, but I can't help suspecting these numbers are more illuminating about issues of self-perception than issues of actual error rate...

    7. Re:Sad... by Da+Fokka · · Score: 1

      That's an interesting approach... Arguing something is NOT a memory leak by comparing it to FireFox.

      But seriously, the behaviour described in the article is a memory leak during program operation. Although the resources might be released when the program exits, before that point memory can be exhausted by this behaviour. This *is* a valid critique of the notion that GCs never leak memory. GCs basically abstract away resource management. For many scenarios this is perfectly acceptable behaviour and a great way to avoid bugs. But this convenience comes at a price. In some cases it is unwise to rely on the garbage collector to manage resources. Frankly, I think the C#/Java/C++/C and GC wars are pointless (although they are fun). It's important to understand the advantages and limitations to each of the technologies and make an informed decision based on tkat knowledge.

  86. C is the assembly language of today. by SanityInAnarchy · · Score: 1

    The problem with C++ is that this "purely structural thing" is so complex that no one person can hold it in their head. There are entirely too many surprises, bits of unnecessary complexity...

    C has a performance-oriented level of interaction with the machine. It has some basic, primitive concepts, on top of which you can build an object-oriented program if you want, but you don't need C++ to do so. Just about any reason I can think of for using C++ is better served by some other language, and the performance/low-level considerations are best served by C, at least for now.

    If you're working on a large enough program that you really need OOP baked into the language, there are other options than C++, most of them better. A favorite combination now seems to be a high-level, dynamic language like Ruby, Python, or Perl, with mechanisms to make it easy to extend in C.

    --
    Don't thank God, thank a doctor!
  87. Re:I'm just glad they're teaching C++ actively aga by vtcodger · · Score: 1
    ***on the application level, Java is the biggest, most succesful language ever***

    Surely, that title belongs to COBOL. Maybe Java wins in the the "Biggest, most successful, unreadable language" subcatagory. I'm not a COBOL programmer BTW. I'm not even sure that the term "Cobol Programmer" isn't an oxymoron as most of the "Cobol Programmers" I met back in the decades when it dominated the business world struck me as being somewhat on the not real swift side of confused.

    I lack the patience to program in COBOL, but the couple of times I've needed to dig into a COBOL program to figure out what it was doing, I found it to be orders of magnitude more comprehensible than C, C++ or Java.

    Seriously, I think the write-only nature of modern languages is a huge contributor to the dubious quality of software. Trying to scale programming languages that lead to baffling code at the toy/small program level to huge systems works about as well as one might expect -- Poorly. Frankly, I see virtually no progress on the big system side since the first non-assembler big systems I saw 40+ years ago written in Fortran and Jovial. In fact, some parts of OSS programs I've looked at written in C++ look to be a decided step backwards.

    So I'm an old foggy who is stuck in the past? Perhaps. Probably even. But I do see significant progress in some areas. List programming is a step forward although I'm not that good at it. Same with Object Orientation. Perl is a vastly better tool for quick and dirty little programs than anything we had in the 1960s. Python is even better. I expect there are even better languages for many jobs.

    But if you ask me, C sucks at least at many of the jobs it is being used for. Bad with object orientation pasted on is lipstick on a pig. It's still a pig and it's still bad. (I'd have thought that C might be OK for some simple embedded programming -- especially if the alternative is Intel's abominable assembly language. But embedded programmers have told me otherwise. Easier to code, but performance is deficient.)

    I'll finish this rant with a quote from the Appendix B to the Unix Hater's Handbook (I use Slackware 12.0 BTW. It has it's moments, but for the most part I'm a Linux fan).

    ... we quickly added additional cryptic features and evolved into B, BCPL, and finally C. We stopped when we got a clean compile on the following syntax:

    for(;P("\n"),R=;P("|"))for(e=C;e=P("_"+(*u++/ 8)%2))P("|"+(*u/4)%2);

    To think that modern programmers would try to use a language that allowed such a statement was beyond our comprehension! We actually thought of selling this to the Soviets to set their computer science progress back 20 or more years. ... http://www.simson.net/ref/ugh.pdf

    That's parody of course. But good parody is usually built on a kernel of truth.

    --
    You can't see ANYTHING from a car, You've got to get out of the goddamned contraption and walk...Edward Abbey
  88. OBJECT PASCAL by JernejL · · Score: 1

    And this is what object pascal actually did right, it delivered the power of c++ without the weird syntax of c++, and all pascal code can be easily understood by anyone.

  89. Re:Education, even at Universities, needs to Impro by mollymoo · · Score: 1

    According to Wikipedia (well, the redirect for "the white book") it's a synonym for K&R. I didn't know what it was, despite owning it.

    --
    Chernobyl 'not a wildlife haven' - BBC News
  90. Re:I'm just glad they're teaching C++ actively aga by kisielk · · Score: 2, Funny

    Really? I always thought the Laplace transform was invented by.. well.. Laplace? I'm pretty sure he was a mathematician, along with Euler, Fourier, and friends.

  91. best Stroustrup sentence ever was... by Anonymous Coward · · Score: 0

    C++ programmers do indeed need education, as do Java programmers. Best Stroustrup sentence, that sums most of what is wrong with today 'OOP programmers' (Stroustrup is right of course in case I'm not clear), is how, when you are doing OOP, implementation is a detail:

    I have consistently pointed out that one of the major ways of writing classes in C++ is without any state, that is, just an interface.

    And note that in Java you can greatly simply development by getting rid of abstract classes and both the 'abstract' and 'protected' keywords (in Java the equivalent of a C++ 'pure abstract classes' is an 'interface').

    However I don't expect 3GL languages programmers and 'OO' programmers using 3GL languages to understand any time soon why this is a Good Thing (TM).

    Using interfaces [aka C++ 'pure abstract classes' as Stroustrup calls them] is the only way to do clean OOA -> OOD -> OOP.

    Remember kids, implementation is a detail in the grand scheme of OO. And, no, "code reuse - oh my god it's too hard and to verbose to use composition and delegation" is not an excuse. Implementation is a detail. Get over it.

    Interview of Stroustrup on the subject at Artima by Bill Venners for anyone wanting to find enlightenment. It's from 2003 already and I don't expect people to understand that before another two decades or so, just as I don't expect people 'teaching Java' to realize that James Gosling screwed up big times by allowing the 'abstract' and 'protected' keywords in Java (btw you can find an interview from Java's "father" on Artima too, where he says he regrets not having gone the 'pure interface' way).

    Listen to language creators kids, both Stroustrup and Gosling agree on this one: interfaces / 'pure abstract classes' are a Good Thing (TM). That is the single most important point educated C++ and Java programmers should know about.

  92. Is it because it is just a language? by dwarfking · · Score: 4, Interesting

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

    More complete environments.

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

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

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

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

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

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

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

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

    1. Re:Is it because it is just a language? by master_p · · Score: 1

      The C++ standards committee can not agree on a GUI model, that's why they abandoned it (the excuse was that half of the people wanted a Model-View-Controller framework, the other half a simple callback-driven framework).

      Furthermore, according to them, who needs a GUI library for C++? no one. C++ is a systems programming language, get it? (despite the fact that it's not used anywhere as a systems programming language)...

      [/sarcasm]

    2. Re:Is it because it is just a language? by Frenchy_2001 · · Score: 1

      You know, you are making a good point, but I can't prevent myself from drawing a parallel between those programming languages and some operating systems.
      C++ is a raw programming language with LOTS of library available. You can find some library to do anything, different library will run on different platform and compete for different functions.
      Compare that to Linux. Here is a kernel, powerful by itself, but dependent of a multitude of modules to run, either tools, windows manager, network, file system... The competition, like windows or OS-X, give a much more stream lined experience, providing both the kernel and the tool together, at the cost of reduced choice.

      This is how I see this. C++ is unlikely to start providing that complete environment. This is not its goal. This is the same as expecting Linux to start choosing a single window manager or file system. This is all about providing a solid base and a varied ecosystem.

      This is a discussion that does not have any good answer. Different people will disagree over the best solution and each will have good arguments. Other languages provide complete ecosystems, I think C++ will keep providing an open choice.

  93. Solution: by Anonymous Coward · · Score: 0

    (1) Find Microsoft-platform programmers.
    (2) Reach over their shoulder and close the Microslop Visual Kindergarten Playschool Point-n-Drool IDE.
    (3) Spin their chair around to face you and say, "Are you listening now? Programming involves CODING - ACTUAL TYPING WITH YOUR FINGERS ON THE KEYBOARD!!! You cannot "klink 'n' build" 1337 pr0gramzez!"

    I guarantee you'd raise the collective IQ of the programming world by 75%. But seriously, C++ is dead of the same thing that killed Java - too many suits and not enough engineers.

  94. Re:I'm just glad they're teaching C++ actively aga by Krakhan · · Score: 1

    Ya, and I'm pretty sure it wasn't to solve engineering problems, but to analyze problems in probability theory that he wrote about. The use of using it, and it's closely related Fourier transform came only about in the 19th century for actual engineering problems.

  95. Computer science is about concepts, not syntax by Capt.+Skinny · · Score: 5, Insightful

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

    Isn't the whole idea of a Computer Science education to learn the underlying concepts of programming, not just the syntax or semantics of a particular language? The programming language used is merely a vehicle for conveying those concepts. The professor who was "learning [J++] with you as we go" was referring to the specifics of the new programming language, not the concepts that he was going to teach in the course. Presumably (unless he was unfit for his position), he knew those concepts well and was able to convey them to the class using whatever syntax and semantics were thrown in front of him.

    The quote I'll never forget came from one of my professors during an advising session: "I'll often get calls from IT managers asking if we have any graduating students who know COBOL. I always tell them that ANY of our graduates could know COBOL - and ask if they are hiring someone for their intellect and understanding of programming concepts, or for their knowledge of a particular language."

    1. Re:Computer science is about concepts, not syntax by andi75 · · Score: 1

      The quote I'll never forget came from one of my professors during an advising session: "I'll often get calls from IT managers asking if we have any graduating students who know COBOL. I always tell them that ANY of our graduates could know COBOL - and ask if they are hiring someone for their intellect and understanding of programming concepts, or for their knowledge of a particular language." Just how long do you want to wait until these people can start writing real code? Take C++ for example: Every CS graduate we hired started cranking out terrible terrible C++ code right away. The list of crimes includes bad use of copy constructors, assignment operators, templates, sometimes they even managed to misuse references. Some of these concepts don't exist in other languages, so how are universities supposed to teach them without doing C++ courses? And I can tell you, it takes a while to clean up the mess people make when they use them irresponsibly.
  96. Do educators instruct on the use of debuggers yet? by Ichijo · · Score: 1

    It should be the topic right after hello world. I once took a C++ class and it was a miserable experience for the other students who couldn't figure out how to get their programs right.

    --
    Any sufficiently unpopular but cohesive argument is indistinguishable from trolling.
  97. Re:I'm just glad they're teaching C++ actively aga by nuttycom · · Score: 1

    Constant need to cast everything? It's been a couple of years since Java 1.5, came out with generics and autoboxing, you know. Unless you're perpetually instantiating objects using reflection, the need to cast is RARE.

  98. Re:I'm just glad they're teaching C++ actively aga by kisielk · · Score: 1

    Well, the GP's comment stated that the transforms themselves were devised by Engineers, which is not the case. The transforms were created by mathematicians, and applied by Engineers, and the theory as to why they work for those particular problems was later derived by science.

  99. Re:I'm just glad they're teaching C++ actively aga by Hal_Porter · · Score: 1

    Keep in mind that Computer Science is *not* coding. It's a subfield of mathematics that deals with the theory of computation. The lecturer might have been a theorist. Hmm, so some people don't code any more but spend their time thinking about higher level problems? Outside academia we call those people managers or PHBs.
    --
    echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
  100. and the rest of the world says.... by heffrey · · Score: 1

    .....that the C++ language needs to improve!

  101. Re:Maintainability by Hal_Porter · · Score: 2, Insightful

    All of our C++ apps, without exception, require a nanny process to kill em when they hemorage too much memory. You have to make sure that you match up calls to new with calls to delete, free to malloc and so on. C++ only leaks when it is written by sloppy, disorganized people with a poor eye for detail.

    It's hemorrhage (US spelling) or haemorrhage (UK spelling) BTW.
    --
    echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
  102. Re:I'm just glad they're teaching C++ actively aga by JamesP · · Score: 2, Insightful

    "Oh, I don't really do any coding at all"." That's not a big deal.

    That is BS

    It is ok for, I dunno, a discrete math prof., or maybe an algorythms professor not to code. It is NOT OK for a C++/JAVA/etc teacher NOT TO code.

    It is ok if a cellular biology professor is not a practicing MD. It is NOT OK for a surgery professor to not know how to open people up and not to work with that (with the rare exception of 'I can't operate anymore with a bionic hand' kind of stuff).

    --
    how long until /. fixes commenting on Chrome?
  103. Re: GC by Anonymous Coward · · Score: 0

    More importantly I would not allow anyone else to write code
    without GC because none of them were capable of doing it right.


    Would you look at that ? Poor guy is completely surrounded by high-grade morons. Perhaps the problem is not with the language, but with his own company.

  104. Re:I'm just glad they're teaching C++ actively aga by harlows_monkeys · · Score: 4, Funny

    I'm still astounded that a Computer Science curriculum includes any in-depth teaching of a programming language. Does the physics curriculum include courses on car repair? Does the biology curriculum include courses for the female students on how to land a good husband? Does the Literature curriculum include an in-depth study of calligraphy?

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

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

  105. You know what I'd really like? by Anonymous Coward · · Score: 0

    C++ is a great language if you want to go hang yourself, but what most people really want is an object-oriented C. I'm convinced most of C++'s more esoteric features are basically designed to enable three different goals: RAII-style programming, templates, and operator overloading. While these make for "clean" code, they often make for obtuse code. They really seem more designed to allow library makers to create APIs that look pretty to use, by hiding resource management, types, and syntax; meanwhile, no C++ programmer who's been burned in the past is ever going to assume they can just "+" two types without reading the documentation, because it could mean anything.

    What I'd like to see is a "restricted subset" of C++ that would be completely compatible with the full language, but would be restricted to a minimal, Java-like subset of features that everyone uses and understands (classes, basically). Then you would be able to declare (perhaps with a #pragma or something) that your C++ code only uses this restricted subset. It would be more verbose and C-like than what the C++ theorists would like, but it would eliminate the problem of subtle interactions that require you to language lawyer to understand. Meanwhile, those who want to use the full C++ language would still be free to do so.

    Essentially, I'm proposing an ISO standard set of programming "guidelines" that would be enforced by the C++ compiler. One of the most important parts of programming in C++ in anything larger than groups of one is to state, up front, what features of the language will and will not be used by the team. This seems pretty broken for a standard language if most people are only expected to understand potentially non-overlapping subsets of it.

  106. Re:I'm just glad they're teaching C++ actively aga by Nicolay77 · · Score: 1

    And if you want to write a GUI in C++ wxWidgets is my toolkit of choice.

    There are others but this is one of the best, and has the best license by far.

    --
    We are Turing O-Machines. The Oracle is out there.
  107. Re:I'm just glad they're teaching C++ actively aga by cbart387 · · Score: 1

    And if you want to write a GUI in C++ wxWidgets is my toolkit of choice. Interesting. Most of my application work have been geared towards algorithmic development then 'consumer' products, so I haven't done much in the way of create GUIs. Are you aware of how it compares to developing in .NET or QT?
    --
    Lack of planning on your part does not constitute an emergency on mine.
  108. C seen harmful by Anonymous Coward · · Score: 0

    Always was a scam, always will be.

  109. Re:I'm just glad they're teaching C++ actively aga by Tyr_7BE · · Score: 1

    "they decided to blindside everyone by teaching Visual J++ instead--Microsoft having "generously" donated the college discs containing the software"

    That seems to be their style, alright. When I was at Waterloo, the first programming course I ever took was in C++. That's the way they'd been doing it for a generation, and it was working quite well. Then along came Microsoft, carrying two big bags with dollar signs on them, and all of a sudden C++ wasn't good enough, the future was C#. I'm glad I squeaked through when I did.

  110. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    Yeah we (particle physicists) learnt that the hard way. We as a rule suck at programming, so we thought hey we should get some outside help. Being scientists, we walked across the building to the comp sci dept and asked if they could help us out. Big mistake. Now instead of having crappy software that doesnt work, we now have crappy software which not only still doesnt work, but now nobody can understand what its suppose to do and what would actually happen if it did work. But for some reason we now get the reassuring feeling it doesnt achieve anything in the theoretically most efficient manner :)

  111. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    I'm really happy to hear that as it means more C++ work in the future for me - Imagine how difficult it would be trying to find a job with a skill requirement that everyone else has.

  112. Re:I'm just glad they're teaching C++ actively aga by klapaucjusz · · Score: 1

    My favorite lecturer quote, "Oh, I don't really do any coding at all"
    That's not a big deal. Computer Science is not about coding in particular, but understanding the practices to design and implement solutions to a problem. Computer Science is more about applied math then writing in language X.

    Computer Science is more than just applied maths. It's applied maths and how it relates to systems design and programming.

    As the OP noted, a lot of CS academics have little programming experience, and this has some rather disturbing consequences. A lot of CS research is unrelated to real-world problems, since the researchers have not had the occasion to develop intuitions that would allow them to feel what is relevant. A lot of CS teaching is cold and abstract, and fails to interest the students, because the lecturers do not have enough programming culture to make their lectures live.

    The best CS academics are people who manage to combine a solid theoretical background with a moderate amount of practical experience.

  113. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    C++ should be banned - I've been using C and assembler for 25 years, also Java, C#, VB, and PHP. Nobody has been more honest about C++ than Tom Cargill, C++ Journal, Fall 1990 and I qoute from the book "Expert C Programming - Deep C Secrets" by Peter Van Der Lindin arguably more knowledgable than Barnes will ever hope to be:

    If you think C++ is not overly complicated, just what is a "protected abstract virtual base pure virtual private destructor; and when was the last time you used one?"

    And I might add who the hell cares? Someone that would invent a language as C++ should be sent to Sibera.

  114. Re:I'm just glad they're teaching C++ actively aga by mcvos · · Score: 1

    True, but I'm still used to Java 1.4 collections (and some enterprise environments still require 1.4), and a lot of frameworks pass superclasses around when I know I'm receiving a more specific class.

    Besides, this is rumoured to be one of the big reasons why dynamic languages are doing so well lately. Bruce Tate wrote some enlightening stuff about this.

  115. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0
  116. Try D by hackingbear · · Score: 1

    I wish D becomes more popular. It allows the low level efficient coding without the craps of C++. it also borrow and improve many ideas found in java/C# such as javadoc-style documentation.

  117. Re:I'm just glad they're teaching C++ actively aga by try_anything · · Score: 1

    The thing is that Java is extraordinarily similar to C++. If you are a competent C++ programmer, you can learn Java in an afternoon (or less). If you are a competent Java programmer, it will take you a little bit longer to learn C++. At least a few days by my estimation.

    This is supposed to be funny, right? Java and C++ are vastly different languages. Java was designed to use a similar syntax to C++ and to (kind of) work when treated as a restricted subset of C++, but that was just for the sake of tricking extremely lazy and conservative corporate programmers into giving it a fair chance. Java programmers don't have to know about header files, macros, operators, the distinction between stack and heap objects, destructors, RAII, and techniques for managing heap objects in the absence of garbage collection. C++ programmers don't have to know about classloaders, type erasure, garbage collection, or introspection. The design skills for the two languages are also completely different, since they have different shortcomings.

    In fact, I see no real advantage in teaching Java over C++.

    On the contrary, they are very different approaches, each with advantages.

    Java has two primary advantages: safety and simplicity. C++ has one big advantage: it's a much more flexible language that allows students to explore a much broader subset of computer science concepts.

    Students can get up to speed pretty fast in Java. Java has a lot of features that only make sense in the context of industrial-scale programming, but students will learn not to ask why. If they get past that part, it doesn't take long to learn a useful subset of Java. A bright student can conceivably become a language expert in less than a year. Plus, programming in Java is extremely convenient. The debuggers are rich, the errors are informative, and the stack traces come in very handy. That means students can devote more of their brainpower to learning CS instead of struggling with the language. The downside is that Java can only express the very narrow range of concepts that were deemed necessary for mediocre programmers writing industrial-scale software. Java is intentionally restricted in its power and in its style, and those restrictions will be imprinted on the brains of students who are taught mostly in Java.

    In C++, you have to deal with memory leaks, corrupted memory, unexplained segfaults, and other issues that sidetrack students for hours and days while they're supposed to be learning basic CS concepts. It's a bit of a lie to teach first-year students in C++ and pretend to be teaching them computer science. Mostly they're learning how to debug C++ programs. On the upside, you can go much farther in C++ than you can in Java. C++ was designed to empower programmers to express as many different ideas and styles of programming as possible while preserving C interoperability and the performance characteristics of C. C++ was designed on the assumption that even though it isn't safe to trust the judgment of the individual programmer, there is no better alternative. Java was designed around the opposite assumption: don't trust the taste of the programmer; shoehorn him into a single, neutered programming paradigm in which he can't do much harm. The design of Java ensures that powerful concepts cannot be expressed in Java by individual programmers but must be layered on top by framework designers.

    C++ : Java :: English : a 1000-word subset of Esperanto

    It's easy to fool yourself into thinking that students will learn more if they don't have to go through the excruciating process of learning a complex, crufty, logically flawed real-world language that evolved to accommodate the impulses of its users. It's wrong; it's an illusion. An artificially restricted language circumscribes your thinking. I've heard the complaint that teaching students in C++ gives an unfair advantage to those who had an earlier start in the languag

  118. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    I have used some Lisp so I am (at least tiny bit) familiar with functional programming
    Which dialect? If it was Scheme then yes, but Common Lisp tends towards imperative and object-oriented code rather than functional, while Emacs Lisp is almost entirely imperative.

    (Still better imperative than C++, because imperative with garbage collection is always going to be better than imperative with unsafe memory management...)
  119. C++ is an ugly hack by Giant+Electronic+Bra · · Score: 2, Insightful

    On an already ugly programming language, or at least one which is at best obsolescent from a technology perspective.

    Having 25+ years of experience in the field my opinion is C++ is aweful. No amount of hacking around the edges of it is ever going to fix that. Due to the very nature of the language defect rates are exceedingly high. Even with modern development, test, and debugging tools building software in C++ is an endeavor which requires an inordinate amount of expertise, mostly in how to avoid doing most of the things the language allows you to do because 99% of them are bad ideas. Instead of learning to program well, most instruction in C++ has to be focused on how to work around its hodgepodge of misfeatures. Personally I wouldn't even consider allowing anyone with less than 5+ years of experience touch a commercial C++ application.

    The whole stankin' mess should be retired. The sooner the better.

    --
    "Malo periculosam, libertatem quam quietam servitutem." -- Jefferson
    1. Re:C++ is an ugly hack by ZecretZquirrel · · Score: 1

      It was a hack from Day 1.

      The current state of C++ reflects the design-by-committee shackles that have long victimized it, a result of the attempt to standardize it. The irony is that it has been a great failure as a standard. But it's difficult to standardize something so inherently complex.

      Committee decisions compound the original sin of the language designer. Conceived as a "better C", it aimed low, and has always been tied to a systems programming philosophy. Compare its path with that of Java, and him with Gosling. It's no coincidence that one was the product of academia, and the other of industry.

      Java's feature arc has been remarkably responsive to the needs of most professional developers who want to solve real-world problems quickly, and with high quality. Much of a C++ developer's working burden is the language itself.

      C++ is now irrelevant to most software application developers. In a competitive market for software product, who today would choose to build using C++ over Java, &c???

  120. Re:I'm just glad they're teaching C++ actively aga by Haeleth · · Score: 1

    If you think C++ is not overly complicated, just what is a "protected abstract virtual base pure virtual private destructor; and when was the last time you used one?"
    It's an unlikely edge case thought up purely to try and make C++ sound overly complicated; and to the best of my knowledge I've never used one, because you don't need to use such things to write good, clean, efficient, and maintainable C++.

    The fact that it's possible to write overly complicated code in C++ does not make C++ overly complicated. I could write incomprehensible spaghetti in (insert your language of choice) too, but unless that language is INTERCAL then it's highly unlikely that that would be the language's fault.
  121. Re:I'm just glad they're teaching C++ actively aga by FishWithAHammer · · Score: 1

    Python (intro to prog)

    No. Start with a functional language, mostly because it "looks like" math, which is something that students already know. Scheme, Lisp, whatever.

    --
    "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
  122. Re:I'm just glad they're teaching C++ actively aga by odourpreventer · · Score: 1

    But Java was written to replace C++ at the application level, and as such it does a tremendous job.

    Not sure what you mean with application level, but I'm going to disagree anyway.

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

  123. Or the kind of language...? by argent · · Score: 1

    One thing to consider is that some languages are better suited to supporting good libraries than others. Early binding and the way templates are implemented makes C++ hard to design reusable versionable libraries for. Explicit message passing and late binding in scripting languages and in languages like Objective C make it easier to build and support good libraries.

    Another is that once most of your program is written in canned libraries and components, the remaining glue doesn't really need the performance of compiled code and early binding.

    So people are simply more likely to create good libraries in languages where you need them, and in languages where they flow naturally from the language design. In C++ you have to wait for standards committees.

  124. Re:I'm just glad they're teaching C++ actively aga by dark404 · · Score: 2, Insightful

    Where are they teaching it actively again? I'm a student on computer science at the moment and all they teach in any depth is Java. The only reason I know c++ is my desire to learn it, despite the fact that various parts of my course have recently required a fairly in depth knowledge of c++.
    As background, I have worked with Java, C, and C++. I've also dealt with functional languages (Lisp, Haskell), scripting languages (perl, php, python), and a bunch of other stuff. In all my experiences, my response to C++ is pfft, I can live without it. If I want to get into the guts of the operating system, muck with the kernel, or do something nasty by hand in memory, I'll use C, if I want to write an application I'll use Java. C++ is a terrible language for application development, it combines all the worst aspects of OOP with all the worst aspects of C style memory handling, but brings no advantage to the table!
    I'm tired of all this chest beating of wanabe's complaining oh they teach me java, but I am such an uber geek I want to learn C++! Computer Science education doesn't teach you to program in JAVA, it teaches you computer science, in the course of that you learn to program, not to program in X, but to program. Any computer scientist worth their salt can program just as easily in one language as another, and can pick up any other language just as easily.
    The only big mental shifts come between procedural languages vs oop languages vs functional languages, etc. Everything else is syntactic sugar. Choose the language which best fits the problem at hand.

  125. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    If Wayne Dykstra's Intro to CS was too much for you, it's probably good that you dropped out.

  126. Re:I'm just glad they're teaching C++ actively aga by 32771 · · Score: 1

    I like your attitude towards reading Knuth. I would like to discuss the nature of the drink though. Could I have a cat instead of the dog? The moor you can get away with even though I almost had to accuse you of racism. Walking across the moor and back could help solve some of those exercises too, even without access to a computer, maybe the dog would be a better companion there. You could even talk to it and you might get more attention too.

    This seems to be a somehow Victorian attitude to computing - some things are just timeless.

    --
    Je me souviens.
  127. Re:I'm just glad they're teaching C++ actively aga by cbart387 · · Score: 1

    clisp. We only used it for about 1/2 a semester to get a small flavor of it. Therefore I doubt we hit many nuances of the difference between it and scheme. I could be wrong, I don't claim any mastery over it.

    --
    Lack of planning on your part does not constitute an emergency on mine.
  128. Re:I'm just glad they're teaching C++ actively aga by hummassa · · Score: 1

    I'm still astounded that a Computer Science curriculum includes any in-depth teaching of a programming language. Does the physics curriculum include courses on car repair?

    No, but it better have hours and hours teaching how to use the lab facilities. Yes, Computers are to Computer Science what Telescopes are to Astrophysics, but except for most hardcore Astrophysics, the guys better know very well how to use their telescopes.
    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
  129. Re:Education, even at Universities, needs to Impro by Sicnarf · · Score: 1

    rant: yep. in my university only the self tought programmers get further. the teachers (in my uni of course) nowadays just give an overview of topic X, without going into any detail (most the stuff you can read from wikipedia what they teach). for example: nobody in my class knew what a function pointer in C is, all they got was primitive assignements. to get into real programming, you teach it yourself and look elsewhere (think challenging programming assignments, like SICP thought at MiT).

  130. Re:I'm just glad they're teaching C++ actively aga by turgid · · Score: 1

    Real science involves performing experiments to prove theories. I say this as someone who studied Astrophysics and had a disparaging attitude towards experiments at the time.

    For those of you lucky enough, and arrogant enough, to have IQs above 200, then by all means just read the books and be content in your heavenly crystal palaces.

    The rest of the human race will carry on making progress.

  131. myth by nguy · · Score: 4, Funny

    C++ is based on a concept known as Object Oriented Programming

    That's actually a myth.

    Or, as Alan Kay, the guy who invented object oriented programming, said: "When I invented OOP, I did not have C++ in mind."

    (He was trying to be diplomatic.)

    1. Re:myth by Pseudonym · · Score: 2, Informative

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

      Wrong.

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

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

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    2. Re:myth by Zero__Kelvin · · Score: 1

      "This is part of the old philosophy that a computer is too inhuman and therefore we should try to turn it into a "black box" inside which some mysterious magical things happen which we don't see and never would want to understand. We just interact with it on a very very high level with bubbly little symbolic things that we as humans like but really have to go through enormous amounts of interpretation to be implemented in reality.

      This is EXACTLY the same mentality that lead to the creation of the Hal-9000 (sic) ..."
      Ironically, you have stumbled upon another commonly held myth! In truth, the mentality that lead to the HAL 9000 (note the capitalization and lack of hyphen) was something like: "Hey. I really need to bang off another book in order to fulfill my contractual obligations with my publisher. Ive got it! A book centered around a Heuristically programmed ALgorithmic Computer! ... in Space! Maybe we can get Stanley Kubrick to make it into a movie!"

      Cheers ... ;-)
      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    3. Re:myth by Anonymous Coward · · Score: 0

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

      C++'s support for all of those features is poor and cumbersome.

    4. Re:myth by Pseudonym · · Score: 1

      C++'s support for all of those features is poor and cumbersome.

      ...and yet highly pragmatic. Incidentally, I used to throw around words like "bloated" and "cumbersome" until I wrote something serious in C++, too. Now I understand.

      Pretty much all of C++'s acknowledged problems can be traced back to its one greatest weakness (which is also its greatest strength): The fact that it's based on C.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    5. Re:myth by Anonymous Coward · · Score: 0

      Indeed, it is a myth.

      C++, as Bjarne explained, is a multi-paradigm language. One of the paradigms is object based and is more based on Simula than SmallTalk. Simula was created in the 60's, and SmallTalk in the 70's.

      While it's true that Alan Kay "invented" the term Object Oriented, he did not invent the concepts. He merely took existing concepts and recombined them to come up with Smalltalk. It was a pretty nice piece of work.

      Bjarne, on the other hand, took similar concepts and recombined them in different ways. The only thing he took from Smalltalk was the term Object Oriented. While I find the end result far less elegant than Smalltalk, I do find it useful.

      There are a class of problems where performance is critical AND higher level abstractions are necessary. Even when the higher level abstractions are not necessary, I find myself using certain features of C++ or the standard library and would miss them if I restricted myself to C.

      That said, I agree that C++ is a very difficult language to learn to use correctly, and contains far more opportunities to shoot yourself in the foot than any other language that I've used (and just to list them: pascal, c, awk, perl, python, ruby, smalltalk, basic, lisp, javascript, java...I'm probably forgetting a few). (Throwing some flames on the fires: Java is by far my least favorite language of all the above. It's SmallTalk-- with C-- syntax. I'd probably quit programming if that were the only language available. Talk about sucking all the fun out of something.)

    6. Re:myth by kraut · · Score: 1

      > Or, as Alan Kay, the guy who invented object oriented programming....

      I'm fairly sure Simula predates SmallTalk by a few years, so Mr Kay doesn't quite deserve that honour.

      I'm also fairly sure that the guy who invented the wheel didn't have modern cars in mind, either ;)

      --
      no taxation without representation!
  132. Re:I got my B.Sc. in Comp. Sci in the 1970s and .. by Anonymous Coward · · Score: 0

    Yeah, well... you Engineer's always were a bit weird... doing your fancy pants "Strength of Materials" labs and Destructive testing... us Artsies have the theory down pat

  133. C++ is my favourite language by fatalGlory · · Score: 1

    I've spent a lot of time now with C++ and Python and been doing a lot of Java at uni lately as well as some ASM.

    Java and Python are great for creating business apps where development needs to be rapid, results need to be decently polished and apps are simple enough not to require the full speed of compiled code. They're also great for teaching to non computer science majors who know their subject material really well and need to be able to get a computer to do their grunt work for them.

    However, I really love computer science. ASM and C++ both let me code in a way that makes me feel like I'm actually interacting with a computer. Not like I'm scripting some abstract logic to be interpreted to the system for me by a program written by someone who actually interacted with the computer on my behalf.

    Why C++ over ASM then? LOL, I still want to have a life outside code. ASM just takes too long to use for most app development.

    --
    Censorship is the opposite of education. If neo-darwinism were defensible, people would not need to try and censor ID.
  134. Re:I'm just glad they're teaching C++ actively aga by yabos · · Score: 1

    Fanshawe College of Applied Arts and Technology, Computer Programmer Analyst 3 year course. At least when I was there 4 years ago they were teaching it. After that I went to university for software engineering and they don't teach you much about programming at all. It's all about how to design a software system and has practically nothing to do with programming. Most of the programming you have to learn on your own. There are many students in my 4th year ready to graduate who are completely terrible programmers. They did teach us 1 basic C course and Java course but it's not much in 4 years worth of university.

  135. Re:I'm just glad they're teaching C++ actively aga by mcvos · · Score: 2, Informative

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

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

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

  136. Pay attention, class! by Heembo · · Score: 1

    Thick Client: C++ Enterprise Web Server-side: Java Web Client: xHTML/JavaScript/CSS/xForms Non-Enterprise Web Server-side: PHP/Ruby

    --
    Horns are really just a broken halo.
  137. Re:I'm just glad they're teaching C++ actively aga by Nicolay77 · · Score: 1

    wxWidgets uses C macros to do function binding to controls, QT has a metacompiler extension to do the same and windows forms are restricted to one platform so I don't plan to use them. Mac counts.

    QT is more mature and more commercial but doesn't use native controls in any platform. wxWidgets uses native controls but has ugly database classes.

    For pure GUI related stuff wxWidgets has superb sizers that adjusts every control to your window/panel/container, while the others are more drag&drop oriented just like VisualBasic.

    --
    We are Turing O-Machines. The Oracle is out there.
  138. Comment removed by account_deleted · · Score: 2, Interesting

    Comment removed based on user account deletion

  139. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    In fact, once you know how most things are working, with a few basic concepts such as pointers or how a computer interpret an instruction listing, you should be able to pick up almost any language fairly easily.

    True, if by "almost any language" you mean "any language other than C++ and Perl".
  140. Re:I'm just glad they're teaching C++ actively aga by David+Deharbe · · Score: 1

    I teach freshmen an introductory class using a functional language (Objective Caml), but I do not think that the fact that it looks like math is of any help: they do not know anything worth in maths:-(

  141. Re:Education, even at Universities, needs to Impro by RzUpAnmsCwrds · · Score: 2, Insightful

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

    Why the hell should they? Is knowing the title of a C book that's out of date (OK, the second edition is better, but K&R usually refers to the original edition) important?

    Perhaps you don't understand what CS is. CS isn't about C - in fact, it's not even about programming at all. CS is about the theory of computation. Things like programming language theory and computational complexity theory are subsets of CS.

    CS doesn't include coding practices, use of source control, project/time management, or software testing. All of that is part of software engineering.

    The problem is that people expect CS programs to produce functional software engineers. And while functional software engineers certainly need a strong grasp of theoretical concepts (such as a basic computational complexity theory and common algorithms), what they really need is software and systems engineering experience.
  142. Re:I'm just glad they're teaching C++ actively aga by SirSlud · · Score: 1

    I would agree with you, but the advertising for a CS degree is about becoming a programmer, not a researcher.

    While its obviously important to develop people who are well versed in the mathematical and architectural aspects of programming, its rather useless to send them out in the world without at least a fair amount of experience in languages they're likely to end up using. Esoteric cs education burns a lot of kids who got into it in the first place thinking it was a path to being a code monkey.

    It seems like a pretty big deal to me if a CS prof doesn't code - how can he or she possibly gauge the real world value or applicability of the knowledge s/he's teaching? I did a lot of music study earlier in my life, and while I don't expect music profs to know how to play any instrument, none would be a red flag. A lot of those profs never touched on anything regarding how to play a particular instrument - it'd be mostly theory and coaching. But if a music prof can't actually be bothered to be interested enough to actually play an instrument, they're unemployed. I understand the value of the science aspect of computer science, but it does bother me that people work in the field yet do not write software themselves.

    --
    "Old man yells at systemd"
  143. Re:I'm just glad they're teaching C++ actively aga by smittyoneeach · · Score: 1

    first-time [Java] programmers have to use objects whereas C++ you can get away with...
    I think it's fairer to say that C++ supports a variety of paradigms, from procedural to generic to object-oriented, without forcing you to use stuff you don't always need (garbage collection) while still keeping around the possibility of doing serious performance optimizations (in-line assembly).
    Philosophically, C++ leans towards TMTOWTDI, which explains its unpopularity with the TOORWTDI crowd.
    --
    Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  144. Re:I'm just glad they're teaching C++ actively aga by cbart387 · · Score: 1

    Philosophically, C++ leans towards TMTOWTDI, which explains its unpopularity with the TOORWTDI crowd. Besides me having to googling those acronyms :( I totally agree with you. It's probably why Java rubs me the wrong way. No matter how finicky C++ can sometimes be I still prefer it.
    --
    Lack of planning on your part does not constitute an emergency on mine.
  145. Re:I'm just glad they're teaching C++ actively aga by skroll82 · · Score: 1

    But he never actually mentioned what his lecturer was actually teaching. I would say that if you were in a Theory of Computation course then it wouldn't be such a surprise if the teacher doesn't actively do a lot of coding.

  146. Re:Teaching C and C++ is a crime. by krreagan · · Score: 1

    Agreed! C, C++ and similar languages promote brain lock! programmers spend too much time debugging the language and not enough time designing or engineering the application. Take a look at most OSS code and you can see this. Horrible.

  147. Re:I'm just glad they're teaching C++ actively aga by tuomoks · · Score: 1

    Same here, since -67. Actually I think no language is really "bad" but how and where they are used is totally gone weird! C, not C++ or C#, is simple but only if you know what you are doing. Same could be said of many languages but the scope of knowledge is different. Take Simula, the first object language, very easy to write if you know what you want - C++ doesn't get even near to that (it isn't even an object oriented language in pure sense), you depend of language syntax instead trying to address the problem to solve. And I'm not a Cobol programmer but to solve a business problem where the calculations have to be correct, different from scientific problems, I would say Cobol is your language. And it is not wordy (where that came?) - with good copy libraries (not mixed with object libraries!) it comes very clean and short to write (and read.) Funny you mention list languages - for example LISP can be very powerful, one of the few languages which can bootstrap itself and endlessly expandable. In right hands it really is one of the most powerful of languages - just takes a little to get to the mindset, as do APL, Prolog, Erlang, etc. Now, showing my age, IBM BAL (basic assembly language) is still my favorite - all the benefits, easy to write, you are in control what and how, very clean and short (if you know what you are doing), commenting is easy, as efficient as any language can get, can interface any other languages and libraries, native threading (tasking) since when, and so on. I wouldn't use it for scientific or for some business tasks but when you need control and performance. Fortran - another undervalued language (as PL/I but let's forget it) - if you need scientific calculations based on tested and proven routines, then it is your language. There has been a long time conversions to C++ for libraries but the amount of code (with weird syntax, nothing to do with calculation itself) will be many times what is needed writing the same code in Fortran - weird again. And it is very easy to read and comment. All these languages have compilers to almost any platform so porting is easy, they report the accurate warning/error positions and don't give up in first error (my gripe with C - the real problem may be 1000 lines back in some include file defined third time over but try to find it sometimes!)
    Yes, I agree with many of the comments, it is important today to know C++, Java, C#, scripting languages (REXX is my favorite - Python is great, AWK has it's place, Tk/Tcl, PERL, PHP, JavaScript, VBS, etc each have their use) but this only because the business selects languages by whoever screams loudest, not what is most suitable for the problem in hand.
    Maybe the focus is too much on languages instead of the solutions? Languages are (relatively) easy. If they are used in business I would assume that company has a CM/SC and well tested libraries in place already so any standard and routine will work independent of the language or platform. In new development I would recommend starting from that, build standard, language independent, well tested code and object libraries first. That is the way what I have seen business working a long, long time - maybe that's why Cobol doesn't go away, it just works on whatever you throw against it, no new, fancy coding needed - maybe call your new XML parser instead of your old parser or change the runtime library reference but that's just one liner. And move it from 32 to 64 bit or from Intel to IBM G6 just by compiling and it still works. Try that in C++ especially with floating point (not defined yet) or endian changes or xxP64 standards or whatever - good luck!

  148. That subset has a name... by mevets · · Score: 1

    C. C++ is just awful. Stroustrup is whining. This could never be his fault; of course not. C++ must be perfect, just look at what he has said about it! It must be wonderful. If most C++ code is unreadable, happens-to-work-once swill, it must be the fault of the teachers. Even the examples in his own books can't give a convincing reason to use it. Line up the "white book" on C, with any of the blue or grey books on C++. Its not just because K&R were great writers (they were); it is because they were great language designers.

    Of course, these are all implementation faults. The pure language, like any pure 'ism', is perfect, it just happens to be useless...

    C++ isn't portable; not just across architectures or OSes, subsequent revisions of compilers typically involve a 'port' of your code to the latest redefinition. Binary compatibility is non-existant (unless you spec all your interfaces as extern "C" :)
    C++ stinks for systems level programming. Trust me; done lots. The quickest solution when faced with C++ low level software is to quickly re-write it in C. Nice thing is, it usually ends up more concise, more reliable, and more maintainable.
    C++ may be ok for application programming that don't require portability. Not really sure of the point.
    C++ stinks for libraries - again, poor version control, dubious infrastructure, poorly specified system environment.

    1. Re:That subset has a name... by epine · · Score: 1

      C++ stinks for systems level programming. Trust me; done lots. The quickest solution when faced with C++ low level software is to quickly re-write it in C. Nice thing is, it usually ends up more concise, more reliable, and more maintainable.

      Trust you? Why?

      Yeah, I've also rewritten bad C++ code in C. I've also then taken the improved C code and rewritten it back to C++, with yet further improvements in concision, reliability, and maintenance, (though, granted, for a restricted set of maintainers).

      Just for the record, I define maintenance as non-trivial extension of functionality, and not as continuing development with cheaper and more poorly trained resources. Repairing bad code that never could have been correct in the first place I tend to regard to as "emptying diapers".

      I always end up repeating the same observation in these C++ discussions: the people who complain most bitterly about C++ tend to be the same people with low regard for their coworkers and their coworker's work output.

      I would only choose to use C++ for a project where I had high regard for the other programmers involved.

      Most likely, if that same crappy coworker had written the code in C originally, you would have rewritten it to improve concision, reliability, improve maintainability. Only you would have complained less, because rewriting bad C in good C requires less keyboarding than rewriting bad C++ in good C (thought generally little real difference in mental effort).

      On the whole, competent C++ programmers tend to code their loops more correctly than most of the C code I've come across. A common meme in C code is to embed five return statements in a deeply nested loop to "handle" error conditions, though usually these nested return statements do a better job of creating error conditions.

      In C++ the tendency for novice or mediocre programmers is to invent classes or class hierarchies with no real utility. If the class manages its own memory, it's almost certainly incorrect, though the incorrectness might not show up until the class is used differently in future (such as contained in an STL container).

      I wrote my last significant systems programming project in C. In the cases where I wished I had templates available to optimize some constructs at compile time (single-reader single-writer synchronization primitives used heavily in interrupt context), I did hideous things with #define macros that I can assure you will not be maintained lightly. Templates would have accomplished this task with the same (or even better) performance, at a higher level of abstraction, with better safe-guards against incorrect use.

      At the end of the day, it was only about 5% of my code base where the limitations of C required putrid convolutions with the C macro processor. If I had programmed in C++, 5% of my code base would have been devoted to hiding the ugliness of C++. Different rug, same difference.

      I'm aware of many non-portable constructs in C++. Almost all of them inherited from C. Most of the C++ portability problems were a transitional effect when the standard got fairly far ahead of the compilers.

      Nor do I understand the complaint about C++ lacking a standard ABI, either. That's been in the works for years:

      http://www.codesourcery.com/cxx-abi/

      Again, it's a matter of having access to mature compilers that actually implement this ABI now that we have it. By that standard, C wasn't portable in the 1980s, as I almost always discovered compiler bugs porting C code from one compiler to another, and rarely was I brave enough to link objects compiled by different compilers.

      However, I never blamed the C language for that state of affairs.

      If you measured the abstraction of a language with a thermometer, C would read about 10 degrees. Kelvin.

      C++ probably has more defects than any other language I know. On average, these defects are less fatal than advertised by

  149. Re:Maintainability by tuomoks · · Score: 1

    Absolutely correct - ((C++ says)) I don't leak, you leak! If the programmer can't keep track of the memory, it is time to get more experience (or forget the programming!) No programming language with GC can fix what you don't know or understand. Sorry - just fixed a horrible C# system slowly running out of the memory and not even talking how the "perfect" thread pools were used!

  150. There is a subtle difference. by mevets · · Score: 1

    The problem with the C code is obvious, and easily caught by code review. C++, on the other hand has hidden the bug so well, only those with an intimate understanding of the class interfaces have a hope of catching it. Code is meant for reading; for everything else there is APL.

    1. Re:There is a subtle difference. by aj50 · · Score: 1

      The C code is written to be as clear as possible and to show what's going on. A much more convoluted example could be written in C. (A simple example which would give something comparable to the C++ code would be to have a C library which implements dynamically resizing arrays and have it return the size as an unsigned int).

      --
      I wish to remain anomalous
  151. Re:I'm just glad they're teaching C++ actively aga by Pseudonym · · Score: 1

    But Java was written to replace C++ at the application level, and as such it does a tremendous job.

    Wrong, and wrong.

    Java was designed to support the execution of code from an untrusted source, such as from over a network. That was the main design criterion, and it permeates the language.

    It was not written to replace C++ in the places where C++ works, and it's actually a very poor substitute. But then, C++ is also a poor substitute for Java.

    --
    sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  152. Re:I'm just glad they're teaching C++ actively aga by Fulcrum+of+Evil · · Score: 1

    a lot of frameworks pass superclasses around when I know I'm receiving a more specific class.

    This is what interfaces and overrideable stubs in the base class are for.

    --
    "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
  153. Re:I'm just glad they're teaching C++ actively aga by harlows_monkeys · · Score: 1

    The moor you can get away with even though I almost had to accuse you of racism

    If I had meant the people, not the habitat type, I would have said moop, not moor.

  154. Re:I'm just glad they're teaching C++ actively aga by owlstead · · Score: 1

    As said, readily solved with Java 1.5, unless you are casting between basic types. And within the Eclipse IDE (e.g.) you can use quick fix if you have a casting problem. Having weak typing is a much bigger problem, IMO.

  155. Seinfeld fans rejoice! by Zero__Kelvin · · Score: 1

    Mod the parent Funny, Seinfeld fans!

    --
    Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
  156. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    Serpentmage was presumably talking about the Heaviside operational calculus (http://en.wikipedia.org/wiki/Operational%20calculus) rather than Laplace transforms as such.

  157. Re:I'm just glad they're teaching C++ actively aga by dhasenan · · Score: 1

    One major benefit that most functional languages provide is automatic parallelization. C++ can't support that, even if you are programming in a functional style, unless you use a framework like OpenMP.

  158. Re:I'm just glad they're teaching C++ actively aga by maxwell+demon · · Score: 1

    If you think C++ is not overly complicated, just what is a "protected abstract virtual base pure virtual private destructor; and when was the last time you used one?"

    What is a "red Ford car steering wheel quick left turn" and what was the last time you used one?
    --
    The Tao of math: The numbers you can count are not the real numbers.
  159. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    I graduated purdue in 07. They were teaching java as the intro course to cs, but besides that the rest of my CS degree was in C. The data structure course was in C++, but really we only used it to implement templates (the rest of that course was theoretical in nature). The graphics course I took had C++ as the language of choice, but we were given a lot of code already (and no C++ concepts were taught). The compiler course was in java.

    Purdue doesnt really focus on software engineering or programming. They focus on theoretical computer science. I didnt learn very much about programming in any given language (not even C), but I did get a lot of crazy stuff thrown into my brain. Having my brain stretched in several very uncomfortable ways made it relatively easy to learn new languages and programming methodologies literally on the job.

  160. Re:I'm just glad they're teaching C++ actively aga by dhasenan · · Score: 1

    On the contrary! If you are quite knowledgeable in C++, it will only take you a few years to learn C++.

  161. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    But for some reason we now get the reassuring feeling it doesnt achieve anything in the theoretically most efficient manner.

    That's good for you! Our CS people came back saying that unless NP!=P (or whatever), we can't even efficiently approximate not achieving anything.

  162. Nooo! by severoon · · Score: 1

    'In the early days of C++, I worried a lot about "not being able to teach teachers fast enough." I had reason to worry because much of the obvious poor use of C++ can be traced to fundamental misunderstandings among educators. I obviously failed to articulate my ideals and principles sufficiently.'

    Yes, clearly that was the problem—you failed to articulate bad ideas sufficiently. Not that they were overarticulated and everyone has 50 different ways to do the same thing.

    'Given that the problems are not restricted to C++, I'm not alone in that. As far as I can see, every large programming community suffers, so the problem is one of scale.'

    I'm a Java programmer myself, after struggling with idiocies of C and C++ for a long time (#include, anyone? care to chase down this header for me?). Java has shown when you start with better principles, you get a better language...and then eventually foul that up, too.

    It boggles me that there are still people trying to breathe life into C++. If you are a university student at this very moment, do yourself a favor: realize that if you learn C++, and decide to base a career on knowing it, you will be doing legacy programming until you lose your job and there is no other. Legacy programming means that you will be mostly working on maintaining and occasionally extending bad ideas poorly written. This has only marginally to do with the language itself, but there it is. If you decide Java is your thing, then after you've worked about another 5 years, you'll find yourself in the same state, because I give Java until about 2013 the way things are going. Then again, maybe we'll move at "Internet speed" and it'll only be 2010 until people are wondering if Java's worth anything any more.

    (The harbinger of evil on Java was marked by the introduction of varargs in Java 5, if you're wondering. I can think of no better way to say, Hey, let's do something pointless that will make it tough to resolve which method is getting called! And slow too, can we make it slow? Oh and also we should say we're doing this so you only have to write one method instead of a bunch, but actually you should have to write a bunch of methods when you only wanted to write one!...just check out that ugly-ass of() method. Of course, now I think about it we did really need it...after all there's no other way that already existed to accomplish the same thing -ahemcoughcougharraycoughcollectionscough-. I'm sure there are lots of good reasons that are sound design for a developer to shroud a method prototype in a could of mystery.)

    So if you're a uni student, learn Java, b/c god knows you'll need it for that first job out of college. But do yourself a big favor and start preparing for the inevitable gigacore processors that will be all the rage by 2015...learn Haskell and LISP. Go write something that runs on a Beowulf cluster (yea, I said it). Figure out how to make an AJAX call to a Java servlet that farms out jobs to an Erlang ring. You'll be glad you did.

    --
    but have you considered the following argument: shut up.
  163. What is C++ ? by dino213b · · Score: 1

    Having been around for some years on this technocratic Earth, and having experience programming in pretty much all the standard (and some exotic) languages, I can say this: no matter which programming language a person might use, that programming language ultimately executes in machine code. Having said that, the most efficient way of writing code is in assembly.

    What drives the wedge between pragmatists and idealists is development time. I could probably optimize my projects at work by dumping PHP and writing CGI programs in assembly - but - at what cost? Rather than spend $10k on development time, it's a better utilization of resources to lease a dual Xeon server for an entire year to meet performance requirements of the system. Not efficient on code level, but absolutely makes sense on a business level. Similarly, I could have employed C for previous data acquisition projects but LabView and G code allowed the project to be completed in two weeks instead of two months. During that time difference, numerous graduate students managed to put the system to good work. Time does matter.

    Even assembly is not straight forward. You must be aware of all opcodes for your code to be efficient, and that means knowing which hardware you're developing a program for. Who has that amount of time to learn engineering specs of processors? Even C and C++ compilers aren't entirely efficient when it comes to generating programs. For amusement, see this classic piece:

    http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html

    This guy spends hours optimizing a program so to reduce its executable size from 3998 bytes to 45 bytes. In this process, it's not just the storage size of the program but also the number of instructions the program goes through. A great achievement in its own right, but, not worth the trouble for larger programs. After all, isn't point of programs to basically do a job? In other words, it's more efficient to write the program once (even if it's inefficient) and leave it be -- rather than rewrite it continuously until it's absurdly efficient.

    There is a reason why R.A.D. has been given an acronym and everything. I'm afraid that in this hodge-podge of processors, operating systems, hardware, etc, the wisest course of action is to shoot for completing a task if the outcome is correct. It's ridiculous to expect today's programmers to stick to a single language and learn it intimately: that's just not how things work in the real world.

    Now, I'm not endorsing Vista's inefficiencies or anything - just talking about day-to-day programming.

  164. Re:I'm just glad they're teaching C++ actively aga by QuoteMstr · · Score: 1

    You are conflating computer science and computer engineering, just like almost everyone. A "C++ teacher" is not teaching computer science, but computer engineering, whereas an algorithms professor is teacher computer science, but not computer engineering.

    Any class that requires the instructor to know actual coding is, on its face, a computer engineering class (though it may also be a computer science one.) Ugh.

    In the hard sciences, labs and lectures are often separate classes with different instructors and grades. I think computer science departments need to create the same separation.

  165. Re:Education, even at Universities, needs to Impro by maxwell+demon · · Score: 1

    This is a horrible attitude, as many students (including myself) are not going into software development.

    In that case, why are you studying CS? It's like studying physics and complaining that you won't need all that quantum mechanics at the engineering job you plan to get. The answer of course is, if you are just interested in engineering, you should study engineering instead.
    --
    The Tao of math: The numbers you can count are not the real numbers.
  166. BS's JSF document mirrors the real thing by Traf-O-Data-Hater · · Score: 1

    As a C++ programmer, aircraft enthusiast and a resident of a country set to buy the Joint Strike Fighter (JSF) I clicked on Stroustrup's link to his 'JSF++: Joint Strike Fighter Air Vehicle Coding Standards PDF' http://www.research.att.com/~bs/JSF-AV-rules.pdf but it was completely broken.

    Given the JSF has gone through all sorts of delays and stuffups, it just seemed so poignantly ironic.

  167. Re:I'm just glad they're teaching C++ actively aga by King.Tito · · Score: 1

    You make a really good point here, and the it's odd how many people get computer programming confused with computer science. I own a company that develops software for fairly mission-critical systems, and the last people I need to hire are scientists; I'm not in the business of solving confounding scientific problems, I'm just in the business of building reliable software for my clients. It's even weirder that they actually use the word "science" in the degree - how many freaking CS graduates would most of you consider to be real scientists? I've met about a thousand or more CS people over the course of the years, and the only time I ever met any that were actual scientists was when I visited a research institute to talk with some guys about licensing a technology they were developing...

    Anyway, to the previous poster's point - I would be more in favor of some universities dropping their CS program entirely and replacing it with one focused on pure software development. This isn't to say that CS should go away, but I think that universities should make a stronger distinction between the scientific and vocational aspects of the field - have a software development degree and have a computer science degree. Leave the contemporary programming languages out of the CS degree, and leave the intense math, etc. out of the software development side of the house. I can't imagine how excited I would be about being able to hire candidates with a four-year degree in "Commercial Software Development" rather than having to look at the same old crap resumes from CS graduates - "I took a lot of advanced math classes, and wrote a logging program in C." Sigh...

    Anyway, the whole point of technology is to make things easier for us, not harder. The "real" computer scientists have done great things and made life very easy for people like me (who just like to build applications software), so why don't we show them the respect that they deserve and stop using CS as a catch-all for anything related to computer software?!?

  168. C++ not a good teaching language by sentientbrendan · · Score: 1

    >I'm a student on computer science at the moment and all they teach in any depth is Java.

    My school does the same thing, and I recommend that. Java is a relatively simple language, good for explaining fundamental data structures and algorithms issues in. When you move into upper division courses you will probably end up doing a lot of C and C++. After all, there's no way to teach an operating systems course in Java, and graphics courses and graphics industry jobs are C++ oriented.

    That said, I think the problem you see in school's is that students learn Java, Scheme, or Python or some such relatively simple language as an introductory measure, and then when they get into upper division courses they are thrown head first into C and C++ without a lot of prep, and I think that is the problem that Stroustrup runs into a lot.

    Both C and C++ require a lot of idioms related to memory management and the nature of how C++ compiles things, that don't exist in other programming language. Even something as trivial as returning large objects from a function, which you do like this in Java

    String method(String input); //signature

    String myString = obj.method("asdf");

    Doesn't work the same in C++! In C++ there are no fewer than 3 ways to return an object from a function.

    By value (a bad idea for potentially large objects like strings):
    std::string my_string = func("asdf");

    By pointer (potentially a bad idea because it requires you to answer the question, who is responsible for deallocating this pointer?):

    std::string* my_string_ptr = func("asdf");

    And, what is usually the correct answer (is efficient and has the least headaches associated with it), by output parameters:

    std::string my_input_str;
    std::string my_ouput_str;
    func(my_input_str, &my_output_str);

    Output parameters are technically possible in java, but not used nearly as often. However, in C++ they are probably the most common idiom, depending on the quality of the code base.

    Issues like this are difficult to teach because they require a level of concern over areas like efficiency and code readability that may be common in industry, but which academics concerned with research rarely have cause to exercise. They also require in dept knowledge of the language in way that is rarely necessary in Java.

    1. Re:C++ not a good teaching language by Anonymous Coward · · Score: 0

      Return by value is idiomatic C++. When you pass a ref param for taking the result, you are implementing RVO by hand in your source. A decent compiler can and will do this for you in the object code where it belongs, so that your team won't have to constantly read through it.

  169. Re:I'm just glad they're teaching C++ actively aga by ralphdaugherty · · Score: 1

    I learned some of the most important concepts in a class that was all done in pseudocode...You are destined to be a code monkey.

          which is preferable to being a pseudocode monkey like you.

      rd

  170. When I find my code in trouble, mother Mary... by laejoh · · Score: 0

    "restrict yourself to a specific subset of C++".

    Now that would be C, wouldn't it?

  171. Re:I'm just glad they're teaching C++ actively aga by Almahtar · · Score: 1

    The thing is that Java is extraordinarily similar to C++. If you are a competent C++ programmer, you can learn Java in an afternoon (or less). If you are a competent Java programmer, it will take you a little bit longer to learn C++. At least a few days by my estimation. WHOA. I think you just underlined the point of the article hardcore. Ow, my faith in mankind.
  172. Re:Education, even at Universities, needs to Impro by mrchaotica · · Score: 1

    I'm continually amazed that the CS majors at my major US accredited university can't program using pointers, object oriented techniques, or parallelism.

    I'll bet just about every CS major can do one of those things... just not all three. And I'd add "understand algorithmic complexity" to the list, and suggest that the best you could hope for from all but the most exceptional students is two out of four.

    --

    "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

  173. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    "I don't know this language myself, so I'll be learning it with you as we go." It's far worse when they are referring to the English language.
  174. Re:I'm just glad they're teaching C++ actively aga by try_anything · · Score: 1

    Unless you're perpetually instantiating objects using reflection, the need to cast is RARE.
    Unfortunately, there is a single Java language wart that is single-handedly responsible for rampant casting when dealing with inheritance heirarchies. Here's an example: In the Eclipse framework, if you're using a TableViewer to display a table of items to a user, you can get the current selection (the items selected by the user) by calling tableViewer.getSelection(). The type returned by tableViewer.getSelection() is IStructedSelection. However, the getSelection method on TableViewer overrides a getSelection method defined on StructuredViewer, which is declared to returned ISelection. Therefore, the getSelection method on TableViewer is also declared to return ISelection, and every time you call tableViewer.getSelection you have to cast it from ISelection to IStructuredSelection.

    This practice was created to deal with the lack of return type covariance prior to Java 1.5. Before Java 1.5, a method returning ISelection could not be overridden by a method returning IStructuredSelection, even though IStructuredSelection is a subtype of ISelection. Many valuable libraries and frameworks date back to before the fix. and there are probably still lots of Java coders who keep coding the old way out of ignorance. Therefore, rampant casting will be a fact of life in Java for years to come.

  175. Re:Teaching C and C++ is a crime. by Anonymous Coward · · Score: 0

    Lunacy might as well be a crime too.

    Good design always trumps choice of language.

  176. Re:I'm just glad they're teaching C++ actively aga by mcvos · · Score: 1

    As said, readily solved with Java 1.5, unless you are casting between basic types. And within the Eclipse IDE (e.g.) you can use quick fix if you have a casting problem. Having weak typing is a much bigger problem, IMO.

    I used to share that opinion, but now that even Java fans like Bruce Tate are cheering the advantages of dynamic typing, I'm not so sure anymore. I'm not about to give up Java yet, but it won't hurt to keep eyes and mind open.

  177. Re:I'm just glad they're teaching C++ actively aga by thedanyes · · Score: 0

    I concur. Your post is both funny and insightful. One time I complained to faculty about the reading material in an operating system class (at a university which I will not mention here), and was basically told that the reason the material was factually incorrect was because things change so often in the CS world. I argued that there were plenty of books written decades ago that were still completely relevant. I was told that those books were few and far between - which is true, but irrelevant AFAICT. I dropped this line of questioning, got an A in the class, and remained frustrated about the ineffectiveness (and in some cases outright falseness) of our assigned reading material.

  178. Have a look at "Embedded C++" by slashbart · · Score: 1

    Most C++ work on embedded systems uses a subset. There are some attempts to formalize this: Embedded C++.

  179. strcpy(char*a,char*b) { memcpy(a,b,strlen(b)+1)}; by slashbart · · Score: 1

    so. This is how MS does it. :-)

  180. Preach it, brother by patio11 · · Score: 1

    My CS teacher used to say "If the future of AI is going to be on the Internet, not in robots, then the future language of AI is going to be the one that can open and parse a URL most easily."

    There are many possible choices for that language. C++ is not one of them.

    Similarly, the future of solving business problems for most people is taking a small set of data from a big honking set of data, doing some business logic on it of trivial complexity relative to one's computational capacity, and displaying it in a comprehensible form to the user. There are probably languages less suited to this task than C++, but I'd have difficulty coming up with one off the top of my head.

    I want to see someone do the Ruby on Rails "15 minutes to a weblog" demonstration in C++. Take however much time you need. Use whatever framework floats your boat. And take a screen recording while doing itShow us how easy it is to create a fairly typical, conceptually trivial application in your favorite tool.

    My guess if I tried it? Somewhere around the 4 hour mark after hitting ANOTHER seg fault I'd commit suicide. Or start reimplimenting it in Perl. Which is really just more violent suicide -- there is more than one way to do yourself in!

  181. The problem is not related to C++ at all by Anonymous Coward · · Score: 0

    It seems to me that the problem with learning C++ is closely coupled with the mental attitude of the learning person.

    There seem to be to problematic attitudes: "Learning resistance" and "lacking curiosity".

    There are developers out there, which for example just won't see the advantage of using exceptions for error handling: "Return codes have always worked for me, thank you very much."

    And then there are the people, who just manage to grasp a minimal feature set of C++ which enables them to solve their problems, however inefficient and error prone the solution may turn out. "Yes, I heard about templates, but I really don't know what they're for."

    And - of course - beeing a bad programmer is a language independent "feature". I've never seen a bad C++ programmer who wrote good, clean Java code. This might be enhanced by C++ since the language enables you to solve any problem in almost any possible way - including the exceedingly stupid one.

    One can argue, that C++ is a complicated language with many pits and trapfalls, but learning how to build a java enterprise application with JSF, Spring, Hibernate has an equally unpleasent learning curve. (Done this for the last 3 years.)

  182. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    Are you talking about Dave Ellison by any chance? I only ask because he said the same thing to my class at university and your username leads me to believe that you may be from the same area ;-)

  183. The Good Old Days by jandersen · · Score: 1

    - and all that. I remember the GIER machine he talks about; those were the days.

    One of the things that strike me is the colossal difference between Stroustrup's vision of C++ and the way it has been put to use; which I suppose is the point he makes in the interview. Having seen abominations like MFC - which isn't atypical of how C++ has been used - you realise that people just use it like any other programming language, making things up as they go along. Stroustrup's assumption, however, was that you work out all your theoretical concepts and models before you start coding anything - in which case C++ has all the features you need.

    The problem is, of course, that very few businesses have the patience or indeed the skills required to work out a good, theoretical model for their products; I certainly haven't been in one in my nearly 30 years in computing.

  184. bullshit by nguy · · Score: 2, Interesting

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

    Alan Kay didn't criticize C++ for being multi-paradigm or for being low-level. Alan Kay criticized C++ because C++ classes and the C++ type system are so mind-numbingly limited and poorly designed. No duck typing. No "become". No reflection. No meta-programming. Instead, you get a tar pit of source code dependency management, potential memory management errors, and other traps.

    Can we please learn from this?

    Well, you certainly could stand to learn a lot, but I suspect that you won't bother.

  185. Approach with feeling by bytesex · · Score: 1

    The problem I see with C++ is this. I know it has been recounted over and over again above, but allow me to distill it to what I think is the crux of it: if I wanted to make a C compiler (which I don't) then I would know how to make one. Same goes for java, LISP, or even BASIC. I know C quite well, and java too, but I know only what needs to be known about the other two (that is, I've written some stuff in it). My point is that the languages are simple; the 'old testament' is about two hundred pages thick using a large font and a lot of whitespace. These languages, irrespective of how well you know them or how long ago you used them, fit in your head. Granted, there would be a few lookups here and there, but all in all, given a few days of extra time, access to a web-browser, lex and yacc (or the natural language-specific variety thereof), you could build a compiler or interpreter for them. And not only do they 'fit in your head', they also have an aura around them, a 'homely feeling', or a 'scent' of sorts. You'd know what extensions to the language would be natural for it and which wouldn't be.

    Not so for C++. I know some of it; I know almost all of C, but the mind just boggles trying to fit all of that behemoth into one coherent picture. It just can't be done. Not only that, but I can't even begin to define what belongs to the 'scent' of C++ and what doesn't. And that's important, because real compiler builders and standard API watchdogs must also have this feeling. For languages with a super-human scale must also have super-human compiler-makers and standard API watchdogs. And not only that, but also programmers who can say, with some pride, 'I know quite a lot, if not all of C++'. The latter thing being impossible is not a good thing - it is a flaw.

    --
    Religion is what happens when nature strikes and groupthink goes wrong.
  186. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    a programmer builds "objects" or "glasses" out of his code, Gahh! The glasses! They do nothing!
  187. Re:I'm just glad they're teaching C++ actively aga by achacha · · Score: 1

    Managing projects is an issue with developers, culture and diligence. I have been on small java projects that were a mess and on many hige C++ projects that were great to work on. Java allows weak developers to write code without knowing how things work underneath which is unfortuante because it is much harder to find good developers in the java world, I interview too many people who don't even understand basic data structures yet claim to be enterprise level engineers.

    Even though I do a lot of java (industry fad?!), I miss the fine grained control over memory and os resources that C++ offers and hope to someday do a lot more C++.

  188. Re:I'm just glad they're teaching C++ actively aga by mgblst · · Score: 1

    What are you, gay?

  189. Re:I'm just glad they're teaching C++ actively aga by jhol13 · · Score: 1

    But beyond some hard-to-define point, where I'm right now, Java just doesn't cut it. Too many pitfalls, too many workarounds. There isn't a language which does not have pitfalls.

    Gödels incompleteness theorem adapted for computer languages: Any programming language which is complete (i.e. usable) must be inconsistent (i.e. unusable).
  190. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    "My research shows that this language is one of the oldest languages in existence, pre-dating even assembly!"

    You are right, of course, but you got the dates wrong. C++ was developed around 100 million years ago, around the Cretaceous age. As the most computationally competent biological components at that time were the dinosaurs, the language acquired a "programming in the large" philosophy.
    It is known that developing in C++ gives you short term gains. However, as systems get more sophisticated, it places huge cognitive stress on its users. This was known to most dinosaur philosophers and as such, was used as a method of punishment for baby dinosaurs in infant academies, for those who do not learn their geometry. At least until the public opinion became against it, swayed by such philosophers as Socrataurs who classified it as child abuse.
    It was still used by grown adults, until a major volcano stack overflow in the Volcanoes CT (Cretaceous-Tertiary) operating system resulted in the destruction of known civilization..

  191. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    I guess you were taught bad practices to do Java development if you think you need to do all that for a quick and dirty Java program. I personally fire up a text editor, type in the basic class and write all my test code in the main function itself, compile it on command line and run it from command line. I don't see how this is different from your scenario for a c++ program.

    Now, for my enterprise applications which are done on massive scale, I will use my Eclipse IDE. Please don't blame your lack of knowledge on the language itself.

    -Anon.

  192. Re:I'm just glad they're teaching C++ actively aga by mcvos · · Score: 1

    Managing projects is an issue with developers, culture and diligence. I have been on small java projects that were a mess and on many hige C++ projects that were great to work on. Java allows weak developers to write code without knowing how things work underneath which is unfortuante because it is much harder to find good developers in the java world, I interview too many people who don't even understand basic data structures yet claim to be enterprise level engineers.

    I hope you seen that the obvious advantage here is that Java programmers don't have to know about the implementation of underlying datastructures. There's a huge standard library with well defined interfaces, and I can rely on that. Ofcourse I can figure out how exactly HashMap or TreeSet is implemented, but why should I? That time is much better used to do something useful with them. All I have to know is what they're good for and what they aren't good for.

    That fact that Java allows programmers to write effective code without knowing how things work underneath is an advantage, not a disadvantage. A language or framework that requires you to know every little detail about its implementation is bad, because it's hard to use and hard to learn.

    (Ofcourse that doesn't change the fact that good programmers should have a good understanding of basic datastructures, but they should also understand the importance of transparency, interfaces and APIs.)

  193. Re:I'm just glad they're teaching C++ actively aga by demallien2 · · Score: 1

    There are, nevertheless, certain things that computer scientists know better how to do then computer engineers.

    Example: I'm an engineer, and I had a job to do that required parsing C header files. Parsers, compilers, loaders, virtual memory, and all that good stuff just never appears in engineering degrees. Too theoretical. Troubles is, I needed that stuff to make a virtual machine implementation actually usable in the real world. I then had to spend three months learning how to write compilers from textbooks, because my company ONLY has engineers, no scientists.

    A practical understanding of programming can only get you so far. When you need to do something truly exceptional with computers, you need the theory to back it up.

  194. You can't do that! by menace3society · · Score: 1

    There's no way to teach C++ effectively in a university setting, because there's so goddamn much of it. It would be like having a major in "Science". You have a language that's been around for a quarter-century and its creator still doesn't fully understand it. Well, maybe he does understand it, but we'll never know because the language is too goddamn complex to say for sure. It's taken forever just to get compilers that implement (as far as anyone knows, anyway) the language completely (and now they want to make a new version that will be even harder to understand.

    I think the first step in teaching good C++ is to sit down and figure out which portion of C++ is actually useful, and then standardize and implement that. Call it C+, or C++,++ or something.

  195. Re:I'm just glad they're teaching C++ actively aga by orlanz · · Score: 1

    We actually stared off w/ other options. I got hit w/ Pseudo code (read: fake programming in English for those who can't spell). For a guy coming from C programming, this was absolute pointless torture (you don't know how many time I scanned a piece of paper and thought of doing Ctrl-F). They went back to Scheme. Later switched to Python and Matlab.

    Scheme isn't too bad as a starting language, but I consider it horrible when you are trying to teach people to write clean, maintainable code. It is far too easy to write cryptic stuff. Python is very clean and clear (read: in grading, you can easily tell when a person went out of their way in making it cryptic). This is the same reason I don't want them to use Perl, php, or javascript. On the plus side, Python has real world applications and lets your imagination run wild. And it has a very large useful library with interfaces to other software.

    At our school, people come from a multitude of fields (every major has to take this class). Some are expert assembly/C/C++ coders! They shouldn't even take this class, they should just get the damn A. Like me and Pseudo code, you will piss us off to the point where we want to beat the crap out of the TAs. Python will add the most real world value to all of us (unless you are a python expert).

    So overall, Python with its emphasis and philosophy is the better option... IMHO.

  196. Re:I'm just glad they're teaching C++ actively aga by jandrese · · Score: 1

    I thought Java was designed to be run on set top boxes and other such environments. It wasn't until later that it was released as a general purpose language.

    --

    I read the internet for the articles.
  197. Re:I'm just glad they're teaching C++ actively aga by jandrese · · Score: 1

    Heh, I know you're exaggerating for effect, but it seems to me that a great many CS programs are in fact training kids to be CS professors (I guess professors in general tend to teach what they know) instead of instilling lots of job skills that would be useful in the real world. I spent half of my senior year in college learning different ways to prove algorithms correct. In my job, I have never been asked to make a single inductive proof or any kind of proof. I doubt many people do in the real world (it's wildly difficult to do for non-trivial problems and doesn't really mean much of anything most of the time). A lot of the skills I learned are great for writing an academic paper, but pretty much useless for architecting a large project.

    --

    I read the internet for the articles.
  198. Re:I'm just glad they're teaching C++ actively aga by nuzak · · Score: 1

    Too bad if your generic was returned from a method that's in a class in a .jar file, you're back to casting. Generics are pretty much useless unless you're recompiling everything from source. Feel like recompiling Hibernate every time you hit F5?

    --
    Done with slashdot, done with nerds, getting a life.
  199. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    Whoosh.

  200. Re:I'm just glad they're teaching C++ actively aga by Just+Some+Guy · · Score: 1

    Heh, I know you're exaggerating for effect, but it seems to me that a great many CS programs are in fact training kids to be CS professors (I guess professors in general tend to teach what they know) instead of instilling lots of job skills that would be useful in the real world.

    Oh, you think? CS has nothing to do with job skills.

    I spent half of my senior year in college learning different ways to prove algorithms correct. In my job, I have never been asked to make a single inductive proof or any kind of proof.

    I do it all the time. Maybe not formally, but I definitely spend a lot of time convincing myself that functions cannot return unexpected values given any inputs they receive. Sure, it takes me longer to write a single function, but my boss likes that I can turns things out to production rapidly without major problems and that I don't spend all my time rewriting code.

    --
    Dewey, what part of this looks like authorities should be involved?
  201. When Matlab is a Good Thing (TM) by Latent+Heat · · Score: 1
    I know that others think that Joel Spolsky has a high opinion of himself, but he writes in a thoroughly entertaining manner and has some thought-provoking ideas.

    Visual Basic is widely regarded as totally Night of the Living Dead zombified and is held in disdane by anyone who considers themselves a professional programmer, especially by anyone with any C/C++ experience. But what ol' Joel does is he hires who he considers to be the best C++/MFC programmers he can get, and he puts them to work using VB.

    Why does he do this? Because VB, at least for things Joel is interested in, is by leaps and bounds more productive than C++/MFC. Just as you are leaps and bounds more productive using Matlab than the FORTRAN you might have started out with. But why subject C++ programmers to VB when they hate VB? A lot of the reason these dudes hate C++ is they have been told by PHBs to fix someone elses spaghetti VB app, but if you take C++ coders, i.e. people who know the rudiments of programming, the are absolute maestros with VB compared to some financial analyst type hacking together a mess of a VB program.

    I am not contradicting anything you are saying. If you had any kind of background in FORTRAN or whatever the equivalent, Matlab is like the pleasure of taking off shoes that pinch. But if you haven't had that equivalent programming background, Matlab can be like any other programming language to a newbie -- endless debugging to get anything right.

    Why gin up a Matlab substitute for undergrad teaching? One reason is that Python is FOSS while Matlab is not. I am not one of these hyper-partisan FOSS advocates, but on the other hand, I see a kind of conflict of interest situation for turning engineering colleges at public universities into wholly owned subsidiaries of anyone, whether it is Microsoft or Mathworks or whomever.

    A second reason is that Python is a reasonable teaching language regarding OO, data structures, functional programming (to a limited extent) of what are the modern foundations of programming and programming languages and outside the numerical programming domain, Matlab is a dog's breakfast. Someone trained on Python can go off in your direction and be comfortable doing numeric calculations in Matlab or go off in another direction and write C code for an embedded computer system, based on learning some basic concepts that Python supports and Matlab does not.

  202. Re:I'm just glad they're teaching C++ actively aga by JimFive · · Score: 1

    And Computer Engineering != Computer Programming (Software Engineering)

    Computer Engineering is designing and building Computers.
    Computer Programming is contained within, but is not all of Computer Science.
    --
    JimFive

    --
    Please stop using the word theory when you mean hypothesis.
  203. Re:I'm just glad they're teaching C++ actively aga by mikael · · Score: 1

    I was thinking of MFC/.NET. If you want to compile a simple executable, you would have to through all this hassle. If you are in Linux you can just use your favorite editor, edit the file, and very possibly run the compiler from inside the editor.

    --
    Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
  204. Re:I'm just glad they're teaching C++ actively aga by FishWithAHammer · · Score: 1

    Python will add the most real world value to all of us (unless you are a python expert).

    If you're worried about learning a language in a school, you're in the wrong place. That's not the point of a university. If you're looking for that, you belong in a technical college.

    Scheme teaches valuable skills that you simply don't get with something like Python. Functional programming is the logical starting point for teaching programming. "But I already know C, I don't need this" is ridiculous. Lisp/Scheme teach a very valuable paradigm that you will not get with Python or C, and its lessons can be applied to imperative languages once they are learned later.

    --
    "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
  205. Re:I'm just glad they're teaching C++ actively aga by leenks · · Score: 1

    Any enterprise still using Java 1.4 is putting themselves at risk. Java 1.4 end-of-life support from Sun ended ages ago, and Java 5 enters end-of-life support this summer when Java 7 is released.

    Your framework observation is a failure of those frameworks. They should be passing objects by different interfaces that describe the functionality. Generally you should not be relying on instanceof/casting within code - it is ugly and inefficient and suggests a nasty design.

  206. Re:I'm just glad they're teaching C++ actively aga by plague3106 · · Score: 1

    Um, maybe you're just thinking of MFC, because in .Net you do that the same way as the other poster suggested for Java.

  207. Re:I'm just glad they're teaching C++ actively aga by jandrese · · Score: 1

    No, that would be useful. That's not what CS proofs entail. It's more like proving rigorously that function x will always be larger than function y for all positive integers. Or that there is a solution for f(x) for all possible real values of x. Validating inputs has nothing to do with it, even though it kinda sounds similar on the surface.

    --

    I read the internet for the articles.
  208. Re:I'm just glad they're teaching C++ actively aga by zoips · · Score: 1

    Minor thing, but all the cool kids use Avalon/WPF now; Windows Forms is pretty much dead and gone.

    ...doesn't change your statement about cross platformness, sadly; it'd be cool if Mono implemented WPF, but I don't see that happening.

  209. Re:Education, even at Universities, needs to Impro by code4fun · · Score: 1

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

  210. Re:I'm just glad they're teaching C++ actively aga by luke923 · · Score: 1

    Ya, and I'm pretty sure it wasn't to solve engineering problems, but to analyze problems in probability theory that he wrote about. The use of using it, and it's closely related Fourier transform came only about in the 19th century for actual engineering problems.

    That's like saying Rev. Thomas Bayes created an algorithm in 1763 to filter spam...

    --
    "Good, Fast, Cheap: Pick any two" -- RFC 1925
  211. Re:I'm just glad they're teaching C++ actively aga by darrinallen · · Score: 1

    I like to write code from assembly to cobol to Ruby or python

  212. Re:I'm just glad they're teaching C++ actively aga by GWBasic · · Score: 1

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

    Likewise, I had a few professors who didn't write any code. I never took them seriously because they couldn't take their knowledge and apply it to any real situations.

    I remember spending 7 weeks on regular expressions, but never understanding the class because we never actually tried using regular expressions on a text file.

    I remember spending 7 weeks on databases, but finding many of the concepts elusive because the instructor was incapable of using a REAL database.

    A core part of Computer Science is learning how to apply knowledge. Likewise, many parts of Computer Science are best learned by "doing". Teaching any part of Computer Science without being able to implement it is just as bad as teaching a mathematical theory without being able to prove it!

  213. Pot, meet Kettle by CSfreakazoid · · Score: 1

    This is literally the pot calling the kettle black. Stroustrup is absolutely horrible at teaching C++ to beginners. So much so, that at Texas A&M, where he is a professor, he is not allowed to teach lower level classes on his own, because all of his students leave unprepared for the next courses. He claimed to fear not being able to teach the teachers fast enough, In reality, teachers learning the language makes them a better teacher. He has no clue what its like to learn the language, because he never learned it. I say this having learned a language from a teacher who was learning it at the same time. If the teacher is willing to actively learn it, it works. And just because you know it better than anyone Bjarne, doesn't mean you can teach worth a damn.

  214. Re:I'm just glad they're teaching C++ actively aga by HeroreV · · Score: 1

    I really don't think a programming language can be considered functional if it doesn't have closures. I believe C++0x is slated to get closures, but until then, C++ is not functional IMO.

  215. Re:Education, even at Universities, needs to Impro by potsee · · Score: 1

    I think the exponential rate of the advancement in technology puts huge demands on current CS programs. Unlike more traditional academia, I feel CS more than any other field is under constant pressure to make sure their students are familiar with the relevant language, design pattern, etc. I feel this causes the programs to drift away from the important foundations of problem solving, mathematical proficiency and ability to break down large problems into manageable pieces. I feel these skills are what I profited most from in pursuing my degree. This also means students will graduate with little practical experience but sharpened analytical skills. There's just not enough time to teach everything!

    And now for my rant for you already in the industry:

    I feel there is a disconnect between employer expectations and what knowledge a graduating possesses. I see so often in this forum people fuming that a new graduate dosen't know this technology or hasn't heard of this protocol, or their coding style is inferior. It takes time for programming skill to mature and there is no one path to becoming successful with a CS degree. Instead of doing surveys about what books people read why don't you try and convince them of the benefits of reading such a book instead of snickering and feeling superior. (I haven't heard of the K&R white book either)

    Maybe I'm just another one of those dumb cs students being churned out by your run of the mill university. Its true I wasn't confronted with pointers until me junior year but I was able to grasp it.

  216. Re:I'm just glad they're teaching C++ actively aga by Fulcrum+of+Evil · · Score: 1

    protected abstract virtual base pure virtual private destructor

    Is it protected or private? Is it virtual or pure virtual? That declaration makes no sense, and I'd shoot anyone who used it.

    --
    "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
  217. Re:I'm just glad they're teaching C++ actively aga by odourpreventer · · Score: 1

    I tried to find a PM button to address you directly, but anyway:

    I often have trouble with containers, to pick a specific issue. Since they store Object:s, I can never be sure what they contain, and after retrieving an element it has to be casted. I've seen someone mention that this can be solved with reflection, and there's supposed to be a template mechanism, like Vector<MyClass> for instance. I haven't been able to make good of any of those though, and I have never seen any existing code making use of those mechanisms.

    Another problem for me is element manipulation. The only way I've been able to alter a container elemenent is extracting it and deleting it from the container, make the changes and then putting it back. Which is fine for smaller structures, but when the container has tens of thousands of elements of a few hundred bytes each, and each needs to be changed, then the problems start.

    If you have any pointers to share, I'd be happy to get them.

  218. Re:I'm just glad they're teaching C++ actively aga by mog007 · · Score: 1

    My university's introductory C.S. course is Java, but it's extremely basic, just offering knowledge on functions, and such.

    So far, every programming class after that has been in C, and with the exception of the introductory class, use of Java in any class is purely an elective course.

  219. D Language by Anonymous Coward · · Score: 0

    I thought C++ developers were aware of the D Language: http://www.digitalmars.com/d/

    BCPL -> B -> C -> C++ -> D

  220. Re:I'm just glad they're teaching C++ actively aga by Anonymous Coward · · Score: 0

    and it's closely related

    "its".

  221. Re:I'm just glad they're teaching C++ actively aga by Gordonjcp · · Score: 1

    Funny, I've just picked up a copy of TAOCP to read on the train. I think I'll bring K&R instead, now.

  222. Re:I'm just glad they're teaching C++ actively aga by Neo+Quietus · · Score: 1

    At my school JAVA is the main language used, especially at the lower levels, but there are required courses in C, UNIX (part of the C course) and MIPS assembly. One of the elective courses is C++.

  223. Curriculum needs less distractions by mich.linux.guy · · Score: 1

    Some educators will point out that all of that - together with ever-popular and useful topics such as graphics and security - doesn't fit into a four-year program for most students. The computer science degree curriculum needs more focus on computer science and less on "general education". I see way too many CS students graduating with a lack of skill in object oriented design and software development process.
    I know I could have done without a lecture on the role of woman in a phallocentric order during a film course to satisfy art & diversity requirements.