Slashdot Mirror


The Future of C++ As Seen By Its Creator

holden writes "In a rare public talk, C++ creator Dr. Bjarne Stroustrup discusses his ideal in programming languages, as well how he sees the next version (and beyond) of C++ developing. He explains the general selection criteria used for adding new features, some of the legacy of C++, and many other interesting topics. Especially interesting is during the Q&A he explains his views of the embrace and extend mentality some implementations, such as VC++, have taken."

90 of 424 comments (clear)

  1. uh... by cosmocain · · Score: 4, Insightful

    ...transcript, anyone? i hate watching or listening to vids at work.

    1. Re:uh... by neonmonk · · Score: 4, Funny

      Agreed. I don't see the point in video unless they're actually showing up some fancy technology. ...Or, alternatively, they've got really nice jugs.

    2. Re:uh... by LiquidCoooled · · Score: 5, Funny

      Good afternoon everybody, I would like to start by including iostream.h into the discussion.

      After this we can get onto the main proceedings which might or might not return anything.

      We move to the future by emitting a string of "Hello world" before returning zero.

      This is the end of the discussion I hope it was informative.

      --
      liqbase :: faster than paper
    3. Re:uh... by Pseudonym · · Score: 5, Insightful

      Good afternoon everybody, I would like to start by including iostream.h into the discussion.

      That ruined the joke for me. Like Stroustrup would ever include the legacy non-namespaced header!

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    4. Re:uh... by smittyoneeach · · Score: 2, Funny

      Stroustrup is an academic. Blowing by petty details for pedagogical reasons is a time-honored device.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    5. Re:uh... by larry+bagina · · Score: 5, Funny

      exception: slashdot editors.

      --
      Do you even lift?

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

    6. Re:uh... by Odin's+Raven · · Score: 5, Funny

      Good afternoon everybody, I would like to start by including iostream.h into the discussion.

      That ruined the joke for me. Like Stroustrup would ever include the legacy non-namespaced header!

      I'm sure he only did that to ensure compatability with older members of the audience.
      --
      A marriage is always made up of two people who are prepared to swear that only the other one snores.
    7. Re:uh... by Mr.+Underbridge · · Score: 4, Funny

      I'm sure he only did that to ensure compatability with older members of the audience.

      Then the joke should have been in COBOL.

    8. Re:uh... by cerberusss · · Score: 5, Funny

      Here ya go, buddy.

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

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

      Interviewer: Problem?

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

      Interviewer: Of course, I did too

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

      Interviewer: Those were the days, eh?

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

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

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

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

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

      Interviewer: You're kidding...?

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

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

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

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

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

      Interviewer: So how exactly did you do it?

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

      Interviewer: What?

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

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

      Stroustrup: There you are then. Mind you, a few tried, in the early days. There was this Oregon company - Mentor Graphics, I think they were called - really caught a cold trying to rewrite everything in C++ in about '90 or '91. I felt sorry for them really, but I thought people would learn from their mistakes.

      Interviewer: Obviously, they didn't?

      Stroustrup: Not in the slightest. Trouble is, most companies hush-up all their major blunders, and explaining a $30 million loss to the shareholders would have been difficult. Give them their due, though, they made it work in the end.

      Interviewer: They did? Well, there you are then, it proves O-O works.

      Stroustrup: Well, almost. The executable was so huge, it took five minutes to load, on an HP workstation, with 128MB of RAM. Then it ran like treacle. Actually, I thought this would be a majo

      --
      8 of 13 people found this answer helpful. Did you?
    9. Re:uh... by StarReaver · · Score: 3, Funny

      Reduce the language to just one word for everything and you'll be fine. If there were only
      One word per definition
      Haiku would be dull.
    10. Re:uh... by afidel · · Score: 2, Insightful

      As someone who's used C++ since it was a collection of precompiler directives I LOL'd, but you really should give credit to the original author.

      --
      There are 4 boxes to use in the defense of liberty: soap, ballot, jury, ammo. Use in that order. Starting now.
    11. Re:uh... by Otter · · Score: 2, Insightful
      Why in the hell do you need both restful and restless to mean the same thing?

      They don't remotely mean the same thing. (Putting aside that you then go on to demand that more words mean the same thing.)

    12. Re:uh... by cerberusss · · Score: 4, Informative

      This thing's been forwarded around the net without the original author attached. However, I think I tracked it down to cddukes@unity.ncsu.edu... Any readers correct me if I'm wrong.

      --
      8 of 13 people found this answer helpful. Did you?
    13. Re:uh... by Surt · · Score: 2, Informative

      http://mw1.merriam-webster.com/dictionary/restful
      1 : marked by, affording, or suggesting rest and repose
      2 : being at rest : quiet

      http://mw1.merriam-webster.com/dictionary/restless
      1: lacking or denying rest : uneasy
      2: continuously moving : unquiet
      3: characterized by or manifesting unrest especially of mind ; also : changeful, discontented

      --
      "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
    14. Re:uh... by epee1221 · · Score: 4, Funny

      Reduce the language to just one word for everything and you'll be double-plus good!

      --
      "The use-mention distinction" is not "enforced here."
    15. Re:uh... by Hoi+Polloi · · Score: 2, Funny

      I skipped that meeting when I saw it was void. Can't get anything out of those things.

      --
      It is by the juice of the coffee bean that thoughts acquire speed, the teeth acquire stains. The stains become a warning
    16. Re:uh... by djw · · Score: 2, Informative

      restful and restless
      I think you mean restive and restless. But they don't mean quite the same thing.
    17. Re:uh... by Anonymous Coward · · Score: 5, Funny

      COBOL is already a joke.

    18. Re:uh... by garoo · · Score: 2

      Reduce the language to just one word for everything and you'll be fine.

      Linguistics is way ahead of you here...

      "I'm a linguist. My job is to make communication simpler. I invented a language with no grammar, no syntax, no ambiguities. In fact, it had only one word: CHICKEN."

      Also note the recently published paper on this topic, "Doug Zongker, "Chicken Chicken Chicken: Chicken Chicken", Annals of Improbable Research, 12(5) September-October 2006, 16-21, and the associated presentation.

      I don't know where linguists get their ideas from but I wish I had a supplier :-P

  2. Embedded video? no thanks by JosefAssad · · Score: 2, Funny
    At least we won't get any "RTFA, moron!" comments in this article.

    But seriously, I like slashdot because, unlike digg, we get ARTICLES, not videos. I'm not watching this. In protest, here's a completely misinformed and irrelevant comment which extrapolates a lot of very outlandish conclusions from the article summary:

    Stoustrup just wants to make sure VC++ doesn't eat into the market share of his new linux-powered RC car, CTTOX. He has been embracing and extending C ofr many years now; if congress weren't so impeachment-obsessed, they would have slapped him with anticompetitive sanctions. What is a doctor doing talking about languages anyhow, he should leave that to linguists like Alan Cox and stick to paediatric medicine.

    Or, to rephrase, give me text links or give me fatal and catastrophic loss of message and meaning

    1. Re:Embedded video? no thanks by neonmonk · · Score: 3, Funny

      Don't you mean WTFV?

  3. Mod Parent Insightful by dreamchaser · · Score: 5, Insightful

    Video or audio just for the sake of being flashy is a dumb idea and I usually won't watch or listen. If I want audio and video I'll devote my full attention to my TV feed. Otherwise when I'm accessing information on the Internet I want text. I can read it far faster than someone speaks on a video interview for one thing, and for another text lends itself far better to (human)multitasking than video or audio does.

    1. Re:Mod Parent Insightful by nschubach · · Score: 3, Funny

      i cumpleetly understand wut ur sayin. its much esyer to reed things on teh internets than it evar wuz be4.

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
  4. In other news. by Anonymous Coward · · Score: 3, Funny

    The future of BASIC has been envisioned as a language to do more and more intricate beeping loops in high school classes.

  5. Next version? by tygerstripes · · Score: 4, Funny

    Great - I've been hearing a lot about C-Pound.

    --
    Meta will eat itself
    1. Re:Next version? by netpixie · · Score: 2, Insightful

      That's a weird article.

      Why is this candidate "bad" because he interprets a piece of marketing twaddle (i.e. the name of C#) in a different way from Bill?

      Round here we (mostly) purposefully call things the wrong name, usually as an exclusive in-joke because we all really know what the real term is meant to be. This includes Giga- pronounced "jigga-" and internet called "interweb" or "interwebnets". My favourite is referring to C# as "coctothorpe" as the proper name for the # symbol is octothorpe. I also used to call C++ "C double plus" as "plus plus" just sounds so ugly (and I'd just finished reading 1984 when I started programming).

      This candidate may be useless for other reasons (and it looks like he is), but calling a silly programming language with a silly name something silly shouldn't be held against him.

    2. Re:Next version? by nwbvt · · Score: 3, Interesting

      Well for starters, your pet name for a programming language is not something you should continuously use while in a job interview. Basically what it tells the interviewer is that you really have very little experience with it, and probably have never heard it spoken before.

      --
      Mathematics is made of 50 percent formulas, 50 percent proofs, and 50 percent imagination.
  6. Torrents of vid available by Anonymous Coward · · Score: 4, Informative

    Please use the torrents, and keep those torrent up and running after you're done d/l'ing.

    http://csclub.uwaterloo.ca/files/stroustrup.ogg.to rrent Ogg/Theora (Recommended)
    http://csclub.uwaterloo.ca/files/stroustrup.avi.to rrent XviD
    http://csclub.uwaterloo.ca/files/stroustrup.mp4.to rrent MP4
    http://csclub.uwaterloo.ca/files/stroustrup.mpg.to rrent MPEG

    AC to prevent karma whoring.

  7. The problem with VC++ by PhrostyMcByte · · Score: 5, Insightful

    Is that they have given 95% of the development time toward managed languages.

    If you look at the new Visual Studio 2008 - in the three years since 2005 was released, what does Orcas have for C/C++? Still no C99, with open admission that there are no plans to support it. No TR1 for C++. No significant compiler changes. Intellisense is still slow and quite easily stops working all together. Still no assembly support in the 64-bit compiler, missing intrinsic functions for important instructions such as CMPXCHG16B.

    What we get is a newer bundled Windows SDK (which you can download NOW), updated MFC libraries (yuck), and a few new options for Vista compatibility.

    In three years, .NET has advanced from 2.0 to 3.5 with huge changes like WPF, WCF, LINQ, etc. They have all but forgotten C++.

    1. Re:The problem with VC++ by Jugalator · · Score: 4, Informative

      This discussion came up again with Visual Studio 2008 "Orcas" and plans seemingly a bit lacking once again for an improved C++ feature set and general love for IntelliSense, etc.

      Microsoft had the following to say:
      http://forums.microsoft.com/MSDN/ShowPost.aspx?Pos tID=970938&SiteID=1

      See bdunlap's response.

      --
      Beware: In C++, your friends can see your privates!
    2. Re:The problem with VC++ by rbanffy · · Score: 2, Informative

      It's clear that Microsoft is not interested in the future of C++.

      They more or less own the market for C# and IDEs for .NET. Why would they still be interested in something that could be used to migrate away from Windows?

      BTW, it's really hard to migrate a Windows C++ program away from Windows. A Windows C++ program may be legal C++, but is something horridly deformed and barely recognizable.

    3. Re:The problem with VC++ by Anonymous+Brave+Guy · · Score: 4, Insightful

      If you look at the new Visual Studio 2008 - in the three years since 2005 was released, what does Orcas have for C/C++?

      I'll see you VC++ 2008 and raise you VC++ .Net (aka VC++ 7.0, aka the 2002 release).

      The sad thing is, from a pure C++ programmer's point of view, a lot of people still regard VC++ 6 as the peak. Sure, the standards compliance is better now, and that's a real improvement. Sure, there have been a few optimisation improvements, and those are worthwhile (when they don't introduce bugs). Sure, the debugger has better visualisation support (autoexp.dat) even for native code, and that's definitely useful (if only they'd document it properly).

      But when they moved to .Net for everything, the IDE slowed down horribly, even without the Intellisense/multi-threading mess that they finally fixed in 2005SP1. Certain features (I'm looking at you, browse toolbar) actually disappeared from VC++, for the rather poor reason that they couldn't be supported in all .Net languages. I understand that the whole unified architecture thing makes sense from a development perspective at Microsoft, but the bottom line is that users don't care, and removing useful functionality is bad. I also appreciate that, several versions later, we now have most of the same basic functionality back again, but it's still a mess compared to the simple, effective browse toolbar. Similar comments apply to various being-too-clever changes to Intellisense, incidentally.

      Perhaps more seriously, as great as all these new optimisations are, we've found far more compiler bugs recently than we ever used to. We write serious mathematical libraries at work, and I promise you it is not fun to spend several days tracking down a bizarre floating point problem, because it turned out that the global optimiser got it wrong fifteen functions up the call stack and now the FPU stack is overflowing.

      Meanwhile, we get to see Microsoft putting lots of goodies in for .Net developers. I'm sure they'd love us all to develop for .Net, but until they support it on seven different platforms (where all versions of "Windows" are grouped together as just one of those), it's never going to be of much interest to us.

      Right now, Visual C++ is still (in my personal opinion) the best C++ compiler/IDE combination available today. But things move fast in software. Code compiled with g++ has lagged in performance for a long time, but if the recent work behind the scenes on things like SSA bears fruit, that performance gap could close very fast. Eclipse/CDT is so clunky as to be almost unusable for C++ development right now (don't flame me, it's just a personal opinion) but I check every now and then to see how things are going and it sounds like someone might be planning a big clean-up so it doesn't feel like C++ forced into a Java-friendly IDE any more. With Microsoft pushing all their funky new UI support into things like WPF that almost no-one uses, and portable GUI toolkits like wxWidgets and Qt becoming better all the time, it's not like having MFC support is a great bonus for new developments anyway.

      In other words, if VC++ 2008 doesn't deliver real improvements for non-.Net-only C++ developers, it's entirely possible that the serious players will be switching to genuinely better open source alternatives for new developments well before the next version of VC++ is out. And that should scare Microsoft, because the superiority of VC++ and the ease of use of VB are the reason so many people have been making effectively Windows-only software for so long.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    4. Re:The problem with VC++ by Blakey+Rat · · Score: 2, Insightful

      Good. I think languages with some kind of automatic memory management are the future and make development easier for software houses, which in turn gives them more time worrying about issues like, "will my grandma be able to use this software?" and less time worrying about issues like, "why does it crash when this pointer is dereferenced!?"

      Not that I have anything against C or C++, but for applications (i.e. anything made by Visual C++) I don't think it's an ideal language. We've (as an industry) wasted too much time getting it working with a modern GUI environment already, let's move on. Make fun of VB or C#, or even Obj-C/Cocoa if you want, but all those languages are designed, and excel, for GUI software development.

    5. Re:The problem with VC++ by spectrokid · · Score: 2, Informative

      intrinsic functions for important instructions such as CMPXCHG16B
      You know you have a sucky language when your important function is called CMPXCHG16B (not to be mistaken with that other little SOB, the good ole CMPCHXG16B)
      --

      10 ?"Hello World" life was simple then

    6. Re:The problem with VC++ by Bluesman · · Score: 2, Funny

      Yeah, what's with all these weird functions like CMPXCHG, XOR, MOVS, and PUSH?

      That Windows C++ stuff, boy, it sure is weird!

      --
      If moderation could change anything, it would be illegal.
    7. Re:The problem with VC++ by lordSaurontheGreat · · Score: 2, Informative

      Eclipse/CDT is so clunky as to be almost unusable for C++ development right now (don't flame me, it's just a personal opinion) but I check every now and then to see how things are going and it sounds like someone might be planning a big clean-up so it doesn't feel like C++ forced into a Java-friendly IDE any more.
      As a die hard Eclipse fan I have to violently agree with you. Eclipse is brilliant at Java development and gives poor little netbeans more than a run for its money in every respect except for the integrated profiler. But the Eclipse CDT is horrifically lame. I tried it. It had a bunch of things Eclipse-like that I enjoyed, but it was just so slow and unpolished that it didn't have the extra mile that we all associate with the Eclipse Quality.
      Bravo to you for recognizing crap in a otherwise golden framework. Many others wouldn't have your vision to recognize the garbage in the goldmine.
      --
      Consider yourself spoken to.
  8. Re:Just one thing by PhrostyMcByte · · Score: 2, Informative

    C++ has adopted Boost's function class in the TR1 library - you will be able to use std::function, etc. No more member function pointers if you don't want them.

  9. Re:C Plus Plus Bye Bye by Omni-Cognate · · Score: 4, Informative

    Not that job listings are a particularly good indicator of anything, but from Monster:

    The C++ ones include plenty of new systems.

    --

    "The Milliard Gargantubrain? A mere abacus - mention it not."

  10. Parent is trolling by Interfacer · · Score: 3, Informative

    C99 is driven by customer demand. And I don't mean as in a bunch of geeks saying 'implement ALL of C99 now!' but as in they work with their enterprise customers to prioritize features.

    TR1 WILL be supported as soon as C++0x is finalized. Not sooner. If they would implement is now, it would likely change as soon as the new standard is ratified. Of course, even if they would implement now, you would criticise them as soon as the standard is ratified because ZOMG! Microsoft's TR1 is proprietary and out of date! LOLOLOLROFLMAO!
    I suspect they will simply license TR1 from dinkumware which is feature complete with the current state of TR1.

    Intellisense is a dog. People are working on it, and a lot of redesign is going on. Not just for intellisense, but for the whole compiler architecture to make it more scalable and plufable.

    And I don't know where you are getting your info from, but asm is perfectly supported in 64 bit. Just inline assembly isn't because for 64 bit code this would make it non-portable between different 64 bit architectures.
    You can still add asm files to your VC++ project and compile them.

    And you can say yuck to MFC and I would agree. But a very large number of enterprise businesses still builds massive VC++ applications that use it extensively. maintaining and improving it makes lots of business sense.

    And finally, C++ is not meant to be as RAD as C# and VB because that would require a lot of manpower which cannot be justified. VC++ is targeted for interoperability, performance and control over the program execution. Not for whipping up a data driven LINQ doc. People who want to use LINQ would simply build a C# project for data interaction and add it to their mixed mode C++ project.

    1. Re:Parent is trolling by PhrostyMcByte · · Score: 3, Interesting

      These are complaints, not trolls. I develop primarily in C++ and am ecstatic about C++0x, and dread seeing my favorite IDE/compiler get put on the backburner and not implement modern unmanaged programming. I don't want to wait 10 years to see C++0x and TR1. They could have easily included Dinkumware's TR1 implementation with it, even in a seperate tr1 namespace, and be sure - everyone would be much much happier.

      C++ was not meant to be RAD like C#, but VC++'s compiler and IDE are _far_ from perfect. There are still several annoying little issues you come across when you play with real C++. My point was that there is so much room for improvement in the C++ compiler but they have completely neglected it and the IDE to implement features for their proprietary languages. Which all in all, this being Microsoft, is not that surprising - but it is still a shame.

      You got one thing right - I did mean inline assembly (sorry, typos happen). It would be just as non-portable as using seperate .asm files - the functionality was there in the x86 compiler, am I to assume they completely rewrote the compiler enough that it would take vast effort to enable this basic functionality for x64?

    2. Re:Parent is trolling by PhrostyMcByte · · Score: 2, Insightful

      A lot of C++ developers are fans of header-only libraries. What can I say, I am too - it makes use of these libraries so much easier. Having assembly files breaks this when writing a library.

      I agree that a good developer will almost never need to use assembly. Unfortunately there are some (very few, but still some) things you just can't do efficiently in C++ - be it a limitation of the language or the compiler.

      Believe me, I wish Microsoft could implement intrinsic functions for everything I need (like CMPXCHG16B mentioned previously). But they don't. I want nothing more than to not have to touch assembly!

    3. Re:Parent is trolling by MORB · · Score: 2, Interesting

      Bullshit. They could (should) start implementing TR1 and even parts of C++0x right now so that they can have a fully compliant implementation shortly after the standard is officially released. That's what gcc is doing. It also helps the stadndardization process because they can see whether the current draft has serious issues and fix them.
      gcc has a TR1 implementation and they have started implementing some of the c++0x features (that should be enabled explicitely on the command line)

      In any case, VC++ majorly sucks. It's slow (and gets significantly slower at each new version), takes ages to do elementary things (I've seen it take 10 to 20 seconds to open a fucking text file - and a small one at that), has a sucky interface (as of vs2005, the project properties dialog was still not resizeable and full of small text fields meant to contain lots of data, like list of libraries. And don't even get me started on the project configurations dialog), don't really have any features not found anywhere else and they don't even work that well (how easily the code completion system fails). To do anything really useful like some automated refactoring operations, you have to install a third party tool (visual assist)

      The project management, with its file/directory hierarchy which is not taken directly from the file system, is completely stupid and annoying (I worked at a MMORPG company on a solution containing dozens of project, and the hierarchy layout in visual studio and the file system were completely different, a fucking nightmare)

      It also don't play well with version control tools, because it like to save the contents of the xml in project files in a different order each time, so even a trivial change will show lots of diffs in version control, making it impossible to figure out which compilation setting was changed frmo a version to another, for instance.

      I don't know, I just can't find any redeeming feature in this IDE. As far as I'm concerned, when it comes to C++ it's a worthless piece of shit that is only used out of market inertia. It used to be alright, but the performance went down while the features stayed roughly the same except for those awesome 3d toolbars, so now it just doesn't seem to be worth its (rather high) price point compared to free alternatives like eclipse/cdt (or even kdevelop 3.4 if it was available for windows).

      And don't come to me saying that a free version is available, its irrelevant to the professional world which have to pay for the dubious privilege of using this thing.

    4. Re:Parent is trolling by MORB · · Score: 2, Informative

      You can use eclipse/mingw, code::blocks, etc.
      Alternatives are out there if you take the effort of using google.

      Your apathetic comment demonstrates what I meant by "market inertia".

  11. With all respect... by 2Bits · · Score: 2, Insightful

    to Stroustrup, but don't you think it's a bit ironic that the creator of such a monstrosity is talking about ideal of programming languages? And don't even get me into the the differences between implementations!

    Yeah, go ahead, bring out your flame hose. Even if I had to burn in hell, this thing is still a monstrosity.

    1. Re:With all respect... by ardor · · Score: 2, Informative

      C++ is far too complex yes. But there is nothing that can really replace it. A language which supports functional, generic, procedural, object-oriented programming, with static typing, metaprogramming, and heavily geared towards native building? I mean, do you know a language which can resolve iterators to simple pointer arithmetic when compiling? Of course there are far better languages feature-wise, but they all demand some performance penalties. This may or may not be relevant. For example, for video codecs its relevant, as it is for most other realtime stuff (try capturing with Java and its GC for instance).

      So, C++ fills a niche. D *may* be a replacement, but I am skeptical. I don't know Eiffel well enough though, this may be a good candidate.

      And lets not forget that C++ toolchains are among the most optimized and tested ones. For example, Lisp could be able to reach C++ performance, but doesnt simply because the Lisp toolchains arent as optimized. A simplified example: sometimes SBCL does register->memory->operation->register calls, where g++ optimizes to register->operation. And, the amount of C++ code in existence is staggering.

      --
      This sig does not contain any SCO code.
    2. Re:With all respect... by Dr.+Manhattan · · Score: 2, Interesting
      C++ isn't just "too complex". It's "so overly complex that it becomes a real problem." From The Art Of Unix Programming: "Compactness is the property that a design can fit inside a human being's head. A good practical test for compactness is this: Does an experienced user normally need a manual? If not, then the design (or at least the subset of it that covers normal use) is compact... C++ is anti-compact -- the language's designer has admitted that he doesn't expect any one programmer to ever understand it all."

      With all the libraries and the plethora of features, it also has a large measure of Perl's problem: "Some designs that are not compact have enough internal redundancy of features that individual programmers end up carving out compact dialects sufficient for that 80% of common tasks by choosing a working subset of the language. Perl has this kind of pseudo-compactness, for example. Such designs have a built-in trap; when two programmers try to communicate about a project, they may find that differences in their working subsets are a significant barrier to understanding and modifying the code."

      The summary, here: "When all is said and done, however, C++'s most fundamental problem is that it is basically just another conventional language. It confines the memory-management problem better than it did before the invention of the Standard Template Library, and a lot better than C does, but the confinement is brittle; it breaks unless your code uses objects and only objects. For many types of application its OO features are not significant, and simply add complexity to C without yielding much advantage. Open-source C++ compilers are available; if C++ were unequivocally superior to C it would now dominate... Consider using C++ if an existing C++ toolkit or service library offers powerful leverage for your application, or if you're in one of the application areas mentioned above for which an OO language is known to be a large win."

      --
      PHEM - party like it's 1997-2003!
    3. Re:With all respect... by hr.wien · · Score: 2, Interesting

      Why does everyone coding OO in C++ seem to think you need to new and delete every damn object? Use the stack and the RAII pattern whenever possible (which, in my experience, is most of the time). It'll make your code both cleaner and safe from resource leaks.

    4. Re:With all respect... by baadger · · Score: 2, Informative

      Let's not forget that you can actually overload the "new" and "delete" operators and drop in your own memory allocator if you wish...

    5. Re:With all respect... by k-zed · · Score: 2, Insightful

      "A language which supports functional, generic, procedural, object-oriented programming, with static typing, metaprogramming, and heavily geared towards native building?"

      Yes. It's called LISP. (Also Scheme, and maybe even OCAML.)
      There are optimizing LISP compilers that beat C/C++ at floating point calculations. Plus C, and all the new trendy MS .NET crap has nothing on the syntax and expressive power LISP has. But good things and good directions aren't exactly "in fashion" in today's IT...

      --
      we discovered a new way to think.
  12. Re:C Plus Plus Bye Bye by ardor · · Score: 3, Interesting

    If you really understand C++, migrating to C# is very easy. C#->C++ however...

    but, if we talk about managed languages, I'd go straight for Python or Common Lisp.

    --
    This sig does not contain any SCO code.
  13. Re:scratch that itch by mwvdlee · · Score: 2, Funny

    I'd much rather prefer speechtotext in this particular case, but to each his own.

    --
    Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
  14. Re:Just one thing by Pr0xY · · Score: 2, Informative
    you can easily get the same effect as the java "interface" mechanism bu supplying a class which contains only pure virtuals (and a virtual destructor). For example:

    class AnimalInterface {
    public:
        virtual ~AnimalInterface() {}
    // note the = 0; on the next lines, that means "pure virtual"
    // pure virtual means "no implementation here, a child class must implement
        virtual void eat() = 0;
        virtual void poop() = 0;
    };
     
    class Monkey : public AnimalInterface {
    public:
        virtual void eat() { std::cout << "monkey eating!\n"; }
        virtual void poop() { std::cout << "monkey pooping!\n"; }
    };
    if a class inherits from AnimalInterface and fails to implement eat or poop, it will result in a compiler error, this the child class must implement the "interface" supplied by the parent class. And just like java, this is safe with regard to multiple inheritance because the pure virtual functions have no implementation, which means no ambiguity with regard to which parent function to call.
  15. 3...2...1... by kazade84 · · Score: 2, Funny

    and let the syntax criticizing begin ;)

  16. not bad... by rgravina · · Score: 5, Interesting

    Recently, I've just started getting into C++, and I can't understand why so many people hate the language with such a passion. The thing is, if you need/want to write your program in a compiled language with plenty of library support, then aside from C, what options are there? I'm not trying to start a flamewar, but I figure if I want to say use C (or other C++) libraries and a compiled language then I feel C++ is much better option than C. One very smart and experienced C programmer I know hates C++ with a passion complaining that "it's too complex" and just rejecting it outright.

    I haven't yet written (or debugged) any large programs in C++, so that could be why I'm still enthusastic. Perhaps after some time with the language I might see what everyone is so worked up about.

    I'm reading through "Effective C++" by Scott Meyers, and although the language seems like it has its warts and complexity, it also offers a great deal of power and is a hell of a lot more fun to program in than C because you get the abstraction support of objects, namespaces etc. Streams - awsome. Shared (reference counting) pointers - awsome. Less need for the preprocessor - awsome. And the standard library (plus Boost too) is so vast... containers, algorithms, it's all there.

    Python is still my favourite general-purpose language, but if I need something compiled, then I don't see what is so bad about C++. Sure, Objective-C is a far better approach to the "lets-make-a-better-C" idea, but I'm not sure how to use it (and the standard library) outside of OSX or GNUStep.

    1. Re:not bad... by Anonymous Coward · · Score: 2, Insightful
      C++ seems to have been designed by someone who hated C.
      C++ is anti-C (should have been named ~C):
      • is complex where C is simple
      • hides what's going on, to the extent that you
        can't tell what's going to happen just by looking at code
        (you have to look way behind the scenes
      • has implementations which are diverging, not converging
    2. Re:not bad... by Random832 · · Score: 4, Funny

      (should have been named ~C) And Godwin's law has been invoked/fulfilled/whatever.

      --
      We've secretly replaced Slashdot with new Folgers Crystals - let's see if it notices.
    3. Re:not bad... by odourpreventer · · Score: 2, Insightful

      The problem is that there are so many ways to do things wrong in C++. Writing proper code takes experience. It doesn't help either that monsters like MFC easily mess things up.

      I was going to quit coding C++ when I discovered Boost and wxWidgets. Now I don't want use anything else.

    4. Re:not bad... by rgravina · · Score: 2, Interesting

      D looks very very interesting. I just had to use C++ for my current project for a few reasons (needed to work with wxWidgets and create a library which is accessable from as many languages as possible - so a C++ and maybe a Python wrapper a some point (using SWIG, or Boost.Python, I suppose).

  17. Re:Just one thing by smellotron · · Score: 2, Interesting

    The main benefit of Java interfaces is that you can have a single class implement multiple interfaces without having to resort to something like C++'s multiple inheritance. So the Monkey class can also implement HairyInterface, EvilInterface and SlingInterface.

    The main benefit of C++ abstract classes is that you can have a single class inherit from multiple abstract classes without having to resort to something like Java's interfaces.

    You think multiply inheriting from a bunch of C++ abstract classes is somehow worse than implementing multiple Java interfaces? Abstract classes are interfaces, and inheriting from an abstract class is identical to implementing an interface. All of the problems you hear about for the evils of multiple inheritance go away when you start talking about pure abstract classes. There's no worrying about "which parent class method will be active when they have identical signatures" since there aren no parent methods.

  18. Watch the video by dysfunct · · Score: 2, Interesting

    As an autodidact I'm easily bored by overly long and dry technical presentations of what could be read through in a couple of minutes, but this video is getting very interesting and funny after the first couple if minutes. Lots of insight into the process of creating the new standards and and all the thoughts that go into it, mixed with anecdotes, random trivia and geek humor by Bjarne Stroustrup himself. I'm actually considering downloading the 700mb xvid version of the talk and making me some popcorn to go with it. IMO, even if you're not a C++ geek it's actually worth watching.

    --
    :/- spoon(_).
  19. The Future Is Already Here... by ezdude · · Score: 2, Funny

    And it looks something like Haskell. Static typing, lazy evaluation, high-level parallelism, pure functionality, explicit imperative-ness. Heck, monads even sound like something from the future.

  20. C++ needed improvements several years ago. by Futurepower(R) · · Score: 3, Informative

    Dr. Stroustrup made a great contribution by designing the C++ language. However, in recent years it seems to me that he has been taking a leisurely approach to making improvements.

    Stroustrup is, unlike most programmers, an excellent writer. His FAQ is an example. Quote: "What's a good certification for C++ programmers? To the best of my knowledge, there isn't a good certification program for C++ programmers. That's a pity. A good certification program would be most useful. However, C++ lacks the central organization that would produce a solid certification program, and a certification program without authority or that focused on syntax would be worse than useless."

    I'm certainly not an expert in this subject. However, I get the same impression from the words "C++ lacks the central organization" in that paragraph that I get from his other recent work. Something like, "What, me be a leader?"

    Note that Java and C#, which are sometimes seen as replacements for C++, are proprietary languages from companies that are routinely mismanaged. If you use those languages, you partner with those companies, and it is possible that you too will suffer from their mismanagement. For that reason, there is a big need for strong leadership in maintaining a language unencumbered by issues of proprietary behavior.

    Concerning Java, Dr. Stroustrup says "Java isn't platform independent; it is a platform. Like Windows, it is a proprietary commercial platform. That is, you can write programs for Windows/Intel or Java/JVM, and in each case you are writing code for a platform owned by a single corporation and tweaked for the commercial benefit of that corporation."

    Concerning C#, he says, "It will take a lot to persuade me that the world needs yet another proprietary language (YAPL). It will be especially hard to persuade me that it needs a language that is closely integrated with a specific proprietary operating system."

    Again, I'm not an expert in this area, but it seems to me that Dr. Stroustrup tends to define his leadership narrowly and concern himself with programming constructs rather than larger issues such as extension, standardization, and certification of libraries, for example. About C++ garbage collection he says, partly: "See ... Hans-J. Boehm's site". It seems to me that there are too many areas in which the C++ answer is "You can just go there", rather than "This is the standard, certified method."

    It's amazing to me, but true leaders are very rare. After all these years, we still depend on Dr. Stroustrup, even though he has been less than a complete leader in the more social aspects of developing the C++ language, in my opinion.

    1. Re:C++ needed improvements several years ago. by teknopurge · · Score: 2, Insightful

      Concerning Java, Dr. Stroustrup says "Java isn't platform independent; it is a platform. Like Windows, it is a proprietary commercial platform. That is, you can write programs for Windows/Intel or Java/JVM, and in each case you are writing code for a platform owned by a single corporation and tweaked for the commercial benefit of that corporation." Boy, he must be very happy about openJDK. I wonder what his next gripe will be about Java?
    2. Re:C++ needed improvements several years ago. by canuck57 · · Score: 2, Insightful

      Again, I'm not an expert in this area, but it seems to me that Dr. Stroustrup tends to define his leadership narrowly and concern himself with programming constructs rather than larger issues such as extension, standardization, and certification of libraries, for example. About C++ garbage collection he says, partly: "See ... Hans-J. Boehm's site [att.com]". It seems to me that there are too many areas in which the C++ answer is "You can just go there", rather than "This is the standard, certified method."

      You left out his quip about how C# and Java leave twice as many resources open at run time and something about sloppy programing. A run time GC is not something I believe is needed in C++. If you want that, write it in Java and live with the associated bloat. Or pull in someones library that does the same thing. An example: http://www.hpl.hp.com/personal/Hans_Boehm/gc/

      What all programmers can't seem to get through their heads is that it takes years to become "proficient" at any language. Once proficient you then understand why things were done the way they were done. Most critics of C++ wish they had learned it or perhaps spent 1 month with it and thought they were experts at critique.

      What mystifies me is the masses often get sucked into propriety closed languages/tools like VB, NET, C# (C-Pound) and others. Trouble is, by the time they actually get proficient the vendor will change the API. To a lesser extent this applies to Perl, Ruby, PHP etc also. And off you are wasting time on relearn tools. Which is why I decided early on to learn C right down to the bootstrap code early on. And later learned C++. Not an easy road, but I spend now spend far less time learning tools and much more time punching performance code.

      Call me nuts if you will, but I like C/C++. And suspect, like Dr. Stroustrup does, they have been predicting the 2 year demise in C++ for 12 years and it is still with us. Sun likes Java because it sells big servers to run that bloat ware. Who is kidding who?

    3. Re:C++ needed improvements several years ago. by roman_mir · · Score: 3, Interesting

      Concerning Java, Dr. Stroustrup says "Java isn't platform independent; it is a platform. Like Windows, it is a proprietary commercial platform. That is, you can write programs for Windows/Intel or Java/JVM, and in each case you are writing code for a platform owned by a single corporation and tweaked for the commercial benefit of that corporation." - shouldn't this count for a Flamebait at this point, that Java is Free Sourced?

  21. Re:Just one thing by jeti · · Score: 2, Interesting

    Can Haskell interface with our existing C and C++ codebase?
    Does a compiler exist for ARM architectures?
    And do you think moving over to Haskell would work for my
    colleagues? Some of them do not have a formal education in
    CS and PL and are not too eager to learn something new.

  22. Size of iostream? by tepples · · Score: 3, Interesting

    Good afternoon everybody, I would like to start by including iostream.h into the discussion.

    After this we can get onto the main proceedings which might or might not return anything.

    We move to the future by emitting a string of "Hello world" before returning zero.

    This is the end of the discussion I hope it was informative. Yes, all quarter megabyte of it. A Hello World program that uses <iostream> has been seen to take nearly that much space when compiled with g++ and linked statically with GNU libstdc++, on fairly recent versions of both MinGW and devkitARM toolchains. Compare this to an equivalent program that uses only <cstdio>, at under 6 kilobytes each. (Actual source code, binaries, and makefiles are available on request.) This hurts especially on one of the platforms that devkitARM supports, which has only 262,144 bytes of program RAM and no suitable shared library mechanism. There are some people who claim to have reduced libstdc++'s <iostream> overhead by a factor of four, but they're not revealing how they did it other than a vague "RTFM".
    1. Re:Size of iostream? by tepples · · Score: 2, Informative

      Do you really expect to get meaningful results when you a) use "Hello world" as your test program Yes. A variant of Amdahl's law that applies to code size states that no useful program may be smaller than Hello World. If the Hello World produced with a given implementation of <iostream> is nearly the size of a target platform's RAM, then not much actual functionality will fit in the remaining space.

      and b) static link? The only alternative to static linking that I know of is dynamic linking. Doesn't this require a system to have enough memory to hold the library? As far as I can tell, GNU libstdc++ built as a shared library is larger than the target platform's RAM.
    2. Re:Size of iostream? by norton_I · · Score: 2, Informative

      Oh rubbish. The template code will be the same as, or smaller than, the non-template code. Unless your compiler is truly awful.


      That entirely depends on how you use templates. A single instantiation of a template will likely be smaller than the equivalent generic code, especially in a complex class where you only have to instantiate the members you use. However, if you allow the same code to be instantiated several times, it will quickly blow up your executable size. Any way you avoid this, you quickly lose the benefit of templates (i.e., you make the generic version and lose compile time type-checking). Have you seen the size of executables that heavily use STL? They can be huge.

      What 'leaner thing' can you do in C but not in C++?


      Since most C programs are valid C++ programs, and will compile to a comparable size, almost nothing. However, as soon as you actually *use* non-trivial C++ features, such as the standard library, you are lost on small platforms. Any programming language you can't like with the most basic element of the languages standard library without taking up 90% of your target RAM is... useless (for that target).
  23. Replacing C++? by Anonymous+Brave+Guy · · Score: 5, Interesting

    C++ is far too complex yes. But there is nothing that can really replace it. A language which supports functional, generic, procedural, object-oriented programming, with static typing, metaprogramming, and heavily geared towards native building?

    The thing is, most development projects that use C++ today don't need all of that.

    C++ is a fine, pragmatic tool, and I have great admiration for Stroustrup's ability to build such a useful thing. C++ is also a powerful systems programming tool.

    But C++ is not a good language for most application development, which is what a great deal of code written in it really is. I think there are several separate but somewhat related reasons for this.

    One is the safety argument. Most people simply don't need the flexibility/footshootability [delete as applicable] of C++. You need only look at the much-hyped field of garbage collection to see that (a) many professional developers find this one feature useful that they regard Java as superior to C++ for this reason alone, (b) many more professional developers have no clue about the overheads involved (which are almost zero for typical applications using modern approaches to GC implementation), and most importantly (c) a great many developers using languages without GC make mistakes that developers using languages with GC wouldn't. Similar arguments apply to other routine problems, such as pointers/NULL.

    The second is the expressive power argument. Life is too short to be using programming languages with primitive, error-prone control flow constructs, functions that aren't first-order entities, no syntactic support for common data structures, crude macros, header files, etc.

    Third we have the standard library argument. Yes, yes, you can get a C++ library for almost anything. That's not the point. The key word is "standard". Take a look at the huge practical success of Java and Perl, and tell me the vast Java standard library and CPAN have nothing to do with them. Sure, C++'s standard library is, technically, of a higher quality than most. But it still has stupid flaws (string support and IO streams are both fundamentally broken, for example). More seriously, it has stupid gaps. In the 21st century, it's hard to seriously advocate application development in a language with no standardised support for user interfaces, networking, concurrency, file systems, etc. No, I'm not going to spend days trying to find the right non-standard library for me. Non-standard libraries are for solving significant problems, where the difficulty and scope make it worth investing the time to find and hook in someone else's code. They're not for trivia that everyone uses all the time.

    And finally, we have the tools argument. Working with header files sucks, and while just about everyone else is playing with their funky, auto-refactoring, navigation supporting editors, what do we have? VC++ (where refactoring still isn't available in native C++) and Eclipse (which is C++ forced into a Java-like IDE)?

    The really scary thing is that reality bites now. It's not like I'm the first person to identify these practical flaws with using C++ for application development. It's not like other people haven't developed languages and tools with all these improvements already. And yet C++ continues to be one of the most important application programming languages today. Why?

    Momentum. That's why. Building a new programming language with a syntax that doesn't look like C is asking for trouble; just look at the arguments Python sees over whitespace. (Curiously, I've never seen such complaints made about Haskell. Perhaps this shows a difference between the insight of your average professional programmer vs. your average language geek academic?) More to the point, trying to advocate a new programming language for industrial application development that isn't some form of block-structured, OO-based clone is asking for trouble.

    I'm hopeful that over the next few years, as hardwar

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:Replacing C++? by Anonymous+Brave+Guy · · Score: 2, Informative

      I think you may be confusing me with either a Java evangelist or a C++ basher. I am neither, but I will go through the various points you raised one by one to clarify what I meant.

      "Primitive, error-prone control flow constructs"? Such as?

      Well, in terms of loops, things like foreach (a real one, not an awkward function template that doesn't work with built-in arrays) and labelled break/continue are no-brainers in any modern procedural language. However, in that area I was really thinking of more powerful things like pattern matching and guards on functions as specific features. Of course, given sufficiently powerful handling of functions or macros, you can effectively define your own control flow constructs, so if you want a forever loop or a generator, you just write it.

      Then there are the OO-related issues, based around polymorphism, virtual function dispatch, and dealing with class and member function templates. Look at the elegant simplicity of Smalltalk or the flexibility of Eiffel and then tell me with a straight face that C++'s manual approach to dealing with inheritance and virtual functions is really the best way we could do things. Hint 1: Function overloading vs. function overriding vs. function hiding and their behaviour with virtual function dispatch are crazy. Hint 2: Template resolution takes many pages to describe in the C++ standard. Hint 3: Virtual destructors, 'nuff said.

      And this is without getting into dealing with concurrency in any way, never mind with higher-level tools than primitive threads and locks. Take a look at Erlang's message passing approach or recent developments in transactional memory in everything from Haskell to .Net-based languages if you want to see how weak the "standard" threads and locks model really is.

      As for functions not being "first-order entities," that's a consequence of C++ being a statically-typed language that puts performance first

      Tell that to OCaml, which manages to combine a powerful type system and high-performance imperative features with a functional programming framework quite effectively. As I noted in my previous post, most projects written using C++ today don't need the fast but unsafe and inexpressive approach. Even those that do don't need it most of the time, which is why hybrid approaches like the one OCaml takes have such potential.

      Not to mention that you have things like functors that can turn functions into real objects with only a class wrapper as code overhead.

      Sorry, but even with the nice tricks in Boost, C++'s support for functional programming is at best mediocre compared to what is common in many other languages today, and I don't just mean the mainly academic ones. Being able to overload operator() and play with templates a bit does not change this, it just makes it slightly less limiting.

      "No syntactic support for common data structures"? I'm not even sure what you're talking about here. What kind of syntactic support do you think C++ lacks?

      Well, try initialising a std::vector with some literal data and see how far you get. This one is so annoying they're actually planning to add a hack to compensate in the next version of the C++ standard.

      But the operator overloading you mentioned, while welcome (Java got this one wrong and just hasn't realised yet), is still quite limited. Want to define a multi-dimensional indexing operator? Better go learn about proxy classes, and template metaprogramming if you don't want to take a significant performance hit while you're doing it. And that's only if your data structure happens to be similar to the array-based built-in stuff. Simple but effective things like the head::tail list notation common in functional languages and amenable to recursive processing through pattern matching are difficult or impossible in C++, even if you create your own classes and overload operators in a re

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  24. Re:C Plus Plus Bye Bye by everphilski · · Score: 2, Interesting

    C++ has gone the way of Fortran

    Sadly, I generate new Fortran code on a regular basis. I wish I was generating new C++ ...

  25. It is?! by Anonymous+Brave+Guy · · Score: 2, Informative

    How do you figure that? I work in low-level code, where performance really matters, and I still can't remember the last time I used pointer arithmetic. Sure, I use array indexing all the time, but the fact that this is semantically equivalent to pointer arithmetic in C++ is coincidental. As long as a language supports arrays (as in contiguous memory that supports fast random access — contrast with linked lists) and indirection (call it a pointer, a reference, a link, whatever you like — something you can build graph-like data structures with) then I don't see any need for pointer arithmetic at all.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    1. Re:It is?! by cerelib · · Score: 2, Insightful

      You are right in a way. Most people do not need pointer arithmetic, but it becomes very useful when you are working with external blocks of data. For example, I was writing some audio capture code in Java and with it you are passed byte arrays. In Java, you cannot simply treat this as a block of data because it is an object. It makes doing things like 16+ bit audio quite annoying. With pointer semantics I can simply treat the byte array like a short array and be done with it. There are many applications that deal with such external blocks of data that also need high performance, which requires the use of memory pointers. To completely replace C/C++, a language must allow this kind of direct memory manipulation.

  26. Tried to post a reply, it failed by theendlessnow · · Score: 4, Funny

    I tried to post a comment on this story, but was unable to upload my video response.
    (sigh)

  27. give it a rest by m2943 · · Score: 3, Insightful

    C++ is my main development language right now, but I have to say: please give it a rest. C++ is what it is, and I don't think adding even more crap to it is going to make it any better.

    What we need is a language with C++-like performance characteristics and a C-like syntax that will feel familiar to C/C++ programmers but without all the baggage of 30+ years of C history.

    (And, no, neither Java nor C# are that language.)

  28. Stroustrup by Anonymous Coward · · Score: 2, Funny

    always wondered who the strstr function was named after...

  29. Re:Static iostream size? by Cassini2 · · Score: 2, Interesting

    Do you code C++ only for PC-class or bigger machines? Or do you also code C++ for an embedded system with small (e.g. 256 KiB) RAM? If so, have you figured out how to compile a program (even Hello World) and statically link it against a Free implementation of the C++ standard library so that the executable is smaller than 200 KiB? I tried GNU libstdc++ with MinGW and (more to the point) devkitARM, and in each case, I got a binary roughly 250 KiB in size.

    I have compiled C++ code down for a PIC microcontroller with 8 kB of RAM. The trick is to use only stuff from the C99 standard. Then you compile the code using VC++ on a Microsoft PC and do your unit testing. You can then rename all the CPP files to C files, and recompile under the PIC compiler and generate valid code.

    In practice, the VC++ compiler is fairly non-standard, and the renaming of files business sucks. My solution was to move all the code into header files (.h), and then include the headers from stub .CPP and .C files.

    The interesting thing was, the development time on the project where I did this was drastically reduced. A full fledged C++ compiler, like Microsoft C++, made program test much simpler. Development time was dramatically reduced because of a much simpler test cycle. This resulted in much more reliable code being given to the PIC, further simplifying the embedded development/test cycle. Debugging an embedded platform is much tougher than debugging on a PC, so any debugging that can be done on the PC is really big bonus.

    Another interesting point is that for an embedded platform, particularly the really small chips, you may be better off turning off the entire C Run-Time Library. You aren't going to use any functions from it anyways. Calls like printf() and iostream make little sense on devices lacking basic terminal I/O commands.

    Additionally, on devices without virtual memory, you want to avoid calls like new and malloc(). Make everything possible stack based, allocated only once at known program points, or allocated statically. Minimize the number of random allocations and deallocations. If you are trying to prove correctness for long uptimes, you need to prove that malloc() always succeeds. That is a very difficult thing to do given the potential complexities of external memory fragmentation and memory leaks. There is no Virtual Memory available to cover up inefficiencies in your code, in new, or in malloc(). Exceptions are also bad, because you have to prove that every single one of them is handled correctly and won't cause run-time issues. Besides, exceptions, new and malloc() are big sources of random uninitialized memory variables, and often result in slower code. All unexpected behavior on an embedded platform is bad.

    On an embedded platform, for long up-times, you must also consider the possibility of hardware memory corruption. As such, statically allocated variables (non-indexed) are nice. You can read directly from a fixed memory location, and effectively verify allowed values. It is also desirable to keep the program simple and straightforward. This makes it easier to prove correctness and simplifies unit testing.

    To any potential coders out there: this approach is completely non-standard, and I don't really recommend it unless you are working with embedded devices. My coding style on a PC platform differs significantly from my coding style on memory constricted embedded devices (like PICs). Also, on an embedded device, program length is usually small (for speed). As such, fast obtuse fragments of code are tolerable (if they are commented.) For a PC, programs are bigger, and obtuse code is not nice.

  30. What follows C++ is probably by Anonymous Coward · · Score: 4, Interesting

    a new language like D and not just an improved C++.

    As a C++ programmer, I can tell you that it is nearly impossible for C++ to make coding, compiling and debugging easier without redesigning the language.

    Coding: Name one C++ editor or IDE that offers accurate code completion or code refactoring (compared to other languages.) I've tried Source Insight, SlickEdit 2007, Visual Studio 2005, Understand for C++, Vim, etc. and it is clear C++ is too complex compared to most other mainstream programming languages.

    Compiling: Implementing a C++ compiler is far too difficult. And compiling takes too long even when you use C++ idioms like pimpl.

    Debugging: Sure, boost.org's smartpointers and RAII are helpful but how many hours do C++ programmers spend tracking down bugs that would've taken minutes (if not seconds) to track down or avoid in other programming languages?

    Why do I use C++? Because it is compiled, has numerous 3rd-party libraries, and is widely used. Like Windows XP, it might be a pain but it is so widely used that you'll have no problems finding employers that will pay you to use it.

    Simply put, we deserve something better than C++ and it isn't going to be enough to enhance C++ because a full redesign is needed in order to address the issues noted above. We need and deserve a language that takes what we've learned from C++ and is designed from the ground up to address those issues.

    So far, D programming language seems to offer the best hope, and some really talented C++ gurus like Walter Bright and Andrei Alexandrescu are involved.

    1. Re:What follows C++ is probably by ChrisA90278 · · Score: 2, Interesting

      I was carful when I wrote "flight control software" and not just "flight software". Seems they are going with Ada for the approx 4% of the code that really matters. The JSF will have about 15 million lines of code aboard. So only 150,000 lines is considered "safely critical" I guess. That's good because I doubt anyone could write 15M bug free lines of code. 150K will still be "way hard" but do-able. I read Lockeed's presentation where they jutified C++. Their reasoning was simple: They would not hire enough Ada programmers. They said they could not train them either because people don't see a career in Ada anymore so they leave. The bulk of the pages was numbers to support the claim that there are not enough people to write 15M lLOC in Ada and worse, in futrue years there will be no one to maintain it. Notice that they are not really writing in C++. They are writing in a very restricted sub-set of C++ and the subset is defined in a way to facilitate testing and inspection.

    2. Re:What follows C++ is probably by sashang · · Score: 2, Interesting

      Check out OCaml. It has C++ like features without the headache. It's more advanced than D and has great performance characteristics. It supports type inference (so you don't need to remember the type of the variable), static typing, generic programming (templates in c++) via modules and functors, concepts (which are meant to be part of c++0x) via signatures, virtual functions via subtyping, and garbage collection. It's also a functional language so you get the core features of functional languages, like pattern matching.

  31. Strostrup is now part of the problem. by Anonymous Coward · · Score: 5, Interesting

    C++ has many problems. Some, like "an array is a pointer", it inherited from C. Some were mistakes in the original design that were later fixed, like unchecked downcasts, "this" as a pointer rather than a reference, and the lack of generics. And some are there because Strostrup is in denial about the problems, like the fact that the language gives no help with either thread or memory management.

    Memory management remains the biggest problem. The fundamental problem is that C and C++ require the programmer to obsess on who owns what, while providing zero assistance in managing that information.There are ways out of this, involving syntax and compiler support for owning and non-owning pointers. But instead, attempts have been made to paper over the problem with templates. This never quite works, because for some things you still need a raw pointer, which breaks the abstraction. The history of auto_ptr (up to standard revision #4 now, I think) makes this clear.

    Bolting on a garbage collector doesn't help much in a language with destructors; see the mess in Microsoft's "managed C++". If you're going to go with a garbage collected approach, it's better to go to a language designed for it, like Java.

    Most of the standards effort is going into template features that few will use and fewer still will use well. Trying to use the template expansion engine as a general purpose macro system is a terrible idea for production code. But it has a big fan club on the standards committee. Worse, the C++ commitee does very little to improve language safety and reliability. Which is why we still have buffer overflows in C++ code, fifteen years in.

    Incidentally, none of this has anything to do with C++ being compiled directly to machine code. There have been safer compilable languages usable for system-level programming. Modula 3 was probably as good as it got. But that language died when DEC went under. It's possible to hard-compile Java; there's a version of GCC for that, and it's getting some interest in the embedded community. The problem could be fixed. But it won't be, because the people responsible are in denial.

    1. Re:Strostrup is now part of the problem. by macrom · · Score: 2, Insightful

      I don't think Stroustrup is in denial at all. Read his book The Design and Evolution of C++ for insight into his decision making process. You may not always agree with it, but at least he's thought things through. When developers start launching complaints about missing features from C++, they generally miss the point of why C++ exists in the first place. It's not a be-all-things-to-all-programmers language. It's a tool to help you get many different types of jobs done.

      No thread management : this is an OS-specific issue. Yes, almost all modern operating systems use threads, but C++ isn't designed to do OS tasks. It's a tool so that you can design your own management of threads in a way that suits your projects and style. Use Boost if you want a widely-supported, cross-platform set of thread management classes.

      No memory management : again, OS-specific. What if I don't want garbage collection? I like the fact that C++ has deterministic destruction of objects, and I can use that to my advantage. If you want memory management, use boost::shared_ptr and it's siblings. Yes, auto_ptr is broken for various activities, but if you aren't aware of the freely available and widely supported alternatives that work just fine, then you need to update your C++ skill set. Stating that templates are a bolt-on solution for memory management is way off base and shows that you don't really understand that templates are a generic programming construct. And to state that we have buffer overruns in C++ because of bad language features is, again, attempting to assign the problem to the wrong source. If developers would use smart pointers and other safe development tactics, a lot of the problems would go away. Hell, I work with a guy now that refuses to use 'const' in parameters because it involves typing 6 extra characters. It's attitudes like this that cause runtime issues, not the choice of language.

      C++ is still a great language. If programmers would take time to familiarize themselves with quick and easy ways to start tightening up their code, we wouldn't have so much problematic software. Instead, everyone sits around and looks at Java, C# and their ilk and demand that the same do-everything-for-me features be brought over. That's not the spirit of C++, and frankly I don't want to see C++ messed with that way. When I want those features, I use those tools and understand why both exist.

    2. Re:Strostrup is now part of the problem. by Cassini2 · · Score: 2, Insightful

      IMHO, I think:
      a) If you want garbage collection, you have to leave C++ and go to a truly safe language like Java or one of the .NET languages. You can't have the ability to do whatever you want to a variable, and the ability to be safe from it simultaneously.
      b) If you are trying to code a GUI application with cool RAD development tools (like VisualBasic and Eclipse), then C++ is the wrong language. It was never built to be quick and easy for the programmer. Additionally, the windows based object-oriented metaphor makes proper memory management difficult.
      c) If you try to use all of C++ in one program, you deserve to be shot. C++ should be used with strict coding guidelines on what features will be used, and what features won't be used. These features can be picked on a per application basis, and thus the language can be customized for almost anything. Just don't try to do everything simultaneously.

      What C++ excels at are projects that require complete control of the machine. If you need the asm directive, its there. If you need funky type unions, you have them. If you need to organize your code, so people can understand it, you have objects and namespaces. If you need to customize the behavior of new(), you can do it. If you need C language compatibility with your header files, it can be done. C++ gives you every option that you may need. Just don't use all of them simultaneously.

    3. Re:Strostrup is now part of the problem. by ardor · · Score: 2, Insightful

      Most of the standards effort is going into template features that few will use and fewer still will use well. Trying to use the template expansion engine as a general purpose macro system is a terrible idea for production code. But it has a big fan club on the standards committee. Worse, the C++ commitee does very little to improve language safety and reliability. Which is why we still have buffer overflows in C++ code, fifteen years in.

      Obviously, you never used modern C++ extensively.

      Templates are not a macro system, they are a typesafe meta-language. I agree that their syntax sucks, but they are lightyears away from being a simple macro system. And lots of people use them, just look at the STL string or vector. You think few people will use concepts or variadic templates, think again. Generic programming is the actual edge of C++.

      I really suggest you read "Modern C++ Design". There you can see perfectly valid examples of how to use templates. Policy-based is a good and powerful example. With this, I can customize my code at compile-time, for example, having a policy which locks a mutex in proper code sections, and another policy with no locks at all. This way, my code *can* be threadsafe, but does not *have* to be (thread safety is useless in a singlethreaded program). Oh yes, I could do that with the preprocessor too, but try debugging this. Also, say goodbye to namespaces, type safety and debugging support.

      Safety and reliability have nothing to do with C++ itself. Many people overuse new and delete, without relying on proper RAII constructs, for example. If you think MFC-style C++ is the zenith, you don't know C++. I have been programming C++ for over 7 years and reached a point where memleaks happen extremely rarely (mostly due to rushed code). Its no black arts, no voodoo, just proper C++ usage.

      --
      This sig does not contain any SCO code.
  32. null keyword rant by wiredlogic · · Score: 2, Insightful

    Could it really have been that difficult to add a "null" keyword to C++? "bool" was cleanly added to C99. We could have had "null" too. I accept the argument that (void*)() isn't typesafe but then the language expects you to throw around a literal integer "0" that is imbued with magical properties. How is this a cleaner solution? This magic 0 violates the type safety principal that got us into this rathole to begin with since it can be assigned to non-integral types (pointers). It can also transform itself into another value since the null address isn't necessarily 0 on all platforms.

    --
    I am becoming gerund, destroyer of verbs.
  33. Rant by treak007 · · Score: 2, Interesting

    Virtual machines like the JVM are all the rage nowadays. Sure they are cross-platform and have some benefits, but they will never replace true natively built code. C++ is a powerful tool that I use daily, and I would said it was anything but dying.

    C++ has a lot of different features, which is why some find it confusing, but it is those many features which allow the language to be so flexible. Whereas a language, again picking on java, such as java forces the programmer to follow a very strict object-oriented form, C++ gives the programmer a choice as to how they want to write their code. I can write very object-oriented code, with features java doesn't support such as operator overloading and multiple inheritance, or I can write very functional-based code that resembles C. Also, C++ gives the programmer true control over what is going on inside their application. In java for example, objects are passed by reference and primitives are passed by value. In C++, I can specify which of the two I want for either type on a per argument basis. Another example is exceptions, which are known to be a rather slow feature in a language. In a language such as Java, again sorry java fans, exceptions are an integral part of the runtime interpreter. In C++, if I find that I don't wish to use exceptions, I can disable support for them and regain that performance boost that was lost at the hands of exception checking.

    Alright, alright..I am done ranting for now. All I guess I am trying to say is that yeah, maybe C++ is a bit more confusing to a beginner then interpreted languages and the like, but it is those features which can be confusing that allow a programmer to really control their code. The better the programmer understands what the code they are writing is doing, the better code they will write. That being said, long live bit flags, unsigned variable types, multiple inheritance, operator overloading and raw pointers!

    -Your Local /. C++ fanboy.

    --
    Klingon Software is not released, it escapes, inflicting terrible damage onto the enemy as it does
    1. Re:Rant by treak007 · · Score: 2, Interesting

      What I can say, though it is not quite relevent to the discussion, but I will anyway... the issue with calling the GC directly -is- an incredibly easy to find bug =P In my opinion, ANYTIME the GC is called directly, thats a bug right there, so finding it can even be automated!!! Tadah! (Seriously though, NEVER EVER EVER call the GC directly. If you THINK you have to, its because there's an architecture problem somewhere...). Interesting. When I code in Java, I try to take control of the program as much as possible, which usually results in me fighting with the JVM. I acknowledge that writing Java code is like writing for a separate os, which acts completely different then the host os and that to write effective Java code, it becomes necessary to familiarize oneself with the JVM and all its nuances.

      This discussion reminds me of a very interesting book that one of my professors lent to me which was a sort of puzzle book describing some small intricacies within the JVM that could lead to rather large bugs. Even with higher-level programming languages, I still believe it is necessary to have a strong understanding of the underlying implementation. So in other words...

      doesn't mean you can hire crap programmers, no matter how much the project managers think so! Exactly!!
      --
      Klingon Software is not released, it escapes, inflicting terrible damage onto the enemy as it does
  34. Jokes in Cobol by billstewart · · Score: 2, Funny
    I've only seen two. One is that there was a company Ryan McFarland that made a COBOL compiler for Unix named "rmcobol" - everybody thought that sounded like a good idea.


    The other came out on Usenet in the 80s and went something like

    Hey Rocky, watch me pull a computer program out of my hat!
    Oh, Bullwinkle, that trick never works!
    100 PROCEDURE DIVISION .... [couple more lines like that]
    Guess I oughta get another hat!

    Some of my coworkers got it, but a couple of them didn't. The disturbing part was that they recognized the Cobol program, but were too young to recognize Rocky and Bullwinkle...
    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  35. C++ is dying while C is thriving by MobyDisk · · Score: 2, Interesting

    What is odd to me is that I see new stuff written in C all the time for embedded systems, *nix code, drivers, etc. It's odd because C++ is merely language extensions on top of C. There's really no down-side to using C++ at all (queue the thread of trolls telling me how awful OOP is and why C++ forces them to use it). My guess is that the problem is g++: I am currently writing some code for the Nintendo DS, and if I compile it in gcc the code is 100k smaller than when I compile the same thing in g++, even before using the OOP features. I don't know why, but I know other people have reported the same issues. This is perpetuatating the myths that C++ is bloated. Really, we need C++ in a lot of ways but the tools are making it look bad.