Slashdot Mirror


An Interview With C++ Creator Bjarne Stroustrup

DevTool writes "Bjarne Stroustrup talks about the imminent C++0x standard and the forthcoming features it brings, the difficulties of standardizing programming languages in general, the calculated risks that the standards committee can afford to take with new features, and even his own New Year's resolutions."

509 comments

  1. Trivial Count: 2 by Anonymous Coward · · Score: 0

    Only two usages of "trivial" in that article? Needs to be fluffed up a bit.

    1. Re:Trivial Count: 2 by MrEricSir · · Score: 2

      We could add more, it would be a trivial change.

      --
      There's no -1 for "I don't get it."
  2. C++0when? by fishexe · · Score: 3, Informative

    Of course by this point it really should be called the imminent C++1x standard.

    --
    "I don't care about the Constitution!" --Bill O'Reilly, November 17, 2009
    1. Re:C++0when? by Anonymous Coward · · Score: 3, Funny

      No, it's going to be called C++0xc or 0xd.

    2. Re:C++0when? by fishexe · · Score: 1

      Where do you get the k?

      --
      "I don't care about the Constitution!" --Bill O'Reilly, November 17, 2009
    3. Re:C++0when? by Imagix · · Score: 1

      Not if you use a hex digit.... C++0B ....

    4. Re:C++0when? by Anonymous Coward · · Score: 1

      two '+' and a pair of scissors...

    5. Re:C++0when? by vondo · · Score: 1

      As Bjarne himself says, "The x is hexadecimal"

    6. Re:C++0when? by Anonymous Coward · · Score: 0

      He took it from your response.

    7. Re:C++0when? by Cryacin · · Score: 1

      Buffer overrun

      --
      Science advances one funeral at a time- Max Planck
    8. Re:C++0when? by bradgoodman · · Score: 1

      Hey...At least it'll be finalized before Duke Nukem Forever... [knock on wood]

    9. Re:C++0when? by h4rm0ny · · Score: 3, Funny

      Nah, the revised and improved C++ is going to be called D.

      Oh wait, it already is. ;)

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    10. Re:C++0when? by OeLeWaPpErKe · · Score: 1

      Perhaps duke nukem forever is written in C++0x. That would explain it's greatness after all.

    11. Re:C++0when? by VortexCortex · · Score: 1

      As Bjarne himself says, "The x is hexadecimal"

      There is no hexadecimal digit 'X'. The '0x' is a prefix in some languages to differentiate a hex number from octal which, in C/C++, also starts with 0 (zero) and has so fractional part.

      So, '0x' would be a syntax error, unless the next rev of C++ allows us to use arbitrary bases for our numbers, then '0x' would be at least 33 (in Base36 (0-9 & a-z) ), but more practically 211 in Base64 (for URL applications (A-Z, a-z, 0-9, _ & - ) ).

      So, we're looking at 2033, 2211, or never -- since '0x' is a syntax error and will never compile.

      For those that would argue that the x stands for an unknown digit -- Wow, just wow, use a variable, (practice what you preach Bjarne! How about "C++ giCompletionYear" ?) or a newly supported regular expression ( "C++ /[01]\d/"), sheesh.

      IMHO, Bjarne isn't showing the full source code -- it's actually a two liner and the diffs show that he edits the first line frequently:

      #define 0x 2012
      C++ 0x

      He's just too proud to admit it because he thinks macros are evil -- Ha!

    12. Re:C++0when? by c++0xFF · · Score: 4, Funny

      My user name seems appropriate here.

    13. Re:C++0when? by fishexe · · Score: 1

      Not if you use a hex digit.... C++0B ....

      But if you were using hex, the hexidecade would be the 7B0s, not the 2000s. So it would have to be C++BB, or generically, C++Bx.

      --
      "I don't care about the Constitution!" --Bill O'Reilly, November 17, 2009
    14. Re:C++0when? by fishexe · · Score: 1

      Brilliant!

      --
      "I don't care about the Constitution!" --Bill O'Reilly, November 17, 2009
    15. Re:C++0when? by Anonymous Coward · · Score: 0

      It would have been way cooler if your uid was much smaller.

    16. Re:C++0when? by maxwell+demon · · Score: 1

      It's a mix of C++0x and Perl 6. And the initial version will run on the Hurd. :-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
    17. Re:C++0when? by Bing+Tsher+E · · Score: 1

      I downloaded a distribution of Debian that ran on the Hurd a number of years ago. It's complete enough to use.

    18. Re:C++0when? by kmoser · · Score: 1

      Let's just cut to the chase and call it XKC++D.

    19. Re:C++0when? by Anonymous Coward · · Score: 0

      It would have been way cooler if your penis was much bigger.

      FTFY

    20. Re:C++0when? by Anonymous Coward · · Score: 0

      Oh, the terror of the v0xFFk! After the final language standard the committee, dogs and cats are living together, etc.

    21. Re:C++0when? by GigaplexNZ · · Score: 1

      For those that would argue that the x stands for an unknown digit -- Wow, just wow, use a variable

      In algebra, x is the most commonly used variable name. Many math oriented programmers tend to use C or C++, so what do you really expect?

    22. Re:C++0when? by Anonymous Coward · · Score: 0

      It will be C+++

  3. Multi-processor Extensions by Script+Cat · · Score: 0

    I want some efficient use of multiprocessor systems. When can expect to see this implemented in G++ or similar?

    1. Re:Multi-processor Extensions by arth1 · · Score: 1

      What's stopping you?
      Or do you want abstractions built-in to the language, and not the implementation?

    2. Re:Multi-processor Extensions by jythie · · Score: 1

      Some people do not seem satisfied unless it is built into the language via special syntax.... even though existing libraries do the job just fine.
      Then again I have noticed a lot of people (and schools) seem to be allergic to threading.

    3. Re:Multi-processor Extensions by Short+Circuit · · Score: 1

      I want some efficient use of multiprocessor systems.

      For which processor classes, and which problem domains? The more flexibility you want, the more you'll sacrifice in efficiency/engineer-time or efficiency/computer-time.

    4. Re:Multi-processor Extensions by lgw · · Score: 3, Informative

      The std::thread and std::async libraries should give you all the tools you need in a plaform-independent way. The popular compiler vendors seem to be eager for C++0x - once the standard is official, Visual Studio will do a patch, and I'm sure G++ will beat them to release. Many of the C++0x features are already there with the -std=gnu++0x option to G++, though I'm not sure if that includes the threading stuff.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    5. Re:Multi-processor Extensions by Script+Cat · · Score: 1

      Threading and mutex gets messy. Do you have some good examples? Perhaps something where we can parallelize loops and deal with data dependency issues. Also distribute the work among the processors all while not being locked to a specific hardware set. I may just be out of the loop.

    6. Re:Multi-processor Extensions by gerddie · · Score: 1

      In g++ you get openmp , but you might want to have a look at cilk++. Unfortunately, it is based on g++-4.2.4, so no C++0x features.

    7. Re:Multi-processor Extensions by Script+Cat · · Score: 1

      In the generic sense, arbitrary desktop systems, 1 core through 8 cores. A problem where there are more processor units available and I have a set of operations that require minimal dependency from one another. Divide the work up arbitrarily among the processors. Maybe there's already a good way to do this but I don't see that it is in common use. Everything tends to be very serial. Let’s say I want to sum an array of n values as fast as possible.

    8. Re:Multi-processor Extensions by Script+Cat · · Score: 1

      std::async neat thanks man.

    9. Re:Multi-processor Extensions by macson_g · · Score: 1

      This is a job for a library, not the language. And there are plenty of them, for instance QtConcurrent or ICC.

    10. Re:Multi-processor Extensions by Short+Circuit · · Score: 2

      Limited to your local desktop's CPU cores, written in C or C++? You probably want to look at OpenMP, probably combined with some compiler intrinsics for vector math. (Or you can use a third-party library which already does things like that.)

      I'll note that, limiting yourself to your desktop's CPU cores cripples even the average web-targeted netbook. You'd be much better off delegating the number crunching to your GPGPUs. (Even my desktop's HD3200 integrated video chipset ought to be able to trounce my Phenom 9650 for a problem like that.)

      Efficient use of parallel resources depends a great deal on the nature of the problem you want to solve. As the most demanding consumers of parallel resources push for even more capacity, more tools are developed. The more tools that get developed, the more complicated the problem is discovered to be.

      There are efforts to take different approaches on the problem, primarily (from what I've seen) in developing alternate programming languages that try to neatly solve those problems that existing programming languages have difficulty with, but they tend to require thinking about problem solving from a vastly different perspective, and have their own systemic complexities and weaknesses.

      In other words, in the area of parallel computation, programming is experiencing an even greater tower-of-Babel event than any other area of programming I'm aware of. This extends from libraries to language extensions, to languages and on through models of programming.

    11. Re:Multi-processor Extensions by scorp1us · · Score: 4, Interesting

      So, I am an unapologetic Qt freak.

      It does everything pretty damn easily and extends your C++ compiler by using a MetaObjectCompiler (MOC pre-processor) and gives you most, not all, of what C++0xForever is promising. Platform independently.

      Of you don't like Qt, then there is Boost. Both are just C++ libraries.

      --
      Slashdot's rate-of-post filter: Preventing you from posting too many great ideas at once.
    12. Re:Multi-processor Extensions by lgw · · Score: 4, Interesting

      The core Boost classes were written by guys on the C++0x committee - they were written with the intent of becoming part of the standard library eventually. It's nice to have commonly used libraries incorporated into the language standard, especially to standardize cross-platform interfaces to platform-dependent stuff like threads.

      But some stuff like Lamba just gets better syntax sugar if you change the language instead of using a library. While I'm not all that happy with the new C++ lambda syntax (what's wrong with making lamba a keyword, guys? same for you C# guys?), is still way easier than the Boost lamba syntax.

      And some stuff like move semantics are just an outright fix to the language. Vector will stop requiring that Foo be copyable - finally!

      --
      Socialism: a lie told by totalitarians and believed by fools.
    13. Re:Multi-processor Extensions by lgw · · Score: 1

      Bah! Slashcode ambush!

      vector<Foo>

      will stop requiring that Foo be copyable.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    14. Re:Multi-processor Extensions by Mitchell314 · · Score: 1

      Then again I have noticed a lot of people (and schools) seem to be allergic to threading.

      Some of us like to be safe with our memory, so go fork yourself. :P

      --
      I read TFA and all I got was this lousy cookie
    15. Re:Multi-processor Extensions by SomeKDEUser · · Score: 3

      lamba is not a keyword for two reasons:

      a) it mostly evokes elvish pastry (properly spelt lembas)

      b) lambda (/\), the Greek letter, is very common in scientific code, and making it a keyword would be painful.

    16. Re:Multi-processor Extensions by tepples · · Score: 1

      Or do you want abstractions built-in to the language, and not the implementation?

      If abstrations are built into the language, even as a standard library rather than as specific syntax, then they'll be portable across UNIX, Windows, and lesser-known platforms that run the language.

    17. Re:Multi-processor Extensions by Chemisor · · Score: 1

      > The more flexibility you want, the more you'll sacrifice in efficiency/engineer-time or efficiency/computer-time.

      Why is it, I wonder, that engineer-time is valued higher than computer-time? A good application, once written, will be run many, many times over many years, by many people. Even a second of execution saved in such a program should be worth months of engineer-time, since it will pay for itself in increased efficiency of its users. These days, of course, the mindset seems to be that the programmers write the app and then nobody uses it more than once. It must be because pretty much every recently written application is so bad that the latter is true.

    18. Re:Multi-processor Extensions by Short+Circuit · · Score: 1

      Simple description: Out-of-sight costs are out-of-mind. Financial concerns for the professional programmer mean meeting deadlines under project requirement constraints. That means getting it out the door quickly.

      Personal concerns for hobbyist programmers include boredom; if it's not slow work and uninteresting, it's not worth their time.

      As for write-once, run-once...blame the hyperfocus on app stores. With app stores, you don't want to invest a lot of developer time creating a project, because there's an arbitrary axe ready to come down on something your company spent two months getting perfect. Once past the arbitrary axe, with as much competition as there is, if someone finds your app even the slightest bit unsatisfactory, the barrier to trying something else is slim to none.

      That's great for consumers, because out of dozens of options, one of them will be just right, and it'll be cheap; the developer won't have wanted to invest a lot of his time, because he might not have landed single sale in the first place. He'll either have been talented enough to get it right early, or he'll simply have been lucky.

  4. I Guess... by GreenSeven · · Score: 1

    I never realized that the standard for C++ hadn't been updated in 13 years... Seems like a long time for a language that popular. Then again, if the standard doesn't change, old code should be supported for a longer period of time. Any thoughts on if this is a benefit?

    --
    The Copper Tribe - Office Software Solutions
    1. Re:I Guess... by Anonymous Coward · · Score: 0

      >I never realized that the standard for C++ hadn't been updated in 13 years

      >Seems like a long time for a language that popular

      I guess that's the reason why :o)

    2. Re:I Guess... by HiThere · · Score: 1

      Yeah, but the handling of unicode is impossibly bad. It can't be fixed with a simple library, because you need to be able to handle literal strings. You could do it with a macro that calls a library...but that's *really* inefficient. The best time to handle it is at compile time.

      I'd also like garbage collection, but that means severe restrictions on pointers, which will break lots of old code. Treating literals as utf-8 strings works fine for all code that adhered to ascii characters, and didn't play fast and loose with the chars, just because an implementation allowed them to. It will even work in most cases where the literal strings are actually byte strings, as long as you don't try to evaluate them. (Well, validate them or print them.)

      That said, I do recognize the need for 8-bit integers. They should be called bytes, though, not chars.

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
    3. Re:I Guess... by shutdown+-p+now · · Score: 2

      I never realized that the standard for C++ hadn't been updated in 13 years...

      Actually, the last update was in 2003 - known, surprisingly, as C++03. It's what most C++ compilers these days implement. It was just comparatively minor, mostly bug fixing and clarifying ambiguous points etc. Though some new features sneaked in - e.g. it lets you write new int[10]() to dynamically allocate a default-initialized array.

    4. Re:I Guess... by lgw · · Score: 1

      Native Unicode literal support is one of the nicer everyday-use improvments in C++0x. A char was never really intended to be a byte, the only restriction was that sizeof(char)==1; that is, it's the finest-grain access you have to memory. With C++0x is must be at least 8 bits (for the first time), but can still be as large as desired AFAIK.

      However, AFAIK the Unicode support doesn't extend to the libraries - AFAIK there's no standard way to count the codepoints in a Unicode string, or do substrings based on count-of-codepoint offsets, or convert between encodings, or anything like that.

      Sdaly dropped from C++0x is opt-in garbage collection. Allowing somehting like "garbage_collect int* pX = new int(0)" would have really helped out when creating cyclic data structures. The committee punted on that, though, not wanting to require a GC implentation in ll comforming compilers. They did add thred_local, though, which is another needed storage-class primitive.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    5. Re:I Guess... by Xest · · Score: 1

      It's probably worth keeping in mind that even if a language is updated that many developers don't need or wont utilise new features anyway. For example, many people will still be using C++ as it was 20 years ago. Of course, it can also take time for language tools such as compilers to catch up to standards too, so it might be some years post standards ratification before the tools are fully upto the job of supporting the new standard anyway.

      Maybe I'm getting old but I don't recall language updates ever having been a frequent thing historically, and rapid updates in more modern languages are born from the release early, patch often mentality that came about with the rise of the connected world and people becoming used to the likes of Windows update downloading 10s, sometimes hundreds of megabytes of updates each month.

      This is not to say frequent updates are bad or anything, just that I don't think it should be seen as unusual that updates to older languages like C++ are relatively infrequent.

    6. Re:I Guess... by spitzak · · Score: 1

      Sadly the C++0x committee is still dedicated to making sure UTF-8 does not work. As far as I can tell the underlying reason for the sabotage is that there is this feeling that it is politically incorrect because it gives English the "better" short encodings.

      What is needed is for \uNNNN and \UNNNNNNNN to produce the UTF-8 encoding of Unicode characters in string constants, while \NNN and \xNN still produce single bytes (even if the result is not a legal UTF-8 encoding). This would be entirely upwardly compatible with current C and C++ code. Also any unicode characters in a string constant should be turned into the UTF-8 encoding.

      Currently you are forced to make "u" wide-character strings if you actually want Unicode characters in any usable way in your source code. This seems to be purposely designed to make use of UTF-8 as painful as possible, so they can continue to smugly think they are somehow promoting world equality and interoperability (when what they are really doing is encouraging the use of ASCII-only and making things worse than when ISO-8859-1 was the standard).

    7. Re:I Guess... by spitzak · · Score: 1

      Some features like "auto" will probably get extensively used quickly. I agree that other features such as the lambdas will not get used by a large subset of programmers for decades.

  5. Why embed tabs in the code examples? by Anonymous Coward · · Score: 0

    which idiot would embed tabs in the code examples? typical kalev fail.

  6. Re:c++ 1x sucks by wiredlogic · · Score: 2

    They should have added nullptr 20 years ago. It's always amusing to read about C++'s design for type safety when we've been forced to sling around magic '0' literals all this time because someone got their panties in a bunch over automatic casting of void*.

    --
    I am becoming gerund, destroyer of verbs.
  7. Too little and too much, way too late by Rogerborg · · Score: 1, Flamebait

    There's still a market for low level C programmers, and for Java, C#, Perl, Python, VB, and just about everything else, but who uses C++ these days? Games developers, a few corporate app maintainers and... uh... hang on...

    Note carefully: I love C++, with all its fragmentation, bloat, gotchas and non-standard-standard-libraries, but really, it's a niche language now, kept alive by beardy wierdies and a few caffeine soaked kids who'll burn out and end up writing SQL for banks in a couple of years. Interesting, but hardly news that matters.

    --
    If you were blocking sigs, you wouldn't have to read this.
    1. Re:Too little and too much, way too late by 0100010001010011 · · Score: 2
    2. Re:Too little and too much, way too late by Anonymous Coward · · Score: 3, Insightful

      Not that I disagree with your feelings but QT is a major C++ magnet -- of course you could argue that QT is a language on its own, not really C++.

    3. Re:Too little and too much, way too late by jythie · · Score: 2

      I don't know, I see a LOT of C++ job postings. Most desktop and server application (designed for sale) development is still done in C++, and it is pretty common in middleware.

    4. Re:Too little and too much, way too late by JBMcB · · Score: 5, Informative

      > Games developers, a few corporate app maintainers and...

      Most Mozilla project applications including Firefox.. Pretty much all of KDE and some of GNOME. WebKit. Google Chrome. Opera. A good chunk of OpenOffice. Most Adobe applications. Most Microsoft desktop applications including Internet Explorer. CUPS. The Qt toolkit and pretty much everything that uses it. MySQL. Autodesk Maya. Winamp.

      I wouldn't say a *few* corporate apps are written in C++, I'd say pretty much every major desktop app that's undergone a major re-write within the last two decades is probably C++.

      --
      My Other Computer Is A Data General Nova III.
    5. Re:Too little and too much, way too late by capnchicken · · Score: 2

      I concur with your anecdotal evidence with my own observations and I share your opinions. But it seems like its moot compared to some of the hard data I've seen in the past.. It may be trending down, but it's not down yet.

      I believe it is also a regional thing, C# seems to dominate the Mid-Western US with Java domination on the US coasts. With C++ being, well, elsewhere out of my ethnocentric regionalisms. Again, just my own personal anecdotal evidence.

      --
      A libertarian shat on my carpet once. Claimed the free market would sort it out. -Ford Prefect(8777)
    6. Re:Too little and too much, way too late by mswhippingboy · · Score: 4, Insightful

      There's still a market for low level C programmers, and for Java, C#, Perl, Python, VB, and just about everything else, but who uses C++ these days? Games developers, a few corporate app maintainers and... uh... hang on...

      Not sure if you're being facetious or not here, but C++ is consistently in the top 3 languages (the others being C and Java) in terms of popularity and usage. It's well above PHP, C#, Perl, Python, VB, Obj-C, and so on. I realize that stats from Tiobe index, Sourceforge, Langpop and other sources are merely an educated guess as to what people are really using, but the fact that nearly all agree on these three languages as being the top contenders seems to add credibility to their accuracy. It certainly beats the opinion of some individuals who are biased toward their favorite (or least favorite) languages.

      kept alive by beardy wierdies and a few caffeine soaked kids who'll burn out and end up writing SQL for banks in a couple of years

      Hey wait a minute! I resemble that remark!

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    7. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Why? Just because of some auto-generated code (moc) for signals/slots?

    8. Re:Too little and too much, way too late by derGoldstein · · Score: 3, Informative

      Let's ask Bjarne the same question: List of C++ Applications
      Chop off half of the software applications on that list, at random -- can you still use your computer now? How about the internet?

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    9. Re:Too little and too much, way too late by FunkyELF · · Score: 1

      It only uses C++ because it was originally XBMP (xbox media player) which had to be built using an illegally obtained XDK where C and C++ were the only choices.
      Had other languages been available, I'm sure it would've been written using them.

    10. Re:Too little and too much, way too late by wondafucka · · Score: 1

      > Games developers, a few corporate app maintainers and...

      Most Mozilla project applications including Firefox.. Pretty much all of KDE and some of GNOME. WebKit. Google Chrome. Opera. A good chunk of OpenOffice. Most Adobe applications. Most Microsoft desktop applications including Internet Explorer. CUPS. The Qt toolkit and pretty much everything that uses it. MySQL. Autodesk Maya. Winamp.

      I wouldn't say a *few* corporate apps are written in C++, I'd say pretty much every major desktop app that's undergone a major re-write within the last two decades is probably C++.

      ...National Instruments, Teradyne, pretty much any hardware interface vendor will provide a C++ instrument driver. All your pretty toys and joys of modern life have components that are tested and researched using the language. (Unless they are using LabView, but let's not go there).

    11. Re:Too little and too much, way too late by derGoldstein · · Score: 1

      Just a clarification... I meant to reply to the parent post. I just had a brain fart because I read the line "but who uses C++ these days?" and starting seizing and foaming at the mouth, and I pressed the wrong "Reply to This" button.
      Man, that was high-quality flamebait.

      (I use C++ for almost everything in which the environment *lets* me use it, so I was the right target I guess)

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    12. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      >I realize that stats from Tiobe index, Sourceforge, Langpop and other sources are merely an educated guess as to what people are really using

      Ask the slashdot crowd what programming language people are using is like asking customers in McDonald's about nouveau cuisine.

    13. Re:Too little and too much, way too late by Is0m0rph · · Score: 1

      What are you talking about? There's tons of work in the US for C++ developers. My job right now for a large company has everything written in C++. C++ is everywhere in the controls and semiconductor industries too.

    14. Re:Too little and too much, way too late by derGoldstein · · Score: 1

      ...It certainly beats the opinion of some individuals who are biased toward their favorite (or least favorite) languages.

      I'd also say it's less religious. I mean compare C++ programmers to Java programmers, or, dare I mention -- Perl programmers (and I used to program in both for years... Criticism of the languages themselves was not taken well).

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    15. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Device drivers, operating system libraries, compilers, tons of retail software, etc. etc.

      In fact, libraries that provide a C header file may actually be implemented in C++. I agree with the fact that C++ is barely used in corporate applications anymore in favor of RAD-flavored languages, but most everything else is still done in C++.

    16. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Virtually all of the money-making bits of high-frequency trading software is written in C++.

    17. Re:Too little and too much, way too late by Anonymous Coward · · Score: 1

      I'd say pretty much every major desktop app that's undergone a major re-write within the last two decades is probably C++.

      s/probably/", unfortunately, "/

    18. Re:Too little and too much, way too late by capnchicken · · Score: 1

      I think that was covered with the burning out working at a bank bit, and really mostly working in a form of SQL anyway.

      --
      A libertarian shat on my carpet once. Claimed the free market would sort it out. -Ford Prefect(8777)
    19. Re:Too little and too much, way too late by shutdown+-p+now · · Score: 3, Informative

      That there is a code generator there is really an implementation detail. From programmer's point of view, signals and slots are really just a language extension, and could as well be implemented by the compiler directly.

    20. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Hell to get Java scripters, and yes they ARE scripters not real programmers, to froth at the mouth all you have to do is put Java and slow in the same sentence.

    21. Re:Too little and too much, way too late by capnchicken · · Score: 1

      My anecdotal evidence is showing again, but I have been involved in a fair number of pipe dream conversions away from COBOL and C++ to things like Java and C#. To me it looks like it is losing mind share from small business CIO's and the youth.

      And besides those behemoths (which 20-30 years ago, fyi, these same points were being made against COBOL), I think the point the GP is trying to make is that nothing really new is coming out that excites people about it being developed in C++ (besides gaming). It has become more of a chore, a weeder language, a necessary evil in the minds of a lot of youth today (anecdotal!) like learning x86 Assembly was (and in some cases still is) in the past.

      The fact of the matter is: C++ is playing catch up. There is nothing new here, those features are being supported in production environments in other languages. Better late then never sure, but not fixing the <<template>> for a dozen years is inexcusable (especially in light of detailed compiler errors) and trumps arguments that it took so long to fix because it is a slow moving rock of stability.

      --
      A libertarian shat on my carpet once. Claimed the free market would sort it out. -Ford Prefect(8777)
    22. Re:Too little and too much, way too late by mswhippingboy · · Score: 1

      Java scripters, and yes they ARE scripters not real programmers

      That's a typical example of what the GP is referring to. I do a good deal of both C++ and Java and you obviously don't know squat about either to make an idiotic statement like that.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    23. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Awww, is the Java weenie gonna cry in his cornflakes?

    24. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      There's still a market for low level C programmers, and for Java, C#, Perl, Python, VB, and just about everything else, but who uses C++ these days? Games developers, a few corporate app maintainers and... uh... hang on...

      Note carefully: I love C++, with all its fragmentation, bloat, gotchas and non-standard-standard-libraries, but really, it's a niche language now, kept alive by beardy wierdies and a few caffeine soaked kids who'll burn out and end up writing SQL for banks in a couple of years. Interesting, but hardly news that matters.

      More like, what does not use C++. Web/cloud applications, Enterprisey corporate stuff and... uh... hang on.

      But I'm sure you're just trolling, really.

    25. Re:Too little and too much, way too late by h4rm0ny · · Score: 1

      To me it looks like it is losing mind share from small business CIO's and the youth.

      Seems so amongst "the youth" at least. Shamelessly anecdotal but I had some fresh out of uni graduate sneering at me because I wrote some applications in C++ (actually, also sneered for using C when I was writing a device driver). He felt superior because he used Python and wrote Django apps. *sigh* Using something created by clever people, does not make one clever oneself. But the point was lost on him. (Disclaimer: I use Python myself from time to time, when appropriate).

      I don't know what it is. Perhaps it is that Universities want to be up to date and so blazon how they are teaching the latest languages (and it's good to keep current - I do), but in doing so they try to tell their students how well-rewarded and special they are for learning said language and what utterly the bee's knees it is. So they come out looking down on what came before. A destructive cycle.

      Or maybe it's just that learning C and C++ is hard in this day and age (or rather it looks hard to modern eyes). And a certain mindset disparages that which it can't or wont do.

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    26. Re:Too little and too much, way too late by h4rm0ny · · Score: 1

      A good programmer is a good programmer in almost any language. But I think there actually is a perceptual shift at work because C++ has been around a long time and those that remain in the language tend to be very experienced and good programmers. Younger and more inexperienced programmers are more likely to have learnt JAVA than C++ and so when an experienced programmer talks encounters an inexperienced one, it is not uncommonly a C++ programmer encountering a JAVA programmer.

      Hell, I once did good programming in Visual Basic (pre .NET). Two weeks after starting I had half the other programmers there coming to ask me how to do things and I had only learnt the language the week before. Of course I had learnt programming in C++, not from a book that started with "to create a form, drag this icon onto your workspace. Now you can add buttons!". Nonetheless, the first thing that goes through my head when I hear "Visual Basic" is 'out of their depth scripter'. And for a lot of C++ programmers, the word JAVA triggers the thought "Lego coder". It will change, no doubt.

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    27. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Well, as someone who writes real-time, embedded systems, I got to say that Java sucks. And don't even get me started on this "real-time Java" nonsense. I prefer languages that are actually deterministic (C, C++, Ada). Java object don't even have deterministic lifetime. You can't even do RAII!

    28. Re:Too little and too much, way too late by mswhippingboy · · Score: 2

      And for a lot of C++ programmers, the word JAVA triggers the thought "Lego coder". It will change, no doubt.

      I understand your point, but I would argue that a really good programmer that only knows a single language does not exist. I don't see how one can become a good programmer without a little intellectual curiosity which would drive them to experiment and learn other languages. I started out many moons ago with Assembler, Basic, Fortran and COBOL, tried LISP (didn't like it), moved on to Pascal and PL/I, then picked up C, followed by C++, tried Objc-C (didn't like it) then Java, Perl and later C#, Groovy, Javascript and various scripting languages. I'm now kicking the tires or Scala, Python, PHP, Go and Erlang. Not one of these languages is "unworthy" of me. Every one has it's merits and is interesting for their unique attributes (even the ones I didn't like).

      C++ programmers who dismiss others with experience in these other languages are showing their ignorance , inflated ego, or probably both. If a C++ programmer makes statements like "Java scripters are not real programmers", chances are they aren't nearly as good a C++ programmer as they think they are.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    29. Re:Too little and too much, way too late by Anonymous Coward · · Score: 1

      I've gotten the same thing from some Ruby guys. Don't bring up performance, apparently that "doesn't matter any more these days".

    30. Re:Too little and too much, way too late by h4rm0ny · · Score: 1

      You know, I agree with everything you just said. I too have a pile of programming languages under my belt. Heck, I seem to have learnt PHP entirely by accident since I don't recall ever actually meaning to learn it but just seem to have sat down and started coding up some web applications in it one day. As you say, a good programmer is a good programmer and one shouldn't characterise anyone by what language they use.

      Oddly enough Java isn't one of the languages I know. I guess I just felt that being fluent in C++, I had that problem space covered and learned other things like Python instead. Also, it just wasn't as much fun as C++. Felt like typing in mittens, though it could just be lack of familiarity. Fun is a hard one to categorise or predict. Probably the most fun language I know right now is D. That's partly because I'm still learning it, but it covers the same problem space as C++, but has a certain lightness of feel to it which really lends itself well to my taste. I like programming in Python for example, but I can never quite lose the muggy lack of power feeling. Whereas D restores that.

      Anyway, I went off-topic. I agree with you post. :)

      H.

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    31. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Not true at all. I've worked at 4 HFT firms. The two best and fastest used Java. Even GETCO uses Java for some of its systems. You just have to have a very good team to do it.

    32. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      I disagree!

      Since C++ is almost fully downwards compatible you could try to find all those C applications that actually were compiled with a C++ compiler.

    33. Re:Too little and too much, way too late by Palshife · · Score: 1

      The world runs on C++. You're ignorant.

      --
      Attention deficit disorder is a complicated issue, spanning several major... HEY LET'S GO RIDE BIKES!
    34. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      The thing is, I don't think anyone has ever written a pure-C program unless their compiler demanded it. Consider the following:

      void main(int argc, char * argv[])
      { //My first program
          printf("Hello world!");
      }

      This program will not compile as C as C99 doesn't support single line comments and requires that the main function return type int. Since the popular compilers are not pedantic by default, I think even if someone intends to write a C program, it will become C++ simply to allow use of single line comments. I really don't think a C/C++ distinction can be made since one is a superset of the other.

    35. Re:Too little and too much, way too late by maxwell+demon · · Score: 1
      --
      The Tao of math: The numbers you can count are not the real numbers.
    36. Re:Too little and too much, way too late by jlarocco · · Score: 1

      I wouldn't go so far as to say it's a new language, but IMO Qt is what the C++ standard library should have been.

      The C++ standard library and STL are terrible compared to the standard libraries of any other modern languages. Qt actually makes C++ programming fairly painless.

    37. Re:Too little and too much, way too late by smellotron · · Score: 1

      I wouldn't go so far as to say it's a new language, but IMO Qt is what the C++ standard library should have been.

      I think any C++ "bearded weirdie" will point out that your desire is specifically what makes C++ so great. There's no requirement that you use libstdc++ - go ahead and #pragma GCC poison std and use only Qt*. No wise man will ever begrudge you for preferring one large, opinionated toolkit over the other large, opinionated toolkit.

      * I don't know if that trick actually works with Qt, but it's worth a shot.

    38. Re:Too little and too much, way too late by mswhippingboy · · Score: 1

      Java was never suited for realtime development. In fact, the original EULA for Java spelled that out. There is a spec for Java RTS (JSR-001) which is supposed to address "some" of the concerns for real-time systems, but I know next to nothing about it and would be reluctant to recommend it for RTS. Generally, any system that does garbage collection is going to be unsuitable for RTS. This includes C#, Obj-C2, Python, Lisp, and a host of other languages.

      However, believe it or not, there is software other than embedded real-time systems.

      For systems that don't have the constraints imposed by RTS, garbage collection is a great feature. Not only does it make the programmers life easier, it can (if not abused) make memory leaks and data corruption a thing of the past.

      No one in their right mind would use Java for RTS, but by the same token, no one in their right mind (today) would use C, C++ or Ada to develop a web application, business application or other software system for which being deterministic is not a critical factor. There are just too many better (as in higher programmer productivity) language systems than C/C++ for these type of applications.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    39. Re:Too little and too much, way too late by The+End+Of+Days · · Score: 1

      As a lesbian grandmother who codes in assembly language, I think I love you.

    40. Re:Too little and too much, way too late by aiht · · Score: 1

      ... for which being deterministic is not a critical factor.

      I trust that you are referring to deterministic timing in a real-time system, rather than deterministic results in general? In my experience, business applications usually benefit from producing the same results repeatably. ;)

    41. Re:Too little and too much, way too late by m50d · · Score: 1

      Qt is great, but it's even better if you use it from Python.

      --
      I am trolling
    42. Re:Too little and too much, way too late by Rogerborg · · Score: 1

      Man, that was high-quality flamebait.

      Thanks, I try to raise my game when the subject merits it. It's nice to have my efforts recognised.

      --
      If you were blocking sigs, you wouldn't have to read this.
    43. Re:Too little and too much, way too late by Rogerborg · · Score: 1

      I said "market", not hippyware. Money can be exchanged for goods and services.

      --
      If you were blocking sigs, you wouldn't have to read this.
    44. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      I believe you are arguing my point. Every language has its suitability. I've know Java dudes who want to shoehorn it into everything, thinking its the end-all-be-all. They like to bash C++ without really understand it. In the real-time world, I might use Java for a GUI tool, but I would never write the actual real-time system with it, not even the so-called "real-time Java."

    45. Re:Too little and too much, way too late by mswhippingboy · · Score: 1

      Yes, deterministic in the context of the discussion - RTS.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    46. Re:Too little and too much, way too late by kv9 · · Score: 1

      jack of all trades, master of none. dismissed.

    47. Re:Too little and too much, way too late by Nutria · · Score: 1

      I had some fresh out of uni graduate sneering at me because I wrote some applications in C++

      25 years ago, it was COBOL programmers that we fresh Uni grads sneered at.

      (Then I got a job programming... COBOL and learned what an excellent and powerful domain-specific language it is.)

      --
      "I don't know, therefore Aliens" Wafflebox1
    48. Re:Too little and too much, way too late by mswhippingboy · · Score: 1

      No, just 35+ years of (~12 hrs/day) heads down development. I still use (as in getting paid for using) nearly all of these languages from time to time. No language is an island unto itself and all languages are related to other (previous) languages to some extent so that when I encounter a new language it tends to build on what I've already learned. I don't claim to be a "master" of anything and I'd dismiss immediately anyone who did make that claim.

      I've always been interested in computer languages and spent a good deal of time studying compiler and language design, including a period of time spent helping to develop the ANSI X3.74-1981 spec for "PL/I General-Purpose Subset".

      I do claim competence in what I know and my clients can vouch (and do vouch with their $$$) for that. I do question the intellectual abilities (and sanity) of anyone who can spent 35 years in software development and still only knows one or two languages.

      Now you're dismissed.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    49. Re:Too little and too much, way too late by JBMcB · · Score: 1

      You're right.

      So, Microsoft, Adobe and Google products don't count?

      --
      My Other Computer Is A Data General Nova III.
    50. Re:Too little and too much, way too late by Rogerborg · · Score: 1

      We can't all work for Microsoft, Adobe and Google. You'll learn that when mom kicks you out of the basement.

      --
      If you were blocking sigs, you wouldn't have to read this.
    51. Re:Too little and too much, way too late by JBMcB · · Score: 1

      Oh. So, to correct your first post - no companies that you are a proficient enough programmer to work for use C++, therefore it doesn't matter to you, therefore it shouldn't matter to anyone.

      Gotcha.

      --
      My Other Computer Is A Data General Nova III.
    52. Re:Too little and too much, way too late by Anonymous Coward · · Score: 0

      Or maybe youth and inexperience never really changes, and you're just old and crotchety and you feel like lashing out at someone for being young.

      That seems pretty likely, given the conclusions you reach and the attitude you express.

    53. Re:Too little and too much, way too late by h4rm0ny · · Score: 1

      Or maybe youth and inexperience never really changes, and you're just old and crotchety and you feel like lashing out at someone for being young.

      If youth and experience never changes for you, who are you? Dorian Gray? Silly to argue that longer experience in programming doesn't have an effect on your ability to program and that differences in programming ability don't then inform your attitudes.

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
  8. Re:c++ 1x sucks by jythie · · Score: 1

    Sadly, designers do not have much interest in 'fixing' things when they can design new stuff AND increase the number of places their design can be used. That is the problem with C++... the people steering it want a language to solve all problems, and increasingly it becomes worse at solving any,.. or at minimal the increasing number of solutions to any given problem embedded in C++ makes understanding it more and more difficult.

  9. /puke by jimmerz28 · · Score: 0

    I think they could use a graphic designer for "The number one developer site!".

    1. Re:/puke by Eudial · · Score: 2

      Don't judge a website by the stylesheet.

      --
      GAAH! MY PRINTER IS ON FIRE!!! PUT IT OUT! PUT IT OUT!
  10. Is C++ ever the right tool for the job? by ron_ivi · · Score: 4, Interesting

    It seems to me that most tasks that seem good for C++ would be better handled using a mix of an easier-to-program language (Ruby, Python, heck even lisp or smalltalk or anything else) with C extensions.

    IMHO C++ seems not very good at very low-level programming; since with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules. In C you're using a pretty good tool for low-level programmings (especially with a dialect where you can sneak in a few assembly calls where you need to). In Ruby you're using a reasonably nice and efficient to develop in OO language. With the incredible ease of writing C extensions for Ruby, it's easy to use the best tool for each part of the job you're doing. The only compelling reason to use C++ I can think of is if some political policy forces you to use a single language for an entire project; and then I guess C++ not quite as clunky as java or c#.

    ( though I'm kinda repeating myself - a longer rant I made on slashdot about the pains of C++ years ago is here http://slashdot.org/comments.pl?sid=100202&cid=8540772 . An even more condemning annoyance about C++ is that thanks to so many convoluted tricks in the language, most people who claim C++ knowledge don't actually know it, as evidenced by the comments in that old thread )

    1. Re:Is C++ ever the right tool for the job? by dkleinsc · · Score: 0

      I started in on C++ as my second programming language, back in my larval days on a classic IBM PC.

      My first impression of it was "Wow, this OOP stuff is fantastic, it makes everything so much more clear!" My second impression of it once I started to build more complex things was "Yeaargh, this is so inconsistent and confusing!".

      So I switched to something easier, and learned old-school Intel assembler which I used to mess around with DOS internals.

      --
      I am officially gone from /. Long live http://www.soylentnews.com/
    2. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 4, Insightful

      I tried to use ruby for a while, but ended up back with C++. I couldn't live without static typing, as it turned out, and also C++ had more libraries leading to faster development (for me, at least).

      C++ is the worst language, excepting every other language I have tried. And I am happy about the new features, they should make coding much nicer.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    3. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Is this a joke?

    4. Re:Is C++ ever the right tool for the job? by Monkeedude1212 · · Score: 1

      The only compelling reason to use C++ I can think of is if some political policy forces you to use a single language for an entire project;

      I think you answered your own question there.

      I've found that a lot of 'outsourced' programming jobs go to people who only know one language. And that language tends to be C++, because its easier to teach someone 1 language than it is to teach them the theory and how it applies to 5 languages.

    5. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      If you want to use an OO language for an embedded system, especially real-time embedded systems like aircraft, C++ is still a good option. With C, you're constantly forcing the language if you want to apply OO principles in a meaningful way (especially if you can't trust some of your programmers to follow it carefully, as in my group). Something like Ruby or Python is obviously out, as are Java, C#, etc.—the very things that make those so nice are what rule them out from use in an environment like that. There are other languages that might do the trick, but—as in the case of C before it—one of the most compelling arguments for C++ is its ubiiquity and the wide availability of support and tools for it.

    6. Re:Is C++ ever the right tool for the job? by godrik · · Score: 4, Informative

      I aggree that people tend to do too many things in C++ (me first). However, there are quite some place where C++ should be used. Mainly gaming engines and high performance computing. You NEED low level programming to deal with that. They could be written in C. But numerous C++ programming techniques (mainly template mechanism) makes it much easier to program. You could not get reusable algorithm accross multiple data type with efficient compile-time type checking at no runtime cost without templates. You could do it with macros but you will have terrible compilation problem if you screw up. Or you could use inheritance but will pay the cost at runtime.

    7. Re:Is C++ ever the right tool for the job? by robbyjo · · Score: 1

      Yes. C++ (and Java) are indispensable for scientific software. In scientific software, the spec is ever changing as the science progresses and hence the flexibility to morph the programs as needed and maintainability are of paramount importance. On the other hand, we need the speed.

      Some of these can be resolved by invoking ready-made C libraries and then called in higher level languages such as Python or R or Matlab. However, in many occasions, this luxury isn't available (e.g., Markov Chain Monte Carlo simulations or custom EM algorithm).

      --

      --
      Error 500: Internal sig error
    8. Re:Is C++ ever the right tool for the job? by Monkeedude1212 · · Score: 3, Funny

      No. THIS is a joke.

      Two bytes meet. The first byte asks, “Are you ill?”
      The second byte replies, “No, just feeling a bit off.”

    9. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 2, Insightful

      No offense but you have to be stupid to not know what + does. If it does something unexpected, chances are you wrote it incorrectly yourself, or are using a terrible library that has undocumented operators that are working incorrectly on top of that. It's not the languages fault when programmers code like retards.

    10. Re:Is C++ ever the right tool for the job? by GreatBunzinni · · Score: 1

      You have to take into account the absolute pain which is to manage a multi-language project, let alone debug any problem. Moreover, the level of mind-numbing bloatedness which interpreted languages such as those you described (ruby, python and the like) may, in your opinion, make a language a bit easier to program in, but in practical terms it leads to terribly bloated software which, unless you are running a high end desktop, runs mind-numbingly slow when compared with native, 100% C++ apps.

      --
      Slashdot, fix your code or at least hire someone who is competent at it to do it for you.
    11. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 5, Informative

      It seems to me that most tasks that seem good for C++ would be better handled using a mix of an easier-to-program language (Ruby, Python, heck even lisp or smalltalk or anything else) with C extensions.

      IMHO C++ seems not very good at very low-level programming; since with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules. In C you're using a pretty good tool for low-level programmings (especially with a dialect where you can sneak in a few assembly calls where you need to). In Ruby you're using a reasonably nice and efficient to develop in OO language. With the incredible ease of writing C extensions for Ruby, it's easy to use the best tool for each part of the job you're doing. The only compelling reason to use C++ I can think of is if some political policy forces you to use a single language for an entire project; and then I guess C++ not quite as clunky as java or c#.

      ( though I'm kinda repeating myself - a longer rant I made on slashdot about the pains of C++ years ago is here http://slashdot.org/comments.pl?sid=100202&cid=8540772 . An even more condemning annoyance about C++ is that thanks to so many convoluted tricks in the language, most people who claim C++ knowledge don't actually know it, as evidenced by the comments in that old thread )

      I disagree on several points. C is great for low level programming, but many times you want to use OO rather than procedural programming. C++ allows you to do exactly the same low level programming you can do in C (including inline-assembler if needed), but also offers the ability to design in OO. I can't think of a good reason not to use C++ rather than C unless it is a simple monolithic (preferably small) project. Mixing languages brings a whole other set of headaches (including staffing issues). Ruby, Python or other languages are fine and have their place, but I can't imagine using them for systems level programming anymore than I would use C++ to build a web application. Languages like Python, Ruby, (errr.. LISP? - there is considerable debate over whether LISP is even a true "programming language" but rather an alternate implementation of a Turing machine, but I digress) are orders of a magnitude too slow to be used as systems programming languages.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    12. Re:Is C++ ever the right tool for the job? by Prune · · Score: 1

      So let's see--you basically wrote that high level programming is confusing compared to assembly. Well yes, primitive operations like mov and sub and push are indeed quite trivial to reason about compared to multiple inheritance and template metaprogramming. So? Flying to the moon is more complicated than driving to the local Walmart as well--it doesn't make it any less worthy.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    13. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 5, Informative

      I used to be a huge C++ fan, though that has waned over the years as I've used better-designed languages and have also seen other people struggle with C++'s testier features.

      That said -- I'd still take C++ over plain C for essentially anything in a heartbeat. (Basically the only exception would be stuff like microcontroller programming or other environments where there isn't really a good C++ compiler.) RAII alone is enough to seal that deal.

      I don't buy most of the arguments of C over C++. For instance, take your statement that "IMHO C++ seems not very good at very low-level programming; since with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules."

      But with modern compilers, I feel it's already very not obvious what the compiler is going to do with your code. What function calls are inlined? What loops are unrolled? For what I think is a reasonably dramatic example of this, take the following snippet:

      int main(int argc, char** argv) {
          int y = 50;
          if (argc > 1) {
              y = 100;
          }
          return y;
      }

      and compile with optimization on. Look at the resulting assembly. There's no branch! (I'm assuming a variant of x86 or x64 here.)

      If you're on a 64-bit system with GCC you'll probably see a cmov (conditional move) instruction, which kind of makes sense. But you don't even need that instruction to be available for it to omit an actual control-flow jump. Recompile with -m32 and look at the assembly again. Much longer, but still no branch. Instead, it uses one of the setxx instructions (setg in my case) and a bit of bit twiddling.

      In my opinion, today's optimizers make the generated code so far removed from what you type into your editor that saying "+ can do anything!" is a drop in the bucket.

    14. Re:Is C++ ever the right tool for the job? by Prune · · Score: 2

      Indeed, C++ is just as easy as C to use for low-level programming, as not only do you have the option of inline assembly which mixes easily with the rest of your code, but you even rarely need to resort to it as in the major compilers (MSVC, gcc, Intel C++) there is a plethora of compiler intrinsics which almost directly map to assembly instructions while providing a type-safe interface. It's quite easy to write synchronization primitives, for example, using interlocked operation intrinsics--while the same have a nice object-oriented interface. Just because C++ is large and has a multitude of features in no way implies that you need to try to use all of these features. You might as well complain that the library has too many books! It's ultimately a matter of programmer discipline; stop shifting the blame.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    15. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      errr.. LISP?

      No, it's called erlang.

    16. Re:Is C++ ever the right tool for the job? by Spykk · · Score: 4, Informative

      If you don't like operator overloading then don't use it. I don't see how that has any effect on C++'s usefulness as a low level language. C++ can use inline assembly the same way C can. C++ has all the power of C with the convenience of classes.

      There is no mandate that you must use templates or operator overloading in C++. If you are going to complain that it gives you the option then why aren't you complaining about C having goto?

      In my experience when someone wants to use C over C++ for a new project it is generally because they don't know C++.

    17. Re:Is C++ ever the right tool for the job? by derGoldstein · · Score: 4, Funny

      You moved from portable, scalable, flexible C++ to an architecture-specific assembler? Ah, I see you were modded up. Good, Slashdot is working perfectly today.

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    18. Re:Is C++ ever the right tool for the job? by lederhosen · · Score: 1

      Most applications should not be written in C or C++., they should be written in a more high level language, where certain kinds of mistakes can not be made.
      Some time critical stuff can be written (as you suggest) in small parts in C to make it perform well. For some stuff you can not mix the C language with languages like Python, Java or C# because latency is a factor, and you want real time behaviour (that is, no garbage collection). Then C++ is a great choice.

    19. Re:Is C++ ever the right tool for the job? by SanityInAnarchy · · Score: 2

      I don't think the point was what sort of optimizations might be employed or what the resulting binary would look like. It's not about implementation, it's about semantics.

      For instance, in C, the bit shifting and boolean operators have precise and well-defined meanings. I know that anything which compiles with one of those operators is going to do exactly what that operator says. I personally don't have a problem with operator overloading (and truly miss it in Java), but in C++, the standard library co-opts those operators and perverts them into something else, to the point where when I was first learning C++ (without learning C), I thought data, which means I need bitwise operations to do what they're supposed to do.

      Now, I don't think that's actually an argument against C++. If I don't want to be confused by operator overloading, I'm not forced to use it, and I think the benefits (when used properly) far outweigh the problems (when abused) -- and I think that's true of many language features people like to complain about. But I do think that's what GP was getting at -- it's not what physical instruction it might turn into, it's what the actual semantics are.

      --
      Don't thank God, thank a doctor!
    20. Re:Is C++ ever the right tool for the job? by derGoldstein · · Score: 3, Interesting

      C++ allows you to work at a level of abstraction that you need right now, for this function or section/area of the program. It gives you this ability while not forcing you to inline other languages, but you *can* compile C alongside it in cases where there's already a C library that does specifically what you want (and almost all task-specific libs are written in C, across most languages). No other language can boast anything near this level of flexibility. Can it be messy? Definitely. But good software structures will look clean and logical no matter where you look along the spectrum of abstraction ("spectrum of abstraction"... I need to remember that next time I publish something intended for academia...).

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    21. Re:Is C++ ever the right tool for the job? by SanityInAnarchy · · Score: 1

      I can't speak for GP, but I'm not the type to bitch and complain because something is hard. I'm the type to make it easier, or switch to a language where it is easier.

      You, on the other hand, are the type I would never hire. What right do you have to waste your employer's time and resources in a giant dick-waving contest? Sure, if it has to be fast, C++ is a good choice -- but as GP pointed out, C might be a better choice. If it doesn't have to run fast, we then need another set of skills which are just as difficult to master -- working efficiently (20 lines of Ruby versus two hundred of C++), making something maintainable and reliable (a tenth the code and infinitely fewer buffer overruns), and something flexible enough for future growth, but on the market today.

      And if it's about the big bucks, or even the big important code that runs big important shit, you're better off doing COBOL. Me, I have a bit less of an ego and a bit more pride in my craft.

      --
      Don't thank God, thank a doctor!
    22. Re:Is C++ ever the right tool for the job? by derGoldstein · · Score: 1

      Also, as the C++ evolves and adds new features, it's easier to "upgrade" software that was written years ago, as long as it was object-oriented. STL libs weren't always around (or "standard", or stable), but eventually you could use vector<> pretty much anywhere you needed an array.

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    23. Re:Is C++ ever the right tool for the job? by dkleinsc · · Score: 1

      Yes, I did, and it really came in handy when I started learning other bits-and-bytes kind of stuff. Concepts like registers, memory blocks, the CPU cycle, etc. Learning MIPS assembler 10 years later in college was a breeze after this stuff.

      --
      I am officially gone from /. Long live http://www.soylentnews.com/
    24. Re:Is C++ ever the right tool for the job? by shutdown+-p+now · · Score: 1

      The reason why C++ remains popular is that it is high-level enough (between core language features, and things that can be implemented as a library), but still lets you interface low-level (i.e. C) things directly with no glue code necessary, no type system mismatch, and so on. The only language on the market today that can match this ability is Objective-C, but it has its own quirks.

      You can write things essentially Java-style in C++. Heck, you can even have GC!

    25. Re:Is C++ ever the right tool for the job? by vadim_t · · Score: 1

      The thing about operator overloading is more about code reading than the internals of what gets generated.

      In C, when you come across "a = b + c;" you know perfectly fine what's going on. Sure it might not generate exactly that in assembly, but what the code is actually doing is perfectly clear.

      In C++ though any arbitrary amount of weirdness can happen if there's overloading, including things like memory allocation, file I/O, database or network access, if the overloaded operator does it for some reason. So you have to be paranoid and check the class definition just in case. It's a function call masquerading as an operator, and that can lead to a lot of confusion.

    26. Re:Is C++ ever the right tool for the job? by Desler · · Score: 0

      runs mind-numbingly slow when compared with native, 100% C++ apps.

      And yet the vast majority of mind-numbingly slow apps I've ever used were usually written in C++.

    27. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      If the OP was concerned about semantics, then why the specification that particularly matters for low-level coding?

      And of course if we go there, then I feel even more strongly about my position because "I think the benefits (when used properly) far outweigh the problems (when abused)" describes my position as well, except I probably would have italicized "far".

      This is off-topic from this particular thread of the discussion, but I also remembered the other objection to C++ that's developed: language interop (using C++ stuff in other languages) is usually nigh impossible. From what I can tell the best way to do language interop to C++ is to write a C wrapper for the C++ stuff, then interface to the C wrapper.

    28. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 2

      I'm a pretty big defender of C++ if only because it often gets trashed, but I think "if you don't like operator overloading, don't use it" isn't a particularly helpful or even accurate position to take. The problem is that you basically never write a program in a vaccum; you basically always use libraries. Does one of the libraries you want use operator overloading? If so, then you either have to use operator overloading or find a different library.

      Hell, when your language's canonical "hello world" program uses operator overloading, I think it's safe to say that it's just something you'll have to deal with in that language. The standard library uses it all over -- iostreams, containers, etc.

    29. Re:Is C++ ever the right tool for the job? by derGoldstein · · Score: 1

      I mostly agree.
      However: look into the work that Google has been doing with javascript interpreters. There are tasks for which C++ simply isn't fast enough to write, and you need to modify the code very often. In these cases you'd need 4 times the manpower to get the job done, and maintained, while computing power (in certain cases) is cheaper. It depends on the task.

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    30. Re:Is C++ ever the right tool for the job? by Desler · · Score: 1

      The shit that runs the shit that runs Ruby? Fuckin C.

      FTFY.

    31. Re:Is C++ ever the right tool for the job? by derGoldstein · · Score: 3, Insightful

      That's simply the fault of the way (or order) that CS is taught (at some places). Using C++ shouldn't have stopped you from learning about registers, memory blocks, and simply digital logic along with micro-architectures. Did you expect C++ to teach you CS, or expect not to need to learn CS if you used it? You're blaming C++ for a separate problem.

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    32. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Yes, I did, and it really came in handy when I started learning other bits-and-bytes kind of stuff. Concepts like registers, memory blocks, the CPU cycle, etc. Learning MIPS assembler 10 years later in college was a breeze after this stuff.

      Every programmer should know those things. It might be a little extreme, but IMO you can't even call yourself a programmer if you don't have a clue about what happens under the hood.

    33. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Ugh. You're an idiot.

    34. Re:Is C++ ever the right tool for the job? by derGoldstein · · Score: 1

      Ok. Now imagine how mind-numbingly slow they'd be if they were written in any other language.

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    35. Re:Is C++ ever the right tool for the job? by npsimons · · Score: 1

      First, just let me preface this by saying C++ is my bread and butter; I write about 90% of my code in it these days, mostly because I'm a maintenance programmer (but don't let that fool you; much of the stuff I "maintain" I have to re-write from scratch (or almost scratch) because the code is nowhere near clear).

      To me, C++ has a lot going for it: it's pretty much as fast as C, and much more clear with powerful language constructs. I'm not much of an expert on other languages (I'm mostly a depth-first learner), but I've yet to see another language have something as powerful as templates/generics (besides Ada, which is where C++ got them from). The fact that you can do compile-time programming speaks volumes for the power of templates.

      Now I'll grant you that it's not always clear what C++ does behind the scenes - but this is true of the other languages you listed, and is mostly a performance problem anyway. If a programmer understands an abstraction (and a programmer *should* understand the abstractions he or she uses), then it's not a problem. Two books I can highly recommend that not only clear up what C++ does behind the scenes, but teach a lot of good coding technique besides are "Thinking in C++" volumes one and two. Sure, they may be 1600 pages combined, but you learn a lot.

      A bigger problem I see with C++ is that it is, to put it politely, a "federation of languages", and most people don't even realize it. I've heard that many shops end up picking just the pieces of the language their programmers are familiar with and forbidding the use of anything else, which is fine until someone stumbles on to something they don't understand.

      Me, I learn what I use, and what I use is C++ because that's what the software I'm maintaining is written in. Perhaps one day I'll delve as deeply into another language as I have with C++, but I've already picked up a number of programming concepts I wasn't proficient with before (coming from C and Perl), so I have to at least defend C++ for being a powerful and fast language.

      An interesting link you might like: C++ is Good for the Economy, It Creates Jobs!.

    36. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 5, Insightful

      So you have to be paranoid and check the class definition just in case.

      So I have two responses to your general comment, though they are related.

      You don't need to check the class definition at all -- you just need to know that one of the operands is an object. That's all. IMO, that's the only* difference between an overloaded operator call and a normal function call.

      Once you're at that point, I don't see any difference between calling the function "+" and calling the function "doSomethingSimple". If you're paranoid enough about the class defining "+" in a way that will cause it to open sockets and thus you have to check the class definition to see if it does, you should be equally paranoid that "doSomethingSimple" will do the same thing and you have to check the class definition anyway.

      The second part of my response is this: why do you CARE what "+" does internally? I can think of two reasons.

      First, because you're concerned about efficiency. I've already said why I think this is a red herring, especially because I suspect most overloaded operator functions will be inlined to something efficient in general other way.

      The second reason is because you want to know whether "+" is a good name for that function. But again I don't see how this differs from normal functions. If I call a function add and write a.add(b) instead of a + b, why are you more suspicious about the latter? I can come up with bad names without operator overloading plenty easily enough. Hell, I come up with bad function names for my non-overloaded functions far more often than bad function "names" for my operators. (And that even neglects the personal opinion that the normal convention of a.add(b) for a + b -- e.g. like what's used in Java's complex class -- feels wrong to me. a.add(b) feels way more like a += b than a + b to me. But again -- this isn't the fault of Java not supporting operator overloading per se, but rather the fault of Sun's function naming.)

      * Okay, there is one other difference. Operator overloading is cool and tempting to use. It invites abuse way more than function naming does. But some high-profile cases aside (in particular, the proposal to overload the comma operator or whatever it was to load containers, a la Vector v = 4, 5, 6, 7, 8; or something), it certainly seems to me that, in practice, programmers are actually able to hold their tongues pretty well. Strangely enough, the biggest exception to this, I feel, is the bitshift overloading in iostreams. And IMO, that's easy enough to learn and brings about enough benefits (I/O type safety, non-repetition of type information, and extensibility vs a printf-style interface, and way less syntactic overhead vs repeated function calls) that it's probably the best solution even though it's not entirely satisfactory.

    37. Re:Is C++ ever the right tool for the job? by derGoldstein · · Score: 1

      How long is a double long if long long nibbled a bit?

      0: You look starved! Have a byte!
      1: Fine, I'll have a nibble.
      0: Let me just heat it up a bit.

      An int took a byte from a float and got a double slap to the face.

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    38. Re:Is C++ ever the right tool for the job? by dkleinsc · · Score: 1

      It didn't stop me from learning about that stuff. But assembler taught me that kind of stuff far more in depth.

      As far as whether I expected C++ to teach me CS, I wasn't thinking along those lines, because I was 10 years old. I was thinking "Hey, I can make this machine do all sorts of nifty things!"

      --
      I am officially gone from /. Long live http://www.soylentnews.com/
    39. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      portable, scalable, flexible C++

      There is a portable, scalable, flexible version of C++? Please tell me what that is, because I'd like to check it out and because it sure ain't the default version. :P

    40. Re:Is C++ ever the right tool for the job? by narcc · · Score: 1

      Well yes, primitive operations like mov and sub and push are indeed quite trivial to reason about compared to multiple inheritance and template metaprogramming.

      Wait, so you're saying that these sort of high-level abstractions intended to make programming and managing complexity easier have, in fact, made programming more difficult and increased complexity?

      If that were true, we'd be overrun by slow, over-sized, bug-filled software.

      Oh, wait...

    41. Re:Is C++ ever the right tool for the job? by vadim_t · · Score: 1

      Third reason: a large amount of what I do is maintenance. So when reading code it's very important for me to clearly see "something happens here". If I see a doSomething(), that's obvious. Overloading can muddle the issue. Add templates and whether it's an object or not will depend on what the template gets used on.

    42. Re:Is C++ ever the right tool for the job? by h4rm0ny · · Score: 1

      Try D. There are a few things still to be done with it and the community is small. But I started out with C++ and have tried a number of languages (couldn't stand Ruby but liked Python for some reason). Anyway, D is rapidly becoming my favourite language. There's a very good book called 'The D Programming Language' by Andrei Alexandrescu which I have on my Kindle and I have to say, it's one of only two occasions when a programming book has actually been really fun to read. The book and the language are an absolutely great experience which I recommend to any C++ programmer that really gets some satisfaction out of programming.

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    43. Re:Is C++ ever the right tool for the job? by h4rm0ny · · Score: 1

      Two bytes meet. The first one says, "do you fancy a nibble?"
      The second byte replies, "What do you think I am, a fucking peadophile?"

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    44. Re:Is C++ ever the right tool for the job? by h4rm0ny · · Score: 1

      True, but a lot of outsourcing goes to India now and I understand that JAVA is the popular one out there, so I'd say JAVA is the "one language everyone knows" these days.

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    45. Re:Is C++ ever the right tool for the job? by firewrought · · Score: 4, Insightful

      If you don't like $FEATURE then don't use it.

      I always cringe when I see this statement in a discussion about programming languages. The presence or absence of a particular feature will impact the third-party libraries you use, the code samples and tutorials you come across, and the legacy apps you inherit. Even if you develop in a vacuum, some features can impact you by accident [operator overloading isn't a good example, but implict-conversion-of-numeric-types-to-boolean is].

      In $FEATURE desirable or not for a particular programming language? Most always, that's going to be a complex usability/design question answerable by some combination of analysis, research, experience, testing, etc. Read the programming languages weblog or the discussion forums for D, Haskell, etc., to see the level of thought that goes into make these tradeoffs.

      --
      -1, Too Many Layers Of Abstraction
    46. Re:Is C++ ever the right tool for the job? by Prune · · Score: 2

      Overly simplistic.
      Both the tools and the products are more complex, but the increase in complexity of the former is lower than the increase in complexity of the latter.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    47. Re:Is C++ ever the right tool for the job? by SanityInAnarchy · · Score: 1

      If the OP was concerned about semantics, then why the specification that particularly matters for low-level coding?

      Maybe the semantics in question are those which are relevant to low-level coding?

      For higher-level stuff, there's less confusion. A string plus an integer, if it works, really only has one sane interpretation. ...maybe? I'm not sure anymore, and it seems like we mostly agree anyhow.

      --
      Don't thank God, thank a doctor!
    48. Re:Is C++ ever the right tool for the job? by noidentity · · Score: 2

      I disagree on several points. C is great for low level programming, but many times you want to use OO rather than procedural programming. C++ allows you to do exactly the same low level programming you can do in C (including inline-assembler if needed), but also offers the ability to design in OO.

      This is why I use C++ instead of C. I can start with basically C code, then mix in whatever C++ features are a benefit to the project, and ignore the rest. Currently I use a pretty small set which provides significant benefits over coding in plain C. Sure, there's unmaintainable C++ code out there, but I'm using the C++ language, not that code, so it's irrelevant to me.

    49. Re:Is C++ ever the right tool for the job? by noidentity · · Score: 1

      Besides, anyone who talks of operator overload misuse being a problem can just be rebutted by pointing them to macro misuse. In code with sane overloading/macro use, neither is a problem.

    50. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      (errr.. LISP? - there is considerable debate over whether LISP is even a true "programming language" but rather an alternate implementation of a Turing machine, but I digress)

      Where are there debates like this? I'd like to see them so I can laugh at whatever definition of "programming language" the proponents of that idea are using that excludes a language that is really good for writing programs in.

      (Or, probably more likely, see "Now, I haven't actually programmed in a Lisp, but...".)

    51. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 1
      It's not false nor misleading. LISP was originally created as a List Processing "system", not specifically a language. It describes an alternative way to implement a Turing machine. The original paper can be found at http://www-formal.stanford.edu/jmc/recursive/node4.html

      If my statement above offends you, then you misinterpreted my intent. LISP has it's place as a powerful tool for creating domain specific languages and as a macro processor (as used in emacs), in AI and mathematics, but is not and was never intended as a general purpose programming language.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    52. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Nop sorry plainly old C with vala (or genie) compiler gives me sane oop... and the resulting generated C code can be further "optimized" but its not really needed

    53. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 1

      I disagree on several points. C is great for low level programming, but many times you want to use OO rather than procedural programming. C++ allows you to do exactly the same low level programming you can do in C (including inline-assembler if needed), but also offers the ability to design in OO.

      I'm not sure C++ is really OO. Alan Kay, who invented the term, famously said that when he did, he certainly didn't have C++ in mind.

      While everyone focuses on the word "object" in OO, the more important part is message passing. To him, OOP means messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. That last point throws out more statically typed systems.

      C++ fails on the first, though something like Objective-C does not.

    54. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 1
      If you aren't aware of this debate, then I suggest you research the history of LISP. I've already covered this on another post. I'm not even sure where I stand on the debate as I can see points on both sides, but I'm not idiotic enough to pretend that there is no debate.

      It's not about whether there is a lot of LISP code out there - there certainly is - emacs is full of lisp macros. AI research and mathematics use it heavily.

      The debate is more about whether it fits the classic definition of a computer language.

      Classically, computer languages are defined by a specific, usually fairly extensive grammar, whereas the LISP grammar is basically

      expr: ID | STR | NUM | list
      list: ( seq )
      seq: | expr seq

      Again, this is not to say that it's not powerful or to deride it's significance, but to try and explain why there is legitimate debate over what constitutes a programming language.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    55. Re:Is C++ ever the right tool for the job? by godrik · · Score: 1

      If you believe C++ is the OOPC version of C. Do not use it. It is indeed pretty useless. C++ is good because of templates which only C equivalent is macros.

    56. Re:Is C++ ever the right tool for the job? by tepples · · Score: 1

      It seems to me that most tasks that seem good for C++ would be better handled using a mix of an easier-to-program language (Ruby, Python, heck even lisp or smalltalk or anything else) with C extensions.

      Which is why iPod touch apps are written in C with smalltalk extensions.

      with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading

      Nor in some of the languages you listed above. Python has __add__, the direct equivalent of operator +.

      and rather convoluted implicit casting rules

      "Convoluted" in that the compiler performs no more than one implicit conversion?

    57. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 1

      You're exactly correct. Smalltalk is one of the few languages that truly implement OO as it was originally described, but it's performance was less than optimal. C++ was an attempt to tack on OO features to the C language, but still maintain high performance. Objective-C was a similar attempt to extend concepts OO to C and perhaps truer to the original description of OO than C++, but it's implementation of message passing and dynamic binding resulted in inferior performance to C++, (not to mention ugly as sin syntax - just my opinion).

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    58. Re:Is C++ ever the right tool for the job? by icebraining · · Score: 1

      Considering it's mostly the developers' fault, and that such languages are easier to develop in, they would probably run faster.

    59. Re:Is C++ ever the right tool for the job? by maxwell+demon · · Score: 1

      That's actually a quite complex grammar. Compare with Unlambda, which is basically:

      expr: FUNCTION | ` expr expr

      SCNR :-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
    60. Re:Is C++ ever the right tool for the job? by ToasterMonkey · · Score: 1

      No offense but you have to be stupid to not know what + does. If it does something unexpected, chances are you wrote it incorrectly yourself, or are using a terrible library that has undocumented operators that are working incorrectly on top of that. It's not the languages fault when programmers code like retards.

      Add, combine, insert, concatenate?
      Is the thing on either side modified by the operation, and/or a meaningful result returned?
      Do you like method names with abbreviated words in other people's APIs?
      Why can't you create those above methods?
      Why can't you create toNumber or toString methods and use native operators?
      Any weasel excuse out of these questions is a good indicator the operator overloading in question will be hard to understand.

      Leave built-in operators to built-in primitives please.
      Use descriptive words for all else. Operator overloading amounts to "allowing" folks to put their car into reverse gear while it is moving forward.
      Maybe some people think there are some bizarre cases where this is needed. Those people need to find a different car, not everyone else.

      Yah, it can be the language's fault when programmers code like retards. That applies to any tool, pretty much any thing. Blaming the user for all problems is epic tool engineering FAIL!
      I blame Slashdot for people not quoting what they are replying to because #1 /. doesn't make it clear to them that other viewers will actually see because WYSI_N_WYG here #2 The reply button should automatically attach SOME context to the fucking post besides hierarchy in a threading view that is disabled by default.

    61. Re:Is C++ ever the right tool for the job? by ukyoCE · · Score: 2

      Overloading can certainly muddle code readability, but it still depends on someone doing something wonky or overcomplicated with an operator instead of a named function. Which you could argue, comes down to "bad code is bad".

      In Java on the other hand, I find it totally unpredictable and unreadable. Bad Java code uses operators and tends to have major bugs due to object VS primitive issues. The "better" Java code uses functions everywhere for equality, addition, etc. So instead of being able to quickly tell where doSomething is called, you see extremely wordy nested functions for math that in C++ would actually look like math.

      I wasn't very happy with operator overloading in C++, but now that I've used Java, I think I want C++ back.

    62. Re:Is C++ ever the right tool for the job? by maxwell+demon · · Score: 1

      This is off-topic from this particular thread of the discussion, but I also remembered the other objection to C++ that's developed: language interop (using C++ stuff in other languages) is usually nigh impossible. From what I can tell the best way to do language interop to C++ is to write a C wrapper for the C++ stuff, then interface to the C wrapper.

      That's true of pretty much any language out there. How do you interface Ruby to Python? Perl to Java? Haskell to Eiffel? Fortran to Prolog?

      --
      The Tao of math: The numbers you can count are not the real numbers.
    63. Re:Is C++ ever the right tool for the job? by epyT-R · · Score: 1

      Like most programmers, you're not looking at the nightmare of dependencies and execution overhead multilanguage applications require, esp ones that are interpreted. seriously, for the end user, running an app written in such languages that can use C/C++ 'plugins' is a royal pain in the ass, and is usually quite a bit slower than simply using a native C/C++ variant. There is a reason C/C++ is used 'for everything' even when purists say there are better tools available. In theory, yes, other languages provide better constructs for designing in specific areas, but as far as execution on real hardware goes, no.

      Yes, this is my opinion based on observations working in the industry. I do not intend to pass it off as fact. I am sure there are exceptions, but reality is rarely as neat and clean andorderly as theory expects of it.

    64. Re:Is C++ ever the right tool for the job? by jkimball4 · · Score: 1

      Or for both languages, because they didn't know Ada.

    65. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Actually, Lisp lets you do those kind of abstraction mixing setups too, but of course is too obscure and poor in the library/toolkit realm for broad use at the moment.

    66. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      C++ seems to be the only solution right now if you need to do both high- and low-level programming and have lots of library support. But C++ is a terrible language, combining low- and high-level programming in the worst possible way (exaggerating, but not a lot), and other languages are better if you look around a little. I hope people start to migrate over to a more sane system language, like D: www.digitalmars.com/d/

    67. Re:Is C++ ever the right tool for the job? by smellotron · · Score: 1

      How easy is it to mix and match D with C or C++ via shared libraries? I regularly work with C and C++, but if I could experiment by developing an isolated module (shared library + headers) in D, it would be much easier to make that leap.

    68. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      C++ is the worst language, excepting every other language I have tried.

      I'd encourage you to look at more languages; C++ is not the only system programming language. D, for example, has a good approach: let's take C++ as a base and fix what's broken (I fell in love when I learned it got rid of the preprocessor :). If you like static typing, have you looked at OCaml? I've heard good things about it, though not sure it's ready for application development.

    69. Re:Is C++ ever the right tool for the job? by The+End+Of+Days · · Score: 1

      That used to be true. These days, we have enough spare power in the machine that it's not necessary for everyone to work at every level.

      I'm not going to try to change your mind, though. I'm just letting you know you have an opinion with which reality disagrees, which means you're just a curmudgeon.

    70. Re:Is C++ ever the right tool for the job? by smellotron · · Score: 1

      ... in C, the bit shifting and boolean operators have precise and well-defined meanings... but in C++, the standard library co-opts those operators and perverts them into something else ...

      I assume you're referring to std::cout << whatever;, but you'll have to remind me where the standard library co-opts boolean operators. I agree that it's possible for someone to futz with that beyond the point of comprehension, but I think if you ever have to stop and ask if a << b is streaming or bit-shifting, you really need better variable names and/or smaller functions. That C++ allows miniature "domain-specific languages" or arithmetic analogues via operator overloading doesn't trump the importance of clean coding for readability.

      I would never suggest that anyone use C++ as a teaching language, I'm with you on that front.

    71. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      It seems to me that you're a retard.

    72. Re:Is C++ ever the right tool for the job? by smellotron · · Score: 1

      A string plus an integer, if it works, really only has one sane interpretation. ...maybe?

      Maybe not...

      typedef ??? string;
      string s = "12344";
      int i = 1;
      assert(s + 1 == 12345 || s + 1 == "2344" || s + 1 == "123441");

    73. Re:Is C++ ever the right tool for the job? by smellotron · · Score: 1

      a.add(b) feels way more like a += b than a + b to me.

      I agree. a.plus(b) at least reads like math.

    74. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      Operator overloading amounts to "allowing" folks to put their car into reverse gear while it is moving forward.

      Like the car analogies, huh? How 'bout this? (I admit it's not as brief, but I feel it's at least actually closer to reality.) A language supports a Car primitive type, which has a gearShift. As an app developer, you are creating a Truck type. A language that doesn't allow operator overloading makes you invent a new name, say transmissionLever, and operate it with your foot. Meanwhile, the next guy comes along and designs an EighteenWheeler, calling his gear shift the gearChangeLever (you still operate it with your foot).

      Of course now someone who wants to write a generic "drive" function is somewhat screwed because there are now three different names for the same concept. (Of course, you're not using a language that supports actual generic programming, so it's not like it matters anyway.)

      Meanwhile, because I'm using a language that allows operator overloading, I write my Truck class and I call my gear shift the gearShift, because that name isn't restricted to just Car objects. I allow the driver to use his hand to use the gearShift, because the language lets me and it's more natural to use that power in this case then to force the driver to use his foot. I then write my EighteenWheeler class, and I name the gear shift the gearShift, and allow the driver to use his hand. Now all three vehicles work the same way, which makes using them more uniform and allows me to write that generic "drive" function that you'd have had to jump through hoops for.

      How's that for an analogy? (Hint for the allegorically challenged: read "operator+" for "gearShift", "use like 'a + b'" for "uses your hand", and "use like a.foo(b)" for "uses your foot".)

      I certainly agree that a language can encourage poor practice or discourage it, but I firmly believe that, on the whole, operator overloading leads to cleaner code.

    75. Re:Is C++ ever the right tool for the job? by jomama717 · · Score: 1

      Bad Java code uses operators and tends to have major bugs due to object VS primitive issues.

      For your own sanity I strongly suggest you don't venture into coding with groovy... the single-quote and double-quote operators take on completely new meanings (single-quote returns java.lang.String, double-quote returns GString) and the ability to create untyped variables using def along with the "convenience" of so-called duck-typing allow the result of someVar + someOtherVar to not be obvious until runtime...nightmarish.

      We have many hands, on and offshore, furiously writing groovy code in a few grails applications and as a result I would say ~70% of our runtime issues are groovy type cast errors.

      --
      while [ 1 ]; do echo -n -e "\xe2\x95\xb$((($RANDOM&1)+1))"; done
    76. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 2

      My reply was slightly tongue-in-cheek, but I do think you have to be using a stupidly restrictive definition of "programming language" for it to exclude at least any Lisp from the last four decades or so.

      Even that link you gave in the other post to the McCarthy paper includes things right near the top (of that section) that say "[LISP] has been or will be used for the following purposes: ... writing a program to ... writing programs for ... writing programs to ..."

      And in your other reply you say "LISP has it's place as a powerful tool for creating domain specific languages and as a macro processor (as used in emacs), in AI and mathematics, but is not and was never intended as a general purpose programming language," which, even if it's technically true of McCarthy's LISP, definitely isn't true of a lot of more modern Lisps. Even if you think that Scheme wasn't intended as a general purpose language and is instead aimed at teaching (something that I would disagree with at least in terms of what it's become), I think it's pretty absurd to argue that Common Lisp, Clojure, and Arc aren't intended as such.

    77. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      Add templates and whether it's an object or not will depend on what the template gets used on.

      So I'll grant you that. Let me ask this question, because I think it bears on this issue and I'm too lazy to type out my arguments for both cases. What do you feel about function overloading? (Specifically based on types, and not numbers, of arguments.)

    78. Re:Is C++ ever the right tool for the job? by Chuck+Messenger · · Score: 1

      I disagree. In my experience - in the domains I've worked in over the last several years - C++ has been the best overall language for almost all purposes, except for cases which can be handled by simple Bash scripts.

      What makes C++ so good? First, to create complex code, it is essential to have a bullet-proof static typing system. This lets you refactor your code with confidence. Refactoring is a continuous process - supporting refactoring is the main task of a (non-trivial) programming language.

      In order to have a bullet-proof static typing system, you need templates and generic programming. Check.

      OK, so C++ has all these things. On top of that, it provides excellent efficiency, in terms of both memory and run-time.

      The icing on the cake is operator overloading. This lets you write very clean domain-specific mini-languages, in effect.

      And then, of course, you get the excellent standard library, Boost, the large amount of third party code, the large number of excellent compilers for a very wide range of hardware, and the large number of trained programmers.

      All in all, it's pretty hard to come up with a good reason to _not_ use C++ in any domain where efficiency is paramount. Beyond that, C++ is an excellent choice in a wide variety of cases, even where efficiency isn't the most important consideration.

    79. Re:Is C++ ever the right tool for the job? by Kaz+Kylheku · · Score: 1

      Are you sure you couldn't live without static typing? Or could it be that you could not live with Ruby's immature, crappy dynamic typing?

      Real dynamic languages have compilers that help discover type errors in your code, and also provide optional type declarations so that you can optimize.

      C++'s declare-everything type system is 1960's technology. But at least it is mature. Don't compare mature type systems to toys; it's not fair!

    80. Re:Is C++ ever the right tool for the job? by Kaz+Kylheku · · Score: 1

      Unlike Python (the principal implementation of it, rather) and Ruby, Lisp (which has not been spelled LISP since 1980) is a compiled language. Lisp implementations produce native code. Lisp libraries for cryptography, regular expressions, etc, are written in Lisp and are comparable to C libraries. Lisp is fast enough to be used as a systems programming language, and has been, including as an operating systems programming language. The system running on the Lisp machines was written in Lisp: OS, drivers, ...
      Yet it is also suitable for making a web application.

      Can you provide a URL to this "considerate debate" about whether "LISP" is a programming language?

    81. Re:Is C++ ever the right tool for the job? by t2t10 · · Score: 1

      I couldn't live without static typing,

      If you do professional software development, you write unit tests; with unit tests, the issue of static vs. dynamic typing pretty much goes away. If you do rapid development or prototyping, then static type systems frequently get in the way; the amount of time you save in hunting down type errors is made up for by the complexities of trying to work around limitations of the static type system (static type systems often hinder design in ways that the designers don't even notice).

      While there are reasons to use static type systems, and even C++, those tend not to be related to static typing and its supposed benefits itself, but rather to things like good code generation or ability to interface easily with other statically typed languages.

    82. Re:Is C++ ever the right tool for the job? by Kaz+Kylheku · · Score: 1

      If you aren't aware of this debate, then I suggest you research the history of LISP. I've already covered this on another post. I'm not even sure where I stand on the debate as I can see points on both sides, but I'm not idiotic enough to pretend that there is no debate.

      It's not about whether there is a lot of LISP code out there - there certainly is - emacs is full of lisp macros. AI research and mathematics use it heavily.

      The debate is more about whether it fits the classic definition of a computer language.

      Classically, computer languages are defined by a specific, usually fairly extensive grammar, whereas the LISP grammar is basically


              expr: ID | STR | NUM | list

              list: ( seq )

              seq: | expr seq

      Again, this is not to say that it's not powerful or to deride it's significance, but to try and explain why there is legitimate debate over what constitutes a programming language.

      You are confusing formal languages and programming languages.

      Programming languages are not simply syntax.

      Programming languages have multiple layers of syntax. For instance, on one level, a C language program is a sequence of various kinds of preprocessor tokens.

      Lisp has a lexical syntax (quite a bit more rich than the grammar you have given) and then it has a syntax within the forms produced by the lexical syntax.

      For instance (defclass derived (base1 base1) (slot ...))) is syntax for defininig a class and (loop for x from 1 to 10 summing (* x x)) is the syntax of an expression which sums the squares from 1 to 10.

      There is a lot of syntax you have left out. For instance #(1 2 3) is Lisp syntax for a vector. #c(1 2) is the complex number 1 + 2i. Then there is backquote syntax, which can nest arbitrarily. E.g. `(1 ,a ,b) is a quasiliteral which denotes the three element list consisting of 1, and the value of A and the value of B.

      The legitimate debate you are alluding to does not exist. I've never seen anyone claim that Lisp isn't a programming language.

      Common Lisp has an ANSI standard (look for it on the ANSI web store). The title is "Information Technology - Programming Language - Common Lisp".

      You are hopefully now better informed.

    83. Re:Is C++ ever the right tool for the job? by t2t10 · · Score: 1

      But numerous C++ programming techniques (mainly template mechanism) makes it much easier to program.

      Efficient template-based algorithm and data structures often become extremely complex to implement and modify, condemning many users to just instantiating existing classes and algorithms. Even then, they are affected by poor error messages and debugging difficulties. In addition, you cannot be certain that your reusable algorithms actually are efficient (small constants, not just low complexity) if you compose them from templates.

      Or you could use inheritance but will pay the cost at runtime.

      Actually, not true. Some compilers perform global program analysis and will give you template-like efficiency with inheritance-like simplicity. And JIT compilers perform inlining and optimization on the fly, giving you template-like efficiency even for dynamically composed data structures.

      In the end, when performance really matters, you have to drill down deep no matter what and can't rely on any automated mechanism, whether it's C++ templates or JITs. And when performance isn't quite so critical, there are many alternatives to C++ templates that work at least as well and are less hassle.

    84. Re:Is C++ ever the right tool for the job? by devent · · Score: 1

      Java is pretty much everything C++ claims to be, except for system programming. It's have static typing, it's almost as fast as C++, you can use C libraries pretty easy via JNI, it's have a lot of open source libraries and it have the best IDEs and tools.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    85. Re:Is C++ ever the right tool for the job? by devent · · Score: 1

      The problem are the other libraries you are including in your project. It's easy to say, if I don't like feature X I will not use it, but the language is still great. What if the developer(s) of a library you need thinks feature X is really cool and use it? Now you have to deal with feature X anyway and so you have to deal with every feature of a language regardless if you want or not.

      It's not like you can just turn off a feature with a compiler flag and everything will work.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    86. Re:Is C++ ever the right tool for the job? by 21mhz · · Score: 1

      RAII alone is enough to seal that deal.

      I hope by RAII you mean the general pattern of freeing allocated resources in the destructor of the object that owns them, and not the obligation to wrap everything with smart pointers and similar gunk in order to attain "exception safety". Because the latter is entirely self-inflicted by the language design.

      and compile with optimization on. Look at the resulting assembly. There's no branch! (I'm assuming a variant of x86 or x64 here.)

      If you're on a 64-bit system with GCC you'll probably see a cmov (conditional move) instruction, which kind of makes sense. But you don't even need that instruction to be available for it to omit an actual control-flow jump. Recompile with -m32 and look at the assembly again. Much longer, but still no branch. Instead, it uses one of the setxx instructions (setg in my case) and a bit of bit twiddling.

      In my opinion, today's optimizers make the generated code so far removed from what you type into your editor that saying "+ can do anything!" is a drop in the bucket.

      If you want to read assembly for your target architecture but cannot understand what it does, how is it the C compiler's problem? It does what you ask it to do.

      --
      My exception safety is -fno-exceptions.
    87. Re:Is C++ ever the right tool for the job? by devent · · Score: 1

      The reason that op.ov. is generally bad is not efficiency, is not whether it's a good name or good style. It's maintainability. Why obscure the code with op.ov.? Why not state very clear in the code what you are going to do?

      As example, a very abused operator is the <<. You write file << "text" It's look very cool, but what does it mean? Why not state clearly what it means: file.append("text") or file.save("text").

      You will read code more then you are going to write it and with op.ov. I need to study every class I use what is the meaning of each op. C++ is probably the first language with build in obfuscater.

      The only thing around it is just forbid op.ov. because no operator is a good name for an operation, except the build in operators. The build in op. are well documented and are only with build in types, so everybody can known what they are mean. But with custom op. you have to study each new interface.

      It's the same reasoning why the named constructor idiom is a good practice. Because ctors. are like operators, they don't have a name, so you can't state clearly what the code means. Point p1 = Point::rectangular(5.7, 1.2); // Obviously rectangular

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    88. Re:Is C++ ever the right tool for the job? by 21mhz · · Score: 1

      The introduction of operator overloading was basically the point after which the complexity of C++ exploded. It brought in the nightmarish overload resolution rules. It was a cause for bolting exceptions onto an unmanaged runtime environment, since how do you report errors in a function that has to have just the right signature to act like an operator? This invited the overarching concept of "exception safety" which is unheard of in sanely designed languages, outside of cases where an explicitly managed system resource needs to be released.

      --
      My exception safety is -fno-exceptions.
    89. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      I hope by RAII you mean the general pattern of freeing allocated resources in the destructor of the object that owns them, and not the obligation to wrap everything with smart pointers and similar gunk in order to attain "exception safety". Because the latter is entirely self-inflicted by the language design.

      Combination of both. RAII is a good idea and awesome even if C++ did not have exceptions, however exceptions make something RAII-like nearly essential to avoid those leaks. (I happen to think that exceptions are a good idea too, but am much less... certain of that position than some of my others. I also haven't seen a language that I think gets exception safety in a substantially better way than C++ does.)

      If you want to read assembly for your target architecture but cannot understand what it does, how is it the C compiler's problem? It does what you ask it to do.

      That's not my point: my point is this. One of the arguments people bring up for using C over C++ is "C++ makes it harder to know what the compiler will do." But with today's optimizers, you need a reasonably intimate familiarity with your compiler to know what it'll do even in C code. So if you really care that much about the code it generates, you have to look. But you can look in C++ code as well, and see what it's doing. So both languages are in the same ballpark when it comes to "how easy is it to expect what the compiler emits."

    90. Re:Is C++ ever the right tool for the job? by aiht · · Score: 1

      A string plus an integer, if it works, really only has one sane interpretation. ...maybe?

      Maybe not...

      typedef ??? string;
      string s = "12344";
      int i = 1;
      assert(s + 1 == 12345 || s + 1 == "2344" || s + 1 == "123441");

      warning C4189: 'i' : local variable is initialized but not referenced

    91. Re:Is C++ ever the right tool for the job? by aiht · · Score: 1

      Indeed, C++ is just as easy as C to use for low-level programming, as not only do you have the option of inline assembly which mixes easily with the rest of your code, but you even rarely need to resort to it as in the major compilers (MSVC, gcc, Intel C++) there is a plethora of compiler intrinsics which almost directly map to assembly instructions while providing a type-safe interface. It's quite easy to write synchronization primitives, for example, using interlocked operation intrinsics--while the same have a nice object-oriented interface. Just because C++ is large and has a multitude of features in no way implies that you need to try to use all of these features. You might as well complain that the library has too many books! It's ultimately a matter of programmer discipline; stop shifting the blame.

      The GP didn't mean to shift the blame. They were trying to write it to an ostream.

    92. Re:Is C++ ever the right tool for the job? by 21mhz · · Score: 1

      (I happen to think that exceptions are a good idea too, but am much less... certain of that position than some of my others. I also haven't seen a language that I think gets exception safety in a substantially better way than C++ does.)

      Look at any managed runtime environment with garbage collection. This is where exception handling actually works without the need for the developers to contort themselves with library-provided helpers over every pointer assignment, and ensure that no destructor can throw exceptions.

      --
      My exception safety is -fno-exceptions.
    93. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 1

      Java sucks. It lacks a lot of essential features: Operator overloading, static polymorphism, lambdas/closures, multiple inheritance (or at LEAST mix-ins), const-support, proper support for limited resources (besides memory)... I could go on. Add to that, the JVMs I see today handle memory extremely poorly, meaning I and many other tend to avoid Java programs whenever possible. Added to that comes the current patent problems.

      Java is a suitable replacement for COBOL, and little more. As for speed... Eclipse is sluggish, KDevelop/Qt-creator is fast --- need I say more? Not that that in itself would bother me for most tasks.

      And don't get me started on JNI. It's cumbersome, slow, buggy and most of all ONE WAY! How fucked up is that?

      Sorry, I had to work in Java again recently, I had almost regressed what a straightjacket of a language that is. Though at least the C#-competition forced a few features that were long overdue..anyone remember how it was to work with the old Collections? "Please leave your type information at entry, or create a freaking huge boilerplate class for every type you need to use".

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    94. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      Why obscure the code with op.ov.? Why not state very clear in the code what you are going to do?

      Because when a class overloads an operator, chances are pretty darn good that the clearest way write code using that class is with that operator!

      Suppose I write a complex number class. (Or, if you feel like saying "what about C99's _Complex, a matrix class.) Which is easier to read:

      z = z * z + c;

      or

      z = z.times(z).plus(c);

      To me, it's not even a particularly close contest, and that's a pretty dead simple expression. The difference in readability grows dramatically as it gets more complicated, especially if you need grouping (parens).

      As a pretty drastic example, I was working on a project that has a step in which the code builds up expression trees for a reasonably complicated expression. I introduced some overloaded operators (e.g. operator+ takes two tree nodes and returns an AST representing their sum) and rewrote the expressions. And when I was done, I realized that I had duplicated -- almost character-for-character -- the comments that were sitting above the expression. I turned comments into executable code with operator overloading. And while I feel a twinge of guilt at this story in the sense that even I am not completely convinced that was a completely appropriate use of operator overloading, there's no way in my mind that I think the code didn't become way more readable.

      As example, a very abused operator is the

      What kind of answer do you want here? The most direct answer is because C++ doesn't support external methods (and doesn't root all objects at an Object class with a toString method) or variadic templates.

      In other words, say I wrote that complex number class from above. I want to print my complex number z. How do I do it? Well, I can't say file.append(z) because file's class has no idea what my complex number is. That means that I have to write either a toString method and say file.append(z.toString()) or I have to reverse it and make a method of the complex class that takes a stream and say z.writeTo(file). Neither approach is super attractive. file.append(z.toString()) is way more wordy than file (almost 3x the number of characters and over 3x the number of tokens), and if I do the latter thing, you can't just chain things together. (What would in actual C++ be file would have to become three separate statements.)

      Operators get around this by allowing you to use free functions. Now you could do the same thing with non-operator free functions too: make a set of write(stream, object) functions. But that quickly becomes obnoxious to edit. That chained output from before would become write(write(write(file, "("), z), ")"). Not only is that obnoxious to read, but if you want to add a fourth thing to print out, you have to insert stuff not just at the end of the line but at the beginning of it as well.

      Now, external methods make the first solution (file.append) workable because you'd be able to add new overloaded append methods for to your class without mucking about with file's definition. Variadic templates would allow you to refine the second version to write(file, "(", z, ")") and keep typesafety and extensibility (which printf lacks). I'd personally be quite happy if C++ supported either or both of these, but my syntactic-sugar sweet tooth is as active as my normal sweet tooth.

      But without either of those features, the only alternative to the overloading of > that I think is even remotely attractive is the forced toString. And given how early programmers are introduced to the > operators, how idiomatic their uses are, and the clutter they remove from the source code, I think the overloaded operators are the least bad alternative.

    95. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 1

      You know, I did write (and do, actually) unit tests --- and I get paid, so definitely professionally. My rubv code is still in production, virtually unchanged, so it was not THAT bad. And no, that did not help me enough, though the test features of ruby are excellent. As ruby programs grow, I spent too long hunting for hidden type errors. It's not that I could not do it, it's that I am vastly more productive in C++. Even though C++ writes function declarations backwards, which is hugely annoying.

      Note that maybe it is a background thing. I am a mathematician by profession, so working with types (well, sets really) comes very naturally to me, and I am seldom limited by the type system in any way... on the contrary, it helps me see the structure as it unfolds itself.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    96. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 1

      Well, don't toy with me like that! What language do you suggest? Note I have tried quite a few...

      You got your timeline screwed up, btw. Declare-everything didn't hit mainstream until long after the 1960's. Still old, sure, but new isn't necessarily better.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    97. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      Bah, I messed up the HTML and didn't spot it in preview. This reply just corrects that; feel free to reply to whichever, but this will be way easier to read. (The other will have missing parts that were chopped out by interpreting << as markup.)

      Why obscure the code with op.ov.? Why not state very clear in the code what you are going to do?

      Because when a class overloads an operator, chances are pretty darn good that the clearest way write code using that class is with that operator!

      Suppose I write a complex number class. (Or, if you feel like saying "what about C99's _Complex, a matrix class.) Which is easier to read:

      z = z * z + c;

      or

      z = z.times(z).plus(c);

      To me, it's not even a particularly close contest, and that's a pretty dead simple expression. The difference in readability grows dramatically as it gets more complicated, especially if you need grouping (parens).

      As a pretty drastic example, I was working on a project that has a step in which the code builds up expression trees for a reasonably complicated expression. I introduced some overloaded operators (e.g. operator+ takes two tree nodes and returns an AST representing their sum) and rewrote the expressions. And when I was done, I realized that I had duplicated -- almost character-for-character -- the comments that were sitting above the expression. I turned comments into executable code with operator overloading. And while I feel a twinge of guilt at this story in the sense that even I am not completely convinced that was a completely appropriate use of operator overloading, there's no way in my mind that I think the code didn't become way more readable.

      As example, a very abused operator is the <<. You write file << "text" It's look very cool, but what does it mean? Why not state clearly what it means: file.append("text") or file.save("text").

      What kind of answer do you want here? The most direct answer is because C++ doesn't support external methods (and doesn't root all objects at an Object class with a toString method) or variadic templates.

      In other words, say I wrote that complex number class from above. I want to print my complex number z. How do I do it? Well, I can't say file.append(z) because file's class has no idea what my complex number is. That means that I have to write either a toString method and say file.append(z.toString()) or I have to reverse it and make a method of the complex class that takes a stream and say z.writeTo(file). Neither approach is super attractive. file.append(z.toString()) is way more wordy than file << z (almost 3x the number of characters and over 3x the number of tokens), and if I do the latter thing, you can't just chain things together. (What would in actual C++ be file << "(" << z << ")" would have to become three separate statements.)

      Operators get around this by allowing you to use free functions. Now you could do the same thing with non-operator free functions too: make a set of write(stream, object) functions. But that quickly becomes obnoxious to edit. That chained output from before would become write(write(write(file, "("), z), ")"). Not only is that obnoxious to read, but if you want to add a fourth thing to print out, you have to insert stuff not just at the end of the line but at the beginning of it as well.

      Now, external methods make the first solution (file.append) workable because you'd be able to add new overloaded append methods for to your class without mucking about with file's definition. Variadic templates would allow you to refine the second version to write(file, "(", z, ")") and keep typesafety and extensibility (which printf lacks). I'd personally be quite happy if C++ supported either or both of these, but then-again my syntactic-sugar sweet tooth is as activ

    98. Re:Is C++ ever the right tool for the job? by jhol13 · · Score: 1

      The problem is, that you cannot come up with good names wit operator overloading.

      The one and only place where "+" is good name is numbers. Is it worth it? Is it really worth to be able to add matrixes with +? I have never written a single program where "+" could have been a descriptive name for a function.

    99. Re:Is C++ ever the right tool for the job? by toutankh · · Score: 0

      The way I see it a "real programming language" is a Turing-complete programming language, which Lisp most certainly is. So I don't really see room for debate on Lisp being a real programming language - would also be interested in a URL to such debate though, maybe I can learn something.

    100. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      Look at any managed runtime environment with garbage collection.

      I've looked at many of them. I was in a grad class with two friends who did a class project that became a tech report on the topic. None of the languages I would consider anywhere close to mainstream have support as good as C++'s.

      The problem is that managed libraries give you management of memory -- and nothing else. The best that most languages provide is stuff like Python's context managers, C#'s using statement, and a couple Lisp's dynamic-wind. These are good, but they introduce syntactic overhead every time you need to use it, which you don't get with C++. That puts them at a small disadvantage.

      "Some other" popular languages leave you with nothing more than the finally block. This is error-prone enough that a couple projects define classes (e.g. a wrapper for the File object, which must be closed) with a single "run" function that does the cleanup in a finally block, and then to use the file object you write an anonymous inner class. Even the Java folks themselves realized that the finally-based scheme was terribly error prone and did something similar for their protected code API. So now you've got this wonderful syntactic mess:

      AccessController.doPrivileged(
          new PrivilegedAction() {
              public Object run() {
      /* work to do while privileged */
              }
          });

      (The doPrivileged function calls a function beginPrivileged, calls run, then calls endPrivileged in a finally block.) This, IMO, doesn't remotely compare to RAII.

      The only language I can think of that has a resource-cleanup mechanism that I actually like as much as C++'s is D, which actually improves it.

      This is where exception handling actually works without the need for the developers to contort themselves with library-provided helpers over every pointer assignment, and ensure that no destructor can throw exceptions.

      Now, I'm not going to claim that C++'s exception handling semantics don't have their dark corners -- actually almost everything about C++ has plenty of dark corners. I also don't want to diminish the value of a managed environment: I said above that it gives you management of memory "and nothing else", but managing memory is admittedly a huge deal.

      But, I still feel that C++'s resource management is basically second to none.

      (I'm also working on a large C++ project now where basically everything is a smart pointer, and I'm not sure what "library-provided helpers" we're contorting ourselves "over every pointer assignment". I hesitate to bring this up because this is a research project and we're probably about as safe from exceptions as a water balloon is safe from a pin, but at the same time we've also had basically no issues caused my memory safety. I suspect you may be overstating the drawbacks of C++ here a bit.)

    101. Re:Is C++ ever the right tool for the job? by SanityInAnarchy · · Score: 1

      Maybe I'm just opinionated about what "sane" means, then...

      Perl is loosely typed enough that it might decide to treat the string as an integer, leading to your first interpretation, but I don't consider this to be sane. Having an actual object magically change types such that its behavior is radically different is a bit too "dynamic" for me -- give me dynamically but strongly typed languages.

      Your second option only makes sense in C, and only really because in C, strings are arrays and arrays are pointers, and you use pointers as iterators. Saner languages make distinctions between these things -- why should I assume that a string is an array at all, and not a rope or some raw binary UTF-8? Wrap it all in an object and let the implementation decide.

      In Ruby, JavaScript, even Java, adding a number to a string always yields your third option -- in fact, in my experience, Ruby does the sanest thing and automatically typecasts only in lossless directions, so ints can become floats, and either can become strings, but not the other way around.

      --
      Don't thank God, thank a doctor!
    102. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      The one and only place where "+" is good name is numbers.

      Is it? What about strings? Or lists? (Most languages, of course, use + for string concatenation. You could argue that strings should be a primitive, and I kind of agree, but there are definitely reasons that speak in favor of C++'s approach as well. In particular, it means that you can write classes that are almost strings, but different in some small but important way (e.g. encoding), and use them the same. Some languages think + makes sense for lists. Python does. C++ doesn't. I think it's at least not unreasonable to have a list + a list give you a list.)

      Or what about some other weird things? What about for a library that builds expression trees. "+" takes two trees and returns a tree that represents their sum. Is "+" such an unreasonable name for that? (While I think that application is definitely more questionable than the traditional number-like object, I'm hard pressed to come up with a pithy alternative. And in this application, switching to overloaded operators for building expression trees made the code easier to read to the extent where what was there was a comment with the expression written in traditional infix notation preceding an ugly mess of function calls, and what I wound up with was almost character-for-character identical to that comment.)

      Is it worth it? Is it really worth to be able to add matrixes with +? I have never written a single program where "+" could have been a descriptive name for a function.

      And I've written at least a couple, even restricting to just programs that use + to add number-like classes. Funny thing that, how it's nice that languages can cater to multiple people.

      Or why not tear down the strawman. How 'bout []? That's an operator. How many programs have you written that use random access containers? (Feel free to answer the negation of that question.)

    103. Re:Is C++ ever the right tool for the job? by SanityInAnarchy · · Score: 1

      I don't mind exceptions in an unmanaged runtime environment -- in fact, I prefer them to the alternative. (Of course, I'd rather not have an unmanaged runtime environment in the first place.)

      But it seems to be because of how C++ did exceptions. Let's compare languages for just a moment:

      In C++, there are at least two places to define each operator, and, what, 20 or 30 operators? In Ruby, there are 5 or 10 operators, all sanely enough defined that you can probably _guess_ how to implement them, and one canonical place to define them if you want a certain effect.

      Part of this, I'm sure, comes from C++'s static typing and operator overloading. Defining an operator in the global scope, outside of any of the types it operates on, is a sane thing to do in C++, and maybe even a nice feature, but it just means that much more to keep track of. That kind of thing would make no sense in Ruby.

      But anyhow, I don't think either of these things are necessarily bad or complicated, at least not by themselves. I think it's C++ that makes them bad and complicated. I definitely miss overloaded operators in Java, which deliberately left them out (probably horrified by C++), but this led to its own problems -- why, in Java, does == do one thing for primitives and a completely different thing for objects? Why the need for .equals and .compareTo?

      --
      Don't thank God, thank a doctor!
    104. Re:Is C++ ever the right tool for the job? by h4rm0ny · · Score: 2

      Well for mixing some C in with your D, you're laughing, as D supports C's ABI and all of C's fundamental and derived types. For C++, it's partial but you can extern to link to C++ objects. The D community is still quite small, but you'll find it heavily composed of C++ programmers going "wow, I like this." ;)

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    105. Re:Is C++ ever the right tool for the job? by devent · · Score: 1

      Whenever there is a discussion about op.ov. always comes an example with a vector, matrix, complex number, etc., i.e. with something math. I get the impression the only thing people write in C++ are some yet another math. library.

      You know how other languages solve complex expressions? With Builders. Instead of abusing op. like that: xml << tag << text xml << tag << text Or whatever you can write:root { tag { text }, tag { text } }

      Only because C++ don't have such features, it doesn't mean op.ov. is such a great idea.

      You have to do that for named functions too. What's the difference between calling a function "+" and calling it "plus"?

      Because it's not a plus. If there was no op.ov. I could tell you that it is a plus. But in C++ it's not a plus, it can be append, save, write, or something completely different. So why confuse the user more and instead just call the method what the method is doing?

      Practically speaking, the name of complex operator+(complex const & rhs) is "+" to the same degree that the name of complex plus(complex const & rhs) is "plus". I feel quite strongly about this.

      In C++ the name is not "plus" but the symbol "+". This symbol "+" can stand for anything you want, like append, save, concat, plus, add, etc. ppp. If you set a normal name for the operation like "append" or even "add" for complex numbers, the user of your library does not need to look up what the method is doing because it tells him in the name. It's all about a fluent API The Wikipedia is about method chaining but I rever here more to the designing a "API in a way that aims to provide for more readable code.".

      So you don't think "+" is a good name for a function that adds two complex numbers, or that "[4]" is a good name for a function that returns the 5th element of an STL vector?

      It is a good name for those particular examples. But why it is not in the C++ standard like in Java is "+" for Strings a concatenation? Operator Ov. is a good thing if it's in the language. Because this operators are well defined and they are a part of the language itself. It's like operators make a lot of sense in mathematic expressions, because operators are a part of mathematics. In mathematics nobody will wonder what 1+1 means, because it's well defined.

      Operator should be part of a language and they should not just change the meaning. The same goes for keywords, are you going to argue that keywords overloading is a good idea?

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    106. Re:Is C++ ever the right tool for the job? by vadim_t · · Score: 1

      I think it's largely unnecessary, and often a sign of bad design.

      Unnecessary because so far I've not seen that much of a need for it. It might make things a bit prettier looking by avoiding the need for a set of functions along the lines of atoi/atof/atol/atoll but in my experience that kind of thing doesn't come up often enough for me to even remember I can do type based overloading.

      Bad design because if you have Frob(Foo) and Frob(Bar), then there are excellent chances that Foo and Bar should inherit from a common class, or implement an interface. Or perhaps Frob should be a method of those classes.

      For code reading though, I think it's less of a problem than operator overloading you obviously see that something called Frob() is getting called. And if you want to read the code for Frob the IDE will either take you to the right version of it, or show that there are multiple versions.

    107. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Don't be so sure templates aren't costing you at run time, particularly if you target any small-cache embedded CPU. Cache misses dominate performance in many applications; if templates bloat up your code too much it can actually impose more overhead than virtual function calls, though obviously it depends on your app. Libraries like Boost and STL over-rely on templates in my opinion; a large part of the C++ community has fallen in love with template-based compile-time functional programming, and refuses to do plain old OOP even when it would be more appropriate.

      However, STL and similar libraries make short work of problems where you don't need the absolute top performance, and still can get you 100X to 1000X over languages like Python for certain types of problems (and =2x for other problem types where Python's libraries do most of the work). Generally, C++ / STL lets you solve most problems with reasonable efficiency, and dip down to lower level C-like programming when needed to get the best possible performance; if you aren't facile in C/C++ you're missing something as a professional developer, IMHO, though you should also know shell, perl, Python and/or a few others too for tools and utility programming.

    108. Re:Is C++ ever the right tool for the job? by devent · · Score: 1

      Ok. C++ sucks anyway. I programmed in C++ 10 years ego, now I would not touch it even if it was the last programming language out there.

      C++ programs a buggy and crash all the time, have a lot of security and memory issues. C++ is bloated and it takes them over 7 years to get a new standard out. Everyone writes his own implementation of String and Vector and the compilation time is the worst of all languages.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    109. Re:Is C++ ever the right tool for the job? by Madsy · · Score: 1

      I've coded AVR-code in C++ with the help of a simple linker script and clever use of the GNU binutils. That's an architecture where the hardware often only has kilobytes of storage and memory. Stop spreading FUD about C++ operator overloading. No one forces you to use that feature. C++ is perfectly fine for embedded programming, as long as you have a clue about what you're doing.
      Furthermore, there are no "convoluted implicit casting rules". Perhaps you mean implicit type promotion like 4 + 'a' becoming ints? It's no different from C. If you want to blame C++ for something obscure, rather take a potshot at the template system, where template candidates are chosen based on access specifiers and SFINAE. *That* is difficult to understand.

    110. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 1

      OK. So you were burned.. 10 years ago? Maybe it is time to move on? I have not seen a self-written Vector or String class for many years now, excepting the Qt-ones. And thanks to the flexibility of the C++ language, those Qt-classes integrate pretty well with the std ones.

      I do agree, though, that C++ sucks for a number of reasons. E.g. default fall-through in case statements is moronic. I only claim that it is the language I keep returning to because while it sucks, it sucks less than everything else I have tried and it has more and better libraries for most things.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    111. Re:Is C++ ever the right tool for the job? by 21mhz · · Score: 1

      (I'm also working on a large C++ project now where basically everything is a smart pointer, and I'm not sure what "library-provided helpers" we're contorting ourselves "over every pointer assignment". I hesitate to bring this up because this is a research project and we're probably about as safe from exceptions as a water balloon is safe from a pin,

      You highlight the issue yourself: nobody in practice attains exception safety in C++. Even if you tried, any library that you use has to be exception-safe as well, and few of them are. This includes all C code: if you use callbacks from C to C++, you have to have a try-catch block in your callback to catch anything that the C++ code might be throwing. No wonder that so many projects disable exception handling or discourage it in their coding guidelines.

      RAII is a good pattern for resource management, and smart pointers have their place. But "exception safety" is a false goal.

      --
      My exception safety is -fno-exceptions.
    112. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Mainly gaming engines and high performance computing. You NEED low level programming to deal with that.

      Notice the differences here. HPC systems are not always real time systems, which is why even dynamic and interpreted languages can make contributions if the problem is sufficiently parallel. Perhaps embedded and real time systems could be better generalizations of the types of systems sometimes requiring low level languages.

    113. Re:Is C++ ever the right tool for the job? by m50d · · Score: 1

      Have you tried: a) C# (I know, I know, but it actually makes a lot of the right choices; it's pretty good as an incrementally-improved Java (which in turn was an incrementally-improved C++)). b) One of the strongly typed functional languages - OCaml or the like. It's a different style of programming, but one that ultimately makes you a better programmer, in any language.

      --
      I am trolling
    114. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      Anyone who spells Lisp "LISP" quite obviously hasn't been around the language enough to know that many Lisp compilers are, in fact, competitive with C performance and, in some cases, can exceed it.

    115. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 1

      C# is a white spot I admit. It's on my todo list, but what I hear from people who use it is "meh. Better than Java, but far from C++".

      Java is hardly an improvement to C++ by any conventional definition, as it lacks a ton of features that C++ sports. It does have a bigger marketing department, and that shows.

      I haven't tried OCaml, but I have tried Haskell. Cute for toy projects, but again, lacking a lot of features I need to be as effective as I am in C++. In particular, I found it too bothersome to do OO programming, which have me a lot of problems when trying to tackle non-trivial problems. It's been a while, though, and back then those features were supposedly in the pipeline, so maybe it is time to try again.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    116. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 1

      Geez, people are so religious about their languages. As stated earlier, I personally am not sure where I stand on the debate, but I am aware of it because I've heard it thrown around for the last 30 years or so whenever LISP was mentioned. I suppose it goes back to the origins of the language. John McCarthy invented LISP as an excecise in mathematics to describe an alternate implementation of a Turing machine. He was actually surprised when one of his students was able to implement it on a real machine. I've heard it said that programming in LISP is not really programming, but rather doing math.

      http://www.paulgraham.com/icad.html

      Today's dialects (Scheme, CLisp, Clojure, etc) are not the same as the original lisp. No of this in anyway diminishes the import of LISP as many of the concepts it pioneered are part of most modern languages today (if-then-else, recursion, functional programming, lambda calculus, etc).

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    117. Re:Is C++ ever the right tool for the job? by smellotron · · Score: 1

      Ruby does the sanest thing and automatically typecasts only in lossless directions, so ints can become floats

      Does Ruby have 64-bit integers? Converting a 64-bit integer to a double-precision IEEE (or 32-bit integer to single-precision IEEE) is lossey.

    118. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 1

      You can pretend that there is no debate if you wish. As I stated, I can see points on both sides of the debate and I don't have a dog in either fight.

      The examples you give are from a dialect of LISP (CLisp I presume). However, CLisp is not the original LISP anymore than Scheme or Arc or Clojure are original LISP - they are dialects - extensions to the original language. Most, if not all modern languages implement ideas that were pioneered by the original LISP. As far as the grammar, no the entire original LISP grammar is almost exactly as I stated above. I only listed the basic grammar statements, but a complete implementation of a LISP parser for bison can be found at
      http://ragnermagalhaes.blogspot.com/2007/08/bison-lisp-grammar.html

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    119. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 1

      Maybe it's a "stupidly restrictive definition", but by your logic, nearly anything can be considered a programming language. Machine language is probably the most widely used of all since everything eventually breaks down to it, but does that mean it's a programming language?

      Nothing is more ubiquitous today than HTML, yet most "programmers" would argue that HTML is not a programming language, but guess what - it is a "declarative" language as opposed to an "imperative" language, but does that really disqualify it as a programming language? Many would argue yes, it does.

      CLisp, Clojure and Arc are not the same as LISP, they are dialects of LISP. Would you consider VB .Net the same as ANSI Basic? I think not. Just because they share a common heritage (Dartmouth Basic) does not make them the same language. Almost all modern languages today implement ideas that were pioneered in LISP, but that does not make them all LISP.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    120. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      Machine language is probably the most widely used of all since everything eventually breaks down to it, but does that mean it's a programming language?

      Sure. So is Java bytecode. Just because it's obnoxious to use doesn't mean it's not a programming language.

      Nothing is more ubiquitous today than HTML, yet most "programmers" would argue that HTML is not a programming language, but guess what - it is a "declarative" language as opposed to an "imperative" language, but does that really disqualify it as a programming language? Many would argue yes, it does.

      Ah, now see, HTML is an interesting question. I'm not sure how I feel about it. I would tend to say "no", though I'm not completely set on that belief.

      But that declarative vs imperative? Not at all the problem. Haskell is clearly a programming language, and it's not imperative. I would say Prolog is too, and it's quite declarative (although I don't understand how you would actually use it for most tasks, that's my own failing).

      No, if HTML isn't a programming language, it's because it's not Turing complete. Heck, I don't even know how you could add 1 + 1 with HTML and display 2 let alone do more complex loop/recursion computations.

      CLisp, Clojure and Arc are not the same as LISP, they are dialects of LISP.

      Okay, fair enough, but then why bring up LISP? Has anyone actually used true LISP any time in the last couple decades?

    121. Re:Is C++ ever the right tool for the job? by mswhippingboy · · Score: 1

      Machine language is probably the most widely used of all since everything eventually breaks down to it, but does that mean it's a programming language?

      Sure. So is Java bytecode. Just because it's obnoxious to use doesn't mean it's not a programming language.

      No, I'm sorry. Allowing that machine language is a programming language it taking it a bit far. Keep in mind that "machine language" != "assembly language".

      Nothing is more ubiquitous today than HTML, yet most "programmers" would argue that HTML is not a programming language, but guess what - it is a "declarative" language as opposed to an "imperative" language, but does that really disqualify it as a programming language? Many would argue yes, it does.

      Ah, now see, HTML is an interesting question. I'm not sure how I feel about it. I would tend to say "no", though I'm not completely set on that belief.

      But that declarative vs imperative? Not at all the problem. Haskell is clearly a programming language, and it's not imperative. I would say Prolog is too, and it's quite declarative (although I don't understand how you would actually use it for most tasks, that's my own failing).

      No, if HTML isn't a programming language, it's because it's not Turing complete. Heck, I don't even know how you could add 1 + 1 with HTML and display 2 let alone do more complex loop/recursion computations.

      Is being Turing complete what constitutes a programming language? Again, machine language is Turing complete, but does a string of ones and zeros stored in memory constitute a programming language?

      CLisp, Clojure and Arc are not the same as LISP, they are dialects of LISP.

      Okay, fair enough, but then why bring up LISP? Has anyone actually used true LISP any time in the last couple decades?

      I didn't bring up LISP, I was simply responding to a prior post that brought it up and I made the (apparently heretical) mistake to note that there is debate over whether (original) LISP is a true programming language.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    122. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      In C++ the name is not "plus" but the symbol "+". This symbol "+" can stand for anything you want, like append, save, concat, plus, add, etc. ppp. If you set a normal name for the operation like "append" or even "add" for complex numbers, the user of your library does not need to look up what the method is doing because it tells him in the name.

      I personally feel that, if I tell you "I'm calling operator+ with a [type of the first operand] and a [type of the second operand]" and you can't immediately make an accurate guess as to what the result will be, that is probably an abuse of the operator overloading feature. If you allow yourself to read some generic usage information about the types involved and that's still true, then I'd say it almost certainly is. (The latter would "allow" operator overloading in some more esoteric cases like my expression tree builder I've mentioned elsewhere in this thread.)

      (Also I feel like you're padding your list a bit there what with both "plus" and "add", but that's beside the point.)
      But why it is not in the C++ standard like in Java is "+" for Strings a concatenation?

      It is in the standard.

      Why's it not in the core language? Because strings aren't, so so saying "the language should say + on strings should do concatenation" doesn't make any sense. You could say that if you replace "string" with "char*" but that brings out a whole HOST of other problems.

      Now you can argue (very reasonably) that perhaps strings should be a core language feature and not just a feature of the library, but this ignores that the language designer can't add EVERY type for which it is reasonable to write a "+" operator to the core language.

      The same goes for keywords, are you going to argue that keywords overloading is a good idea?

      Heh, now that's an interesting question. And I have a couple answers.

      First, understand that I've become a fair fan of syntactic abstraction. This plays a big part of why I like C++ (where I developed it), and is why I love Lisps. So don't count on me to see some innate problem with keyword overloading just because it's keyword overloading.

      Second, it's not like operator overloading ever changes the meaning of anything, really. To the compiler, it adds a new meaning where there wasn't one before. To the programmer, if there is some meaning of "+" that doesn't make sense, then go down the hall and hit the programmer who wrote it or shoot an email to the dev list, and write a wrapper function. Why when someone does that with operator overloading do we say "a language shouldn't support operator overloading" but when someone comes up with a bad name for a function (would you like some examples? I've seen plenty) we don't say "a language shouldn't support functions"?

      Third, I can actually think of cases where a simple way of doing "keyword overloading" might actually be a reasonable idea, but I kind of don't have time to type it out right now. If you're curious I can expound more fully, but the idea is something like "overload if/while to reduce the temptation to add an automatic conversion to boolean (a la the iostream types)."

    123. Re:Is C++ ever the right tool for the job? by Cro+Magnon · · Score: 1

      I always cringe when I see this statement in a discussion about programming languages. The presence or absence of a particular feature will impact the third-party libraries you use, the code samples and tutorials you come across, and the legacy apps you inherit.

      I'm an old COBOL dinosaur. COBOL has an abomination called "ALTER", which basically modifies GOTOs depending on a certain value. Nobody sane would ever use such a feature! I worked on plenty of programs written by people who were not sane. If $FEATURE exists in a language, it WILL get misused, and according to Murphy's Law, you WILL have to work on programs with $FEATURE.

      --
      Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
    124. Re:Is C++ ever the right tool for the job? by kv9 · · Score: 1

      you're assuming that everyone should run one bloated app at a time in a single user environment which has enough spare power. sadly, so do many other "programmers".

    125. Re:Is C++ ever the right tool for the job? by slashdotjunker · · Score: 1

      with C++ it's not always obvious what a compiler might want to do with '+' thanks to operator overloading and rather convoluted implicit casting rules.

      I agree that optimized, compiled code might as well be a block box nowadays.

      However, I think the problem with C++ is that it is not obvious what your fellow _programmer_ wants to do with '+'. That's the real problem with operator overloading. Everytime I have to dive through 4 layers of pre-processed headers to figure out what '+' does is another nail in that coffin.

    126. Re:Is C++ ever the right tool for the job? by Anonymous Coward · · Score: 0

      I personally don't have a problem with operator overloading (and truly miss it in Java)

      Scala has operator overloading.

    127. Re:Is C++ ever the right tool for the job? by m50d · · Score: 1

      Using C++ does force you to think about exceptions, and in particular about resource management in the presence of exceptions, which is where the real headaches come from. Of course C allows you to do the same thing with goto, but hopefully by now people know better than that.

      --
      I am trolling
    128. Re:Is C++ ever the right tool for the job? by EvanED · · Score: 1

      Of course C allows you to do the same thing with goto

      Or, you know, "return". Not that anyone uses that black sheep of a keyword.

    129. Re:Is C++ ever the right tool for the job? by chthon · · Score: 1

      Xah Lee, is that you?

    130. Re:Is C++ ever the right tool for the job? by devent · · Score: 1

      Now you can argue (very reasonably) that perhaps strings should be a core language feature and not just a feature of the library, but this ignores that the language designer can't add EVERY type for which it is reasonable to write a "+" operator to the core language.

      Sure you can. Just take the most common types and that includes strings: boolean, byte, short, int, long, float, double, char, string and arrays. If you want you can add BigDecimal (arbitrary-precision signed decimal numbers) and Complex. Define operators for those and forbid op.ov. Other types are so uncommon that operators are not necessary and are just a little bit sugar (like vector, map). There just aren't so many primitive types in a language and for self defined types (like classes) a method is better.

      Why when someone does that with operator overloading do we say "a language shouldn't support operator overloading" but when someone comes up with a bad name for a function (would you like some examples? I've seen plenty) we don't say "a language shouldn't support functions"?

      True, bad names are everywhere. But at least with a method I can just hover my mouse over the name and the IDE will get me the documentation in a nice tool tip. Furthermore, with a method I can see the method. Try to spot the op.ov in that code: http://www.copypastecode.com/61754/

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    131. Re:Is C++ ever the right tool for the job? by Kaz+Kylheku · · Score: 1

      The most recent (open source) project I have worked on is Txr (http://www.nongnu.org/txr/).

      Even though I have tons of C++ experience, this is written in a dialect which compiles with either a C or C++ compiler, and does the same thing.

      This dialect more portable than either C++-incompatible C or C-incompatible C++.

      The main paradigm within the program is ideologically and esthetically incompatible with most of the extensions that C++ brings to C.

      Wide portability isn't the only benefit. You get access to a wider range of diagnostics. There are things the C++ compiler might tell you that the C compiler won't, and even vice versa.

      Many things that are banned in C++ are bad features in C or bad style of C coding. For instance, skipping variable initializations with a goto. Or lack of type safety in the handling of enum constants.

      Programs in the "C/C++ dialect" benefit from these things being diagnosed without losing compatibility with C.

      Here is another one: C++'s enforcement of type-safe linkage, the one-definition rule, and its banishment of obsolescent features, like calling undeclared C functions.

      I get approximately the same code from GCC's C++ or C's front end. Benchmarks have differed between the two as much as between different versions of GCC.

      These days, performance concerns are no longer valid as a reason for eschewing C++ in favor of C (except in provable circumstances with particular toolchains and platforms). However, the C/C++ dialect will let you port your code anywhere, choosing the best possible compiler. If some embedded target has a great C++ compiler, but a so-so C compiler, you can use the C++ compiler and vice versa. Even if you don't ship with the C++ compiler, you can use it for diagnostics.

    132. Re:Is C++ ever the right tool for the job? by SanityInAnarchy · · Score: 1

      Wow, good to know. Thanks! ...I had no idea.

      Yes, Ruby seems to use 64-bit integers on a 64-bit system. I'm not sure what it uses on 32-bit systems. I'm also not sure whether it uses them all the time or scales to them -- for instance, it automagically converts to Bignum as needed, rather than overflowing.

      It does not, however, catch that precision issue when converting to a "Float" (not sure if that's 32-bit or 64-bit).

      Maybe I've just been using it so long that "integer + float = float" is intuitive to me...

      --
      Don't thank God, thank a doctor!
    133. Re:Is C++ ever the right tool for the job? by SanityInAnarchy · · Score: 1

      So does JRuby.

      However, sometimes, I'm forced to write actual Java code, and other JVM languages aren't a substitute. The most obvious example is when taking a Java-based CS course. A more recent example was a job using a Java-based web development platform with a giant pile of tools -- using anything other than Java wouldn't really have saved much time in the end, so long as I was tied to that platform.

      --
      Don't thank God, thank a doctor!
    134. Re:Is C++ ever the right tool for the job? by t2t10 · · Score: 1

      I am a mathematician by profession,

      Yeah, mathematicians tend to like C++. They also tend to be pretty poor at building good abstractions, which is probably why they aren't bothered so much by the type system limitations of C++.

    135. Re:Is C++ ever the right tool for the job? by The+End+Of+Days · · Score: 1

      No, I'm assuming that meeting the 80% case is more important than satisfying the tweakers. Feel free to insult me to make your case, though. I'm merely describing reality to you.

    136. Re:Is C++ ever the right tool for the job? by smellotron · · Score: 1

      Maybe I've just been using it so long that "integer + float = float" is intuitive to me...

      It is intuitive, as long as you keep in mind that IEEE floating-point is designed as an approximate representation instead of exact. Adding an exact number (integer) to an approximation (float) should produce an approximation. Sometimes you get lucky and the approximation is accurate :)

    137. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 1

      LOL. Mathematicians tend to be poor at building abstractions?! ROFL Pull the other one, it has bells on!

      Sure, it would be nice if C++ supported duck typing, but such can be emulated with simple encapsulation and it sort of works. If that was what you were referring to.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    138. Re:Is C++ ever the right tool for the job? by CondeZer0 · · Score: 1

      If you need/want static typing, but the lightweight feel of dynamic languages, plus high performance and extremely fast compile times, you might want to try Google's Go.

      --
      "When in doubt, use brute force." Ken Thompson
    139. Re:Is C++ ever the right tool for the job? by CondeZer0 · · Score: 1

      D is an almost worse convoluted mess of insane 'features' than C++.

      Add the D1/D2 split plus multiple 'standard' (haha) libs, and the result is not particularly fun to deal with.

      But the D fanboys (which I doubt use D for anything) love to ignore all the problems and over-sell their pet language to the point that they talk about features that are not even implemented yet.

      But hey, if C++ has damaged your brain enough, this might be just the thing for you.

      --
      "When in doubt, use brute force." Ken Thompson
    140. Re:Is C++ ever the right tool for the job? by EsbenMoseHansen · · Score: 1

      Compile times is the bottom of the pack for me. Modern computers are so fast, I seldom sit and wait for compilation. C++ already offers peak performance.

      Still, I might have a look again. Last time around I was not impressed :)

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    141. Re:Is C++ ever the right tool for the job? by m50d · · Score: 1

      Sure, but that's always explicit. You'll never call a library function and have it make your method return, whereas you can call a library function and have it make your method throw an exception.

      --
      I am trolling
    142. Re:Is C++ ever the right tool for the job? by azgard · · Score: 1

      I believe he is suggesting Common Lisp.

    143. Re:Is C++ ever the right tool for the job? by chthon · · Score: 1

      To me, C++ has a lot going for it: it's pretty much as fast as C, and much more clear with powerful language constructs. I'm not much of an expert on other languages (I'm mostly a depth-first learner), but I've yet to see another language have something as powerful as templates/generics (besides Ada, which is where C++ got them from). The fact that you can do compile-time programming speaks volumes for the power of templates.

      All the Lisps have compile-time programming, and you do not need to learn another language, and D has the same feature, also in D.

    144. Re:Is C++ ever the right tool for the job? by h4rm0ny · · Score: 1

      Heh. I remember that interview. Never entirely been convinced it was a joke. :D

      Anyway, bit of a D fan here, just replying. I'm only just starting to use it on a decent sized project. I think it's fine, though obviously you differ. As someone still fairly new to the language, I'd be interested to know what the insane features are. Not so I can argue about them - genuinely just curious / want to learn.

      I will say that I don't think the D1/D2 split is an issue. The community is small enough and the code that's out there limited enough, that most people are able to regard the shift to D2 as a joyous thing, not a problem. D1 is still maintained and out there for those that want it.

      --

      Aide-toi, le Ciel t'aidera - Jeanne D'Arc.
    145. Re:Is C++ ever the right tool for the job? by petke · · Score: 1

      In C++0X you can have fundamentally different features interoperating seamlessly at the statement level (the whole is more than the sum of its parts style interoperability). Something you couldn't if you used different languages. In C++0x you can say pass a lambda that to an STL algorithm, which return value is moved (not copied) into a variable declared as auto. That's some heavy useful stuff right there. You say C++ is bad for low level programming because it has customisation at the syntactic level the operators. That's only a problem if you don't know what you are doing. Customization point like that are especially useful for low level programming so that you can define the most efficient operators for each type once and have it be used everywhere. The way i see it there is no way to argue with you C programmers, if you could there would be no C programmers any more. C has a weak type system. That's worse than no type system at all. No promises about the correctness of the program can be made because of it. In C you are on your own in undefined land the minute you step into it. Only a fool (sorry) would thing that's a good idea.

    146. Re:Is C++ ever the right tool for the job? by petke · · Score: 1

      I forgot to mention the most important thing that C++ brings to the table compared to C. Abstraction without performance penalty. Abstraction is a good idea in maths, and its a good idea in programming. holding the view that abstraction is a bad is anti-intellectual at the most fundamental level.

  11. Make it stop..... by jythie · · Score: 3, Interesting

    Stop trying to add more redundant features to C++... it is already getting progressively harder for C++ programmers to read each other's code and teach newbies what something means.

    All this does is result in yet more more syntactic sugar to teach people in order to accomplish the same tasks they can already do with the older standards, and yet another round of relearning so you can tell what someone who learned a 'neat new trick' is doing. And of course you STILL need to teach the old methods to newbies so they can understand C++ code that they have to maintain.

    Seriously.. this really does not help.

    1. Re:Make it stop..... by Anonymous Coward · · Score: 0

      Agree.
      The impression I get from the WG is that they have no idea where the language should be going, or how to solve the existing problems and unsolved corner cases created by indiscriminately adding features. So their solution is to add even more features.

    2. Re:Make it stop..... by EsbenMoseHansen · · Score: 2

      Some of us wants them. For you that do not, pass std=c++98 to gcc and be happy. Think of it as a new language :)

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    3. Re:Make it stop..... by jythie · · Score: 1

      The problem with this is, we end up with a fractured language were 'I know C++' communicates less and less to a potential employer or team. One of the nightmares I had dealing with a C++ project even a few years ago was everyone's code looked (and worked) so differently according to when they learned the language to the point they could not maintain each others code. The only solution ends up being forcing a standard of 'which version of C++ we will use', which then results in holy wars and retraining when you bring in more people.

    4. Re:Make it stop..... by Anonymous Coward · · Score: 1

      What do you mean when you say "newbies" and "syntactic sugar"?

      Sorry, I stopped tracking changes to the English language several decades ago.

    5. Re:Make it stop..... by Korin43 · · Score: 1

      Some of us like it when language designers make things easier for us.


      for each(int i : some_container) { // do things
      }

      vs:


      for(std::container_type::iterator i = some_container.begin(); i != some_container.end(); i++) { // do things
      }

      One of those is immediately obvious and one takes a second to think about. Who cares if you have to learn one new piece of syntax in a language you'll use for decades?

      That said, I see the standard library improvements as more interesting (mainly multithreading and hash tables). Sure you could do those before, but now you have guaranteed portability to any platform that full supports C++, with no checks to see what's available.

    6. Re:Make it stop..... by Korin43 · · Score: 1

      Er.. for the "for each" part, I mean just "for". I was confused by Microsoft extentions.

    7. Re:Make it stop..... by Anonymous Coward · · Score: 0

      It makes me think that there might be some value in rigorously specifying a standard subset of C++0x. I mean... my impression is that nobody is really using the entirety of the C++ language; everybody uses a set of core features, and pick-and-chooses the more specialized functions.

      In a group project, it might be a good idea to define features that may be used across the board, and separate them from features (say, operator overloading, or some of the weirder template stuff) that should be used only if there's a strong reason, and well-flagged and documented.

    8. Re:Make it stop..... by russotto · · Score: 1

      for(std::container_type::iterator i = some_container.begin(); i != some_container.end(); i++) { // do things
      }

      This is just one of MANY reasons C++ needs to die. Just about every interaction with the STL is like this. And suppose you're going through multiple parallel containers (what python calls "zip")? Then the new sugar doesn't work except for one container.

      C++ is the language which allows you to just about anything, but nothing that is all of complex, clear, and efficient. No amount of hacked-on extras are going to solve the problem.

    9. Re:Make it stop..... by EsbenMoseHansen · · Score: 1

      This will be the, what, second standard? Third? And besides the new libraries, it's not that many new hard-to-grok features that are added. Actually, I can only think of lambda, but a language without lambda is an atrocity. Is there any particular feature you are thinking of? Have you read the wikipedia page?

      I have worked on a number of projects, usually as some sort of project lead or technical lead. I have had problems with people who could not grok C++ (though not many), but I have not had the problem you describe, which just shows how lucky I am ;)

      In my humble opinion the biggest problem I have had over the years is to get people to search for a freaking library instead of trying to do everything themselves. Admittedly, that is not a problem specific to C++.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    10. Re:Make it stop..... by noidentity · · Score: 1

      You can already do it all with assembler, so it's all syntactic sugar. Presumably, they add it where they believe it will result in a net benefit. If you read the interview, you'll find there aren't many significant features, more refinement of current ones. R-value references seem the main addition, but this is mostly of interest to library authors (as most features are); users simply get cleaner library interfaces to use, not having to worry as much about avoiding copying of large objects.

    11. Re:Make it stop..... by lederhosen · · Score: 1

      I do not agree. most of the changes are good, and really needed. They will make programs easier to read and add expressiveness. How can you be against things like auto variables and lambda expressions?

    12. Re:Make it stop..... by Korin43 · · Score: 1

      Sounds like they could fix that by adding a 'zip' function ;)

    13. Re:Make it stop..... by russotto · · Score: 1

      You can already do it all with assembler, so it's all syntactic sugar. Presumably, they add it where they believe it will result in a net benefit.

      The problem is it's been added in a haphazard way. This is a language where a major feature (template metaprogramming) occurred _by accident_.

    14. Re:Make it stop..... by Anonymous Coward · · Score: 0

      >The only solution ends up being forcing a standard of 'which version of C++ we will use', which then results in holy wars and retraining when you bring in more people.

      They're called coding standards. Implement them.

    15. Re:Make it stop..... by Prune · · Score: 1

      Taking the "syntactic sugar" argument to its conclusion, everything above machine language is syntactic sugar. Accomplish the same task you can already do with an older standard? You can accomplish the same task with any turing-complete language. Such as assembly. Basically, your argument fails a pretty basic sanity check because, by extension, it implies that punched cards are as good as a high-level language.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    16. Re:Make it stop..... by Prune · · Score: 1

      This can go either way. I've interviewed people who, when asked to write a test program, produced a C program disguised as C++--with all the old-fashioned C crap like variables declared at the top of the function etc.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    17. Re:Make it stop..... by David+Greene · · Score: 1

      And suppose you're going through multiple parallel containers (what python calls "zip")?

      Use the boost zip_iterator. Next question.

      --

    18. Re:Make it stop..... by David+Greene · · Score: 1

      Well, it really depends on what you mean by template metaprogramming. The very first standard C++ library had template metaprogramming in it (the rebind member of allocators, iterator tags, etc.). The age-old "print something out at compile time" code is not very useful and makes a very poor example of what template metaprogramming is for.

      Typelists were a turning point but it was only "by accident" in the sense that this was the first time people could use a C-like language to experiment with generic programming, and effectively this was the first time most people had even heard of generic programming. The generic programming experts have been talking about this stuff for a long time.

      --

    19. Re:Make it stop..... by lgw · · Score: 1

      There's a fairly important paper in the world of PL that basically says this: all languages are just macros around "if, lambda, and sigma". If you made a really good optimizing compiler around just those 3 operators, then the next 100 programming languages could each just be some set of macros to create the right tool for the right job.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    20. Re:Make it stop..... by Anonymous Coward · · Score: 1

      And suppose you're going through multiple parallel containers (what python calls "zip")? Then the new sugar doesn't work except for one container.

      Use the boost zip iterators.

      C++ is the language which allows you to just about anything, but nothing that is all of complex, clear, and efficient. No amount of hacked-on extras are going to solve the problem.

      C++ provides the ability to do many complex things simply and efficiently. A large part of that is providing the basic tools from which powerful 'hacked-on' extras can be built, i.e. libraries. Case in point, boost zip iterators and many other boost libraries.

    21. Re:Make it stop..... by lgw · · Score: 3, Insightful

      Well, variable declared at the top of the function are the least evil c-ism. The real problem is a lack of understanding of RAII, and a fear of exceptions. The last time I read Googles C++ coding standards I died a little inside. People just don't "get" C++ for some reason.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    22. Re:Make it stop..... by shutdown+-p+now · · Score: 2

      And suppose you're going through multiple parallel containers (what python calls "zip")? Then the new sugar doesn't work except for one container.

      The sugar is meant for a simple case, just like Python's "for". When you need something more complicated, then - again, as in Python - you use a library solution. In case of zipping two sequences together, you'd use a zip_iterator. In general, you can also simplify many STL patterns by using Boost range library.

      And STL is unwieldy mainly because of the need to explicitly spell out types everywhere. With auto in C++0x, most STL operations are much more concise.

    23. Re:Make it stop..... by EsbenMoseHansen · · Score: 2

      Those ARE atrocious, are they not? Personally, my coding standing are usually "types looks like this, member variables like this, code nice".

      Of course, the last bit takes a bit for people to learn, but it works nicer than a detailed standard, in my experience.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    24. Re:Make it stop..... by Anonymous Coward · · Score: 0

      Well if you didn't already foresee it, C++ is the Perl for ex-C-programmers.

    25. Re:Make it stop..... by Anonymous Coward · · Score: 0

      a high-level language without lambda is an atrocity.

      FTFY

    26. Re:Make it stop..... by Anonymous Coward · · Score: 0

      Maybe this is all just to difficult for your poor brain. Might I suggest a career in janitorial engineering?

    27. Re:Make it stop..... by Anonymous Coward · · Score: 1

      std::for_each( container.begin(), container.end(), []( int i ){
      // do things
      });

      If you use it properly ...

    28. Re:Make it stop..... by derGoldstein · · Score: 1

      Some of us wants them.

      Smeagol? Is that you?...

      --
      Entomologically speaking, the spider is not a bug, it's a feature.
    29. Re:Make it stop..... by turgid · · Score: 1

      Shhh! Don't give away the secret!

    30. Re:Make it stop..... by Prune · · Score: 0

      Regarding your signature: why would a nation worry about "debt" enumerated in a currency of which it is the monopoly issuer? Krugman is right.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    31. Re:Make it stop..... by js_sebastian · · Score: 3, Interesting

      Stop trying to add more redundant features to C++...

      Did you even bother to read about what these supposedly "redundant" new features are? Personally, I think these redundant new features will help maintain C++ as one of the 2 or 3 most used programming languages for the next decade. Especially since this time all of the new features already have reference implementations, so the compilers will be very quick to implement them (GCC already supports a long list of them).

      I would say the single most important feature is finally having standard support for threading and concurrency. Hopefully, this will gradually lead to a standard library of high-level abstractions for parallel programming as well as concurrent algorithms (did you ever try the parallel mode of the gnu stl? parallel sort on 8 cores is sweet...).

      There are also a lot of little tweaks under the hood, that programmers will benefit from even if they never need to know about it, just by using the STL. For instance even if you have never heard of move constructors, they will make some methods of standard containers more efficient and make it possible to have a proper implementation of the new unique_ptr (useful for Resource Acquisition Is Initialization paradigm). And most of the added syntax is straightforward enough that it doesn' t really add complexity:

      Initializer lists:

      vector<string> v = { "xyzzy", "plugh", "abracadabra" };

      Range-based for+auto types:

      for (auto x: my_container) {
      ...
      }

    32. Re:Make it stop..... by Noughmad · · Score: 1

      This can quite easily be solved by using a macro.

      http://doc.trolltech.com/latest/containers.html#the-foreach-keyword

      --
      PlusFive Slashdot reader for Android. Can post comments.
    33. Re:Make it stop..... by lgw · · Score: 1, Interesting

      Because the "debt" is mostly in short term bonds - it used to be mostly long term, but the Fed broke that. We therefore can't inflate our way our of debt without destroying the currency itself, because you have to complete that process before the bonds mature.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    34. Re:Make it stop..... by SleeknStealthy · · Score: 1

      Iterators are one of the most critical parts of c++ that help make generic programming powerful and efficient. You can reduce the complexity, increase conciseness and simplify logic for all containers in a generic case using templates and iterators. When you don't understand a language, it is very easy to find a strawman.

      --
      Math
    35. Re:Make it stop..... by lefticus · · Score: 1

      I've felt that same little death when reading the Google C++ coding standards doc. I've said it before and I'll say it again: Nobody Understands C++.

      -Jason

    36. Re:Make it stop..... by maxwell+demon · · Score: 1

      What is sigma?

      --
      The Tao of math: The numbers you can count are not the real numbers.
    37. Re:Make it stop..... by Anonymous Coward · · Score: 0

      How is that, different from the framework and runtime changes in Java and (more notoriusly) in Net? were past recomendations, latter were worst case (in next version)

      It is platform pushing, for comercial "land grabbing" through framework adicted programers better? How "the market" selection saved the best components, when the C++ based COM ecosystem pased out? (using the same excuse of language complexity that you mention)

      If instead of more syntactic sugar and relearning; you whant: small, clean, expresive language; with clear, efficient integration by runtime... you are thinking in modula3, objetive c, eiffel or vala/genie not in C++

    38. Re:Make it stop..... by icebraining · · Score: 1

      Doesn't exactly solve the "retraining when you bring in more people" part.

    39. Re:Make it stop..... by Anonymous Coward · · Score: 0

      That looks like fun in a debugger.

    40. Re:Make it stop..... by russotto · · Score: 1

      Iterators are one of the most critical parts of c++ that help make generic programming powerful and efficient. You can reduce the complexity, increase conciseness and simplify logic for all containers in a generic case using templates and iterators. When you don't understand a language, it is very easy to find a strawman.

      There's nothing at all wrong with the concept of iterators. It's the C++ implementation that's a disaster, in terms of the horrible syntax it requires. The AC above who suggested the use of this particular expression: "[]( int i ){ // do things }" demonstrated my point quite well, I think. Not that it actually works.

    41. Re:Make it stop..... by c++0xFF · · Score: 1

      My thoughts exactly.

      If anything, C++0x simplifies the learning curve for C++. The "syntactic sugar" adds those things that I've always wanted to do naturally.

      Move constructors let me return vectors from a function (instead of passing by reference). I can also initialize most anything with {}'s. Automatic type inference simplifies life, especially with templates. Members can be initialized where they're declared. Constructors can be inherited.

      And possibly the most important of all, I no longer have to put an ugly space between >>'s.

    42. Re:Make it stop..... by 21mhz · · Score: 1

      Well, variable declared at the top of the function are the least evil c-ism. The real problem is a lack of understanding of RAII, and a fear of exceptions. The last time I read Googles C++ coding standards I died a little inside.

      It's not necessarily fear. C++ exceptions create far more problems than they solve. I understand the usefulness of RAII as a general pattern, but mandating it everywhere as a way to solve language design problems is ludicrous.

      People just don't "get" C++ for some reason.

      It may be also that some people get it well enough to know what to avoid.

      --
      My exception safety is -fno-exceptions.
    43. Re:Make it stop..... by EsbenMoseHansen · · Score: 1

      Yeah, yeah, English is my second language and I was tired. SORRY!! :)

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    44. Re:Make it stop..... by pedestrian+crossing · · Score: 1

      Mmmm, smells like Perl...

      --
      A house divided against itself cannot stand.
    45. Re:Make it stop..... by m50d · · Score: 1

      If it's a new language then it should get rid of features that didn't work out - drop namespaces, make everything use std::string rather than char*, reclaim some low-level syntax (e.g. []) for something more useful in high-level programming (lists?)... etc.

      --
      I am trolling
    46. Re:Make it stop..... by EsbenMoseHansen · · Score: 1

      It is not uncommon for a new language to be somewhat compatible with another language. In fact, C++ itself is a prime example of this.

      That said, you have a strange idea of "didn't work out". Namespaces are a critical feature to C++, [] is used for lists today (and indeed for the very std::string class you mention). While the library interfaces could always stand some improvement, I hardly find it a showstopper that a few interfaces are still on char* --- there might even be good reasons for it (think about it).

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    47. Re:Make it stop..... by Anonymous Coward · · Score: 0

      I totally agree ! Java is catching up FAST with redundant and useless features ! C++ has to add a lot of nonsense to stay ahead of the game !

    48. Re:Make it stop..... by lgw · · Score: 1

      Sigma is the primitive that assigns a new value to a variable, with a lamda-like syntax. The lambda-calculus proper has no assignment, but transforming a procedural program to a set of primitives lacking assignment is more of an academic excercise than a practical way to build a compiler. I acually forgot a primitive in my list: "capture current continuation" to allow non-local jumps.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    49. Re:Make it stop..... by lgw · · Score: 1

      fear. C++ exceptions create far more problems than they solve.

      Sorry, but you're just wrong. That was a reasonable argument to make 15 years ago, but not today. RAII is not some workaround, it was the intent of the language from the earliest days. Good C code never exits from the middle of a function, and control always paases through clean-up code at the end of every function. This is fundamentally human-error prone.

      Good C++ code is built from exception-safe primitives, and no such dicipline is needed. With just a few primite library classes done right, the majority of your coders never even need to think about it - all code is just naturally exception safe, and returning or throwing from anywhere never risks a resource leak - you can't even forget to use a "using" block as you can in C# and Java. Seriuously, I'm approaching 20 years of professional coding and I've never coded a memory or handle or lock leak, and certainly not because I don't make mistakes.

      Believe me, I understand that C++ exceptions suck if you're typing C code into a .cpp file so never do that. C++ is a different mindset.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    50. Re:Make it stop..... by 21mhz · · Score: 1

      Sorry, but you're just wrong. That was a reasonable argument to make 15 years ago, but not today.

      Today, as then, you still have to ensure that no destructor throws exceptions. And with excellent obfuscation properties of C++, it's not a task that a human can be relied upon to perform well. I once asked a couple of C++ fanboys to tell me what an innocuously looking 20 LOC code example would do, and they both failed.

      RAII is not some workaround, it was the intent of the language from the earliest days. Good C code never exits from the middle of a function, and control always paases through clean-up code at the end of every function. This is fundamentally human-error prone.

      Cool, but don't force me to use a costly smart pointer for each data member that wants to be a pointer. I can free my owned objects in a destructor myself, thank you. Also, classes like tr1::shared_ptr are designed for casting convenience in assignments and constructors (otherwise they'd suck), which makes them problematic to use in method signatures together with overloading. Discipline required again. But people rather tend to use plain pointers or references in method signatures, which defeats the purpose of shared pointers (but helps to keep the mangled symbol names to be less than a mile long, and makes reading compiler error messages less of a hair-pulling experience).

      Believe me, I understand that C++ exceptions suck if you're typing C code into a .cpp file so never do that. C++ is a different mindset.

      No mindset change needed for me: I use Qt and implement exception safety by use of compiler flag -fno-exceptions. Makes usage of C callbacks a breeze, too. I also use -fno-rtti to prevent even accidental usage of another C++ feature that is broken by design, and indicates a code design problem in most cases anyway.

      --
      My exception safety is -fno-exceptions.
    51. Re:Make it stop..... by bonch · · Score: 0

      Krugman is a troll who writes columns to make liberals feel better about thinking a certain way. Don't trust so much in op-ed authors.

    52. Re:Make it stop..... by radtea · · Score: 1

      With auto in C++0x, most STL operations are much more concise.

      This is by far my favourite new C++ feature. I swap back and forth between Python and C++ a lot, and increaingly I'm aware of how many god-damned times I'm telling the C++ compiler something it already has all the information it needs to figure out: the type of variable I'm initializing.

      "auto" effectively makes C++ type declarations for almost all local variable obsolete, whcih is wonderful. It will make code a bit hardewr to read--you'll have to know what types are being returned--but if you're caring about that you should know that anyway, not being reminded multiple times by the poor perons who wrote the code in the first place.

      --
      Blasphemy is a human right. Blasphemophobia kills.
    53. Re:Make it stop..... by shutdown+-p+now · · Score: 1

      As users of dynamically typed languages quickly discovered, it's much more readable to encode the reasonable (unlike e.g. Hungarian notation) amount of information about type into the variable name. For example, if it's a plural noun, it's a collection. If it begins with "is", "has" or "can", it's a Boolean flag. And so on. Adhering to this principle makes the code naturally readable in and of itself, with no need for type declarations.

      Same technique can be put to great use in statically typed languages with some form of type inference, C++0x being one of them.

    54. Re:Make it stop..... by lgw · · Score: 1

      Today, as then, you still have to ensure that no destructor throws exceptions. And with excellent obfuscation properties of C++, it's not a task that a human can be relied upon to perform well. I once asked a couple of C++ fanboys to tell me what an innocuously looking 20 LOC code example would do, and they both failed.

      One can write crap code in any language. C syntax isn't all that complicated, but the C Obfuscation Contests show just how messed up you can get with it.

      With proper C++ style, you don't really do much with destructors. Sure, balancing allocation in constructors with de-allocation in destructors is just as error prone as the c style of doing that in each function, but that's not what good C++ code looks like. Only the primitive classes such as file handles and locks need a destructor, and they all have the same design pattern (scoped object) and so can be implemented with a single templated class. In my current code base there's only a single line of code that is used to free all resources across all classes, and that one line is solidly reviewed and tested.

      Cool, but don't force me to use a costly smart pointer for each data member that wants to be a pointer. I can free my owned objects in a destructor myself, thank you.

      Which is exactly the wrong way, for the reasons mentioned above. You should never be expliticly freeing anything, except in odd corner cases like non-trivial cyclic graphs. Good C++ code looks much like good code in a garbage-colected language - your program logic isn't cluttered with bookkeeping. In fact, that to me is the worst part of well-written C code - every damn function call must be followed by an error check and branch to clean-up code on error. The needed ritual error checking is more lines of code than the actual program logic.

      Also, there's no particular cost with auto_ptr, not sure what you think it does beyond call the destructor of the class it points to when it is itself destroyed.

      o mindset change needed for me: I use Qt and implement exception safety by use of compiler flag -fno-exceptions. Makes usage of C callbacks a breeze, too. I also use -fno-rtti to prevent even accidental usage of another C++ feature that is broken by design, and indicates a code design problem in most cases anyway.

      Well, don't let me stop you from typing C code into cpp files, but please stop calling that code C++ - it gives the language a bad reputation.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    55. Re:Make it stop..... by 21mhz · · Score: 1

      With proper C++ style, you don't really do much with destructors.

      Um, whenever you have a class that needs to commit something using, say, I/O before the object is destroyed, you rely on your clients to call the explicit method for that and get their proper error reporting, otherwise you do it in the destructor wrapped in an ugly catch-all block. Usage of badly designed language features makes you remember all these nasty little things...

      In my current code base there's only a single line of code that is used to free all resources across all classes, and that one line is solidly reviewed and tested.

      Bullshit. That line exploits static or dynamic polymorphism, and all the implementations used by it need to be reviewed and tested.
      By the way, every implicit code path that can be taken by a raised exception needs to be tested too.

      Good C++ code looks much like good code in a garbage-colected language - your program logic isn't cluttered with bookkeeping. In fact, that to me is the worst part of well-written C code - every damn function call must be followed by an error check and branch to clean-up code on error. The needed ritual error checking is more lines of code than the actual program logic.

      Yeah, that's why we use Vala these days. You don't know how liberating it is to use a real object-oriented language that is still close enough to the metal.

      Also, there's no particular cost with auto_ptr, not sure what you think it does beyond call the destructor of the class it points to when it is itself destroyed.

      But, but, auto_ptr sucks and is deprecated by all RAII gurus whose revenue from C++ trick books is anything worth talking about!

      Well, don't let me stop you from typing C code into cpp files, but please stop calling that code C++ - it gives the language a bad reputation.

      Of course I don't use plain C code in C++ files. But very often I need to supply callbacks to some C library (no, not all useful code in the world is written by C++ RAII hotshots), and I like to implement them without having to wrap everything in a catch-all block or suffer memory leaks or worse. I'll agree on calling it "Qt style code" and accept all the stigma associated with it ;)

      --
      My exception safety is -fno-exceptions.
    56. Re:Make it stop..... by lgw · · Score: 1

      Um, whenever you have a class that needs to commit something using, say, I/O before the object is destroyed, you rely on your clients to call the explicit method for that and get their proper error reporting, otherwise you do it in the destructor wrapped in an ugly catch-all block. Usage of badly designed language features makes you remember all these nasty little things...

      Well, I've done the same thing, but I don't like it. Doing anything non-trivial in a destructor is asking for trouble, but I too fall prey to having a one-liner destructor that calls the function the user was supposed to call, just in case.

      Bullshit. That line exploits static or dynamic polymorphism, and all the implementations used by it need to be reviewed and tested.

      Well, technically true, but the testing is very shallow (did you in fact match the kind of handle and the close function in your template typedef), sometimes shallow enough that the compiler will catch any mistake. For example, my primitive wrapper for a Windows registry key handle looks something like this:

      typedef ScopedObject<HKEY, NULL, RegCloseKey> RegKeyHandle;

      Working with the registry used o be nightmarish, because there are so many possible error conditions, and so many damn handles you have to have open at once. This sort of thing really cleans up the code. In any case, all the "business logic" of how to handle this object going out of scope, assignment of this object, and so on are exactly the same as file handles, service handles, and so on, and don't need to be seperately tested - only the base type, cleanup function and "null" value are different.

      But, but, auto_ptr sucks and is deprecated by all RAII gurus whose revenue from C++ trick books is anything worth talking about!

      On this, we agree entirely.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    57. Re:Make it stop..... by Kaz+Kylheku · · Score: 1

      C++ exceptions are broken. An exception in computing is some event out of the normal flow of the program's execution which requires handling. For instance, a not-present page of virtual memory, upon a memory access to that memory.

      During an exception, meticulous care must be taken to preserve the program state, for two reasons. One is so that the maximum information is available about what the processor was doing (in case the exception was caused by code). The other reason is to allow the program to be resumed where it left off, as one of the options for recovering from the exception.

      The point of departure for C++ exceptions is the erasure of information. Once a C++ exception is thrown, a search for the handler begins. As the search progresses, information is thrown away (unwinding). All call frames between the handling site and the exception throw site are thrown away.

      C++ exceptions are not really an exception mechanism but a dynamic non-local control transfer mechanism, which provides a way to escape from deep within some context without any intent to recover and continue.

      C++ exceptions are debugger-hostile. If you stop the program where an exception is caught, there is no meaningful backtrace for investigating what happened; it's already gone. To catch the exception where it occurs, you have to put a breakpoint on every throw which might be causing it.

      These dumb exceptions are suitable for writing system utilities which can follow the mentality of simply bailing when something goes wrong, so that some higher-level metaprogram (script) can notice the failed termination status and do the real handling.

      I once wrote an exception library for C which is similar. It ended up being used in projects like Ethereal/Wireshark. I no longer endorse that library. Today, I would not design it that way.

      The search for an exception handler must be done in a new execution frame, without discarding any frames. When a suitable handler is found among the call frames, that handler can then search the call frames for a restart point, as determined by that handler's recovery strategy. Once a restart point is chosen, only then does unwinding take place and a non-local transfer to that restart point.

      This design allows the module where an exception is raised to provide ways to recover and continue.

    58. Re:Make it stop..... by lgw · · Score: 1

      To catch the exception where it occurs, you have to put a breakpoint on every throw which might be causing it.

      But putting a breakpoint in the constructor for std::exception generally accomplishes this in a few seconds' work.

      Exceptions are simply a form of non-local branching. It's totally appropriate to "unwind the stack" when performing an "escape continuation", which is the special case that C++ implements (as do most modern languages - exceptions as a way of implementing concurrency nevey really did catch on). In the majority of cases where an error occurs in the real world, there is no debugger attached, and I'd rather see all the appropriate clean-up happen.

      That being said, the habit of most recent langauages of capturing some sort of stack trace and adding it to the payload of the exception that gets thrown is a great innovation. That would be damn hard to do in C++ because C++ lacks reflection. Heck, if you ask me, lack of reflection is the single biggest problem with C++, and your debgging complant is just a side effect of that.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    59. Re:Make it stop..... by 21mhz · · Score: 1

      So, when it comes to smart pointers as data members, no alternative is entirely good. Either you get shared ownership, or you can't effortlessly copy-construct your member. For shared ownership, C++any-decade-now provides no copy-on-modify facilities (Qt does), so you have to be careful about what your objects share. shared_ptr uses atomic operations in multi-threaded programs, so if you use it just for fool-proof deallocation, you may be bumping into more memory barriers than is good for your program's performance.

      --
      My exception safety is -fno-exceptions.
    60. Re:Make it stop..... by m50d · · Score: 1
      It is not uncommon for a new language to be somewhat compatible with another language. In fact, C++ itself is a prime example of this.

      Sure. But it's very uncommon for a new language to have quite as many features (many of which overlap in terms of what they do) as C++ (just compare the length of the C++ standard to any other one), and if one was proposed it would (quite rightly) be derided as overly cluttered, complex, impossible to learn from scratch.

      That said, you have a strange idea of "didn't work out". Namespaces are a critical feature to C++

      I was under the impression there was a consensus they weren't really working; see the need to use unordered_map so as not to conflict with hash_map.

      While the library interfaces could always stand some improvement, I hardly find it a showstopper that a few interfaces are still on char* --- there might even be good reasons for it (think about it).

      No one problem is ever a showstopper. But C++ has hundreds of little corners like this that would make absolutely no sense in a new language, and together they make it harder to learn; they're there solely for the sake of compatibility with previous versions. Which makes sense, but only if you take the (frankly obvious) position that C++0x is not a new language, but a revision of an existing one.

      --
      I am trolling
    61. Re:Make it stop..... by EsbenMoseHansen · · Score: 1

      Yeah, yeah, I see you sig. Well done.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    62. Re:Make it stop..... by Dixie_Flatline · · Score: 1

      A friend of mine (a much smarter friend, truth be told) once said about C++, "The design philosophy of C++ is that you don't pay for anything you don't use, so as a result, there isn't anything worth paying for."

    63. Re:Make it stop..... by Anonymous Coward · · Score: 0

      The lack of reflections is the single biggest contributor to optimizer-derived efficiency of the compiled executable. Optimization during compilation is a type of partial specialization, and reflection is one of the anitheses of partial specialization.

    64. Re:Make it stop..... by Anonymous Coward · · Score: 0

      Using exceptions is the most evil new "feature" people are using. Really, try to use them in a large project. You dont know what a function is throwing before you have read all the functions you use.
      Exceptions = hiding possible problems really well in code so developers go nuts.

  12. I always wanted to say this in public : by unity100 · · Score: 1

    C plüzs plüsz ...

    1. Re:I always wanted to say this in public : by Anonymous Coward · · Score: 0

      You're so right. My turn now:

      Tschi piu piu ...

    2. Re:I always wanted to say this in public : by Anonymous Coward · · Score: 0

      Szí plász plász?

    3. Re:I always wanted to say this in public : by unity100 · · Score: 1

      aaaah. apparently czech is the best.

  13. Interview by Mongoose+Disciple · · Score: 5, Funny

    I always preferred this interview with Bjarne Stroustrup.

    (Yes, I know it's not real, but...)

    1. Re:Interview by Anonymous Coward · · Score: 1

      Or this tutorial on how to teach yourself C++ in 21 days.

    2. Re:Interview by Prune · · Score: 4, Insightful

      I wrote C for about 5 years and then switched to C++ with which I've stuck for the last dozen years. With that perspective, the article you linked to is such a lousy attempt at humor that it made me cringe. C++ has, like many other large entities with significant history, become a bit messy due to the need for legacy support given its huge installed base. This does not mean that you cannot write neat programs with it! It's easy to blame the language instead of the software developer. It is just a matter of a bit of attention and discipline to do great stuff with C++ even while using what some may refer to its more esoteric features like template metaprogramming etc. I could never give up things like multiple inheritance, which may require a bit of care during usage, but I've found to be the way to go in many situations. The majority of the C++0x additions are very welcome as well. What's really needed is a completely modern reference text that minimizes time spent on legacy issues. It's basically the same situation with OpenGL, which has become much larger in the 3.x and 4.x versions, while still supporting all the legacy code--and there is no proper reference so one usually sees a messy mix of 2.x and 3/4.x in most current projects, rather than a clean, organized design following the most recent variant. A proper text (other than the standards document itself) would make a huge difference.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    3. Re:Interview by Mongoose+Disciple · · Score: 1

      Simple question:

      Do you believe that C++ doesn't have a lot of traps that other languages don't, often for no good reason?

      I don't, which is why it's funny.

      If you shoot yourself in the nuts with a shotgun, I'd blame you. If ten million people buy the same shotgun and nine and a half million shoot themselves in the nuts with it, it's time to blame the shotgun. It's not impossible to write good C++ code, but it's harder than it could be.

      There's basically no situation in which C++ would be my personal language of choice for a project -- either I care enough about performance and optimization that it's worth writing in C, or it's worth writing in a better object oriented language further from the metal like a Java or C# or even a scripting language, depending on the task.

    4. Re:Interview by andi75 · · Score: 1

      There are certainly a lot of competent C++ programmers out there. But there's also a lot of less competent ones. And sometime you get one who appears to be compotent, but actually isn't. With C++, these guys can do A LOT MORE damage to your project than they could do with simpler languages, and after a few years, the project becomes an unmanageable mess that's far more expensive to maintain and extend than it should be.

  14. Could they not have named it something sensible? by LordNacho · · Score: 2

    See-plus-plus-zero-ex doesn't really roll off the tongue. How about something a bit easier? Super-C, C-flat, Cmega+ or something lame that people can actually say.

    (Here's your queue to explain to me what the proper pronunciation is. AND the reason for picking such a weird name)

  15. Last interview by Anonymous Coward · · Score: 0

    http://harmful.cat-v.org/software/c++/I_did_it_for_you_all

  16. yeah, void* was destroyed by r00t · · Score: 3, Insightful

    Early C++ introduced void* and it was good. C adopted it.

    Then C++ took away the automatic casting, I guess about the time C++ was first standardized. OK, now what is the point? The value of void* is gone. Now we write code with nasty casts. We can even hide the nasty casts in macros. Oh joy.

    C remains fairly sane. There haven't been any serious fuckups since the trigraph disaster which no compiler enables by default. C99 is damn nice in fact.

    1. Re:yeah, void* was destroyed by Anonymous Coward · · Score: 0

      On the 'serious fuckups' list: Let me know when they finally remove the security disasters like strcpy and gets from the standard library. Maybe then major software vendors will stop having to fix the buffer-overflow-of-the-week.

    2. Re:yeah, void* was destroyed by c++0xFF · · Score: 1

      gets was officially deprecated in C99.

    3. Re:yeah, void* was destroyed by Anonymous Coward · · Score: 0

      I bet you don't follow C1x. Complex numbers? Managed functions from Microsoft?
      And they were supposed to encode existing practice. I don't remember Microsoft ever releasing a C compiler after C89. Or writing safe code for that matter.
      C has jumped the shark as well.

    4. Re:yeah, void* was destroyed by Anonymous Coward · · Score: 0

      It's frightening to think that someone so inept in the ways of type safety might actually right code.

    5. Re:yeah, void* was destroyed by bonch · · Score: 1

      Those are library problems, not language problems.

    6. Re:yeah, void* was destroyed by Kaz+Kylheku · · Score: 2

      "void *" is a stupid misfeature, which I avoid in all new C code that is written by me.

      C++ never took away the automatic conversion from "void *"; it never had such a conversion. C perverted the "void *" idea by adding that conversion. As recently as last week, I ran into a void * bug. Some stupidly defined third party API defined an important handle type like this:

          typedef void *handle_t;

      A typedef for void * usually spells trouble. Anyway, one of the functions of this API is like this:

          int api_init(handle_t *phandle);

      the cleanup is:

          int api_cleanup(handle_t handle);

      The buggy program called both of them as api_init(&handle); and api_cleanup(&handle). Compiled without a peep, of course. C++ wouldn't help with this because this is a conversion to void *, not from void *.

      In all new C code that I develop for my own projects, I now use some character type as a generic pointer-to-anything, and have explicit casts everywhere there is an unsafe conversion, in either direction.

      The conversion from any pointer to object type to void * (allowed in C and C++) is itself braindamaged, because it gets you halfway to reinterpreting some memory without requiring you to confirm it or leave behind a piece of documentation in the code that can be easily spotted later (the cast).

      C was better off before "void *", when malloc returned "char *".

      In the Txr project (http://www.nongnu.org/txr/) I developed last year, I introduced "typedef unsigned char mem_t". After that, all generic pointers are "mem_t *". An allocator returns "mem_t *": All pointers other than unsigned char * have to be converted to and from mem_t * with a cast.

      This works out beautifully.

    7. Re:yeah, void* was destroyed by r00t · · Score: 1

      In your API example, an opaque struct done as "struct foo;" would have been proper.

  17. Oh God! by Anonymous Coward · · Score: 0

    ...if some political policy forces you to use a single language for an entire project...

    Oh God!

    I have never seen a software project that used "the right tool for the job" - different languages for different for different parts of the system - that wasn't: overly complex, buggy as all hell, and a complete bitch to debug and to understand.

    Here you are, debugging the C++ code and all of a sudden, it makes a call to an interpreted language module (kicking off the interpreter in the process) and you can't step in and follow WTF is going on. You're back to printing out to console or a file to see what's going on. Of course, the first several times in doing that isn't enough so you're constantly adding more "print" statements.

    I once had a system that had a Java Swing UI, a C++ module that did something, that called a Perl module because, according to the original developer Perl is the only language for processing text, which then went back up the chain to the Java UI which then made JDBC calls into Oracle (with its own SQL code) and then back. It was buggy, ugly, slow as fucking hell, and the end user eventually scrapped everything (and canned everyone in the process) and bought something off the shelf.

    tl;dr: Writing a system in one language is perfectly acceptable and this "right too for the job" only applies to trades people. Languages are just syntax and they all end up as ones and zeros in the end.

    1. Re:Oh God! by icebraining · · Score: 2

      Many games use two languages (C++ for the core, and something like Lua for the game logic) and it works perfectly fine.

  18. Slashdotted, here is article text by Anonymous Coward · · Score: 4, Funny

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

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

    Interviewer: Problem?

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

    Interviewer: Of course, I did too

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

    Interviewer: Those were the days, eh?

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

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

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

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

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

    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 works

    1. Re:Slashdotted, here is article text by rastilin · · Score: 1

      It all makes sense now... I'd always suspected.

      --
      How do you kill that which has no life?
    2. Re:Slashdotted, here is article text by Anonymous Coward · · Score: 0

      Ancient, well known spoof. Congrats to mods for giving Karma to an AC.

    3. Re:Slashdotted, here is article text by CondeZer0 · · Score: 1
      --
      "When in doubt, use brute force." Ken Thompson
  19. The problem with C++ is it's too powerful by GodfatherofSoul · · Score: 1

    And, we all know that power corrupts. So, when Joe Shortcut figures out that he can overload the '=' operator to slice his ham sandwich, you invariably end up with illogical, non-intuitively behaving code. Plus, the language in an effort to be ultimately configurable, doesn't take care of some menial, repetitive tasks. That opens the door for insanely dangerous, obscure bugs like object slicing. I wish that the standards community would have just drawn a line in the sand and said "OK, here's the cleaned up, modern version that we made practical at the expense of esoteric powers."

    That being said, I have total respect for what Stroustrup accomplished in context.

    --
    I swear to God...I swear to God! That is NOT how you treat your human!
    1. Re:The problem with C++ is it's too powerful by EsbenMoseHansen · · Score: 1

      I never understood the first complaint. Yes, you can make = or + or whatever do crazy thing you like, but that goes for every function call. I remember debugging some (Java code, but that is besides the point) where the programmer had decided that getFoo() should actually change the internal state of the object in such a way that calling getFoo() twice totally screwed up the program. That was every bit as bad as if he has overloaded operator- to do the same.

      Slicing, I agree, is a real problem, though I have seldom encountered it in real life. Perhaps because I like to keep all but my leaf classes abstract, which more or less eliminates the slicing problem.

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    2. Re:The problem with C++ is it's too powerful by poppopret · · Score: 1

      Overloading '=' is nothing. People overload '()' even. (yes, the parentheses) People overload ',' and '->' and worse.

    3. Re:The problem with C++ is it's too powerful by David+Greene · · Score: 2

      What is it about operator overloading that gets people all tied up in knots? An operator is just a function. It has a name, just like every other function. That name can be helpful or misleading, just like every other function. Operators are just functions. Really.

      --

    4. Re:The problem with C++ is it's too powerful by shutdown+-p+now · · Score: 1

      What's wrong with overloading "()" and "->"? That's indispensable for smart pointers and function-like objects (callable things with optional state... i.e. closures).

    5. Re:The problem with C++ is it's too powerful by Anonymous Coward · · Score: 0

      You don't know what you are talking about. Objects overload the function operator to create function-like objects. It is the easiest, and most elegant way (without true closures) to create invocations of functions that have their own state, while keeping the function itself reentrant.

    6. Re:The problem with C++ is it's too powerful by lgw · · Score: 1

      The people who hate it most seem to be C "programmers" who don't use functions. Sad as it is, those SOBs haven't all aged out yet.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    7. Re:The problem with C++ is it's too powerful by Noughmad · · Score: 1

      What is it about Zaphod Beeblebrox that gets people all tied up in knots? Zaphod is just this guy, you know. He has a name, just like every other guy. That name can be helpful or misleading, just like every other guy. Zaphod is just this guy, you know. Really.

      Not to discredit your comment, but I think it sound better this way.

      --
      PlusFive Slashdot reader for Android. Can post comments.
    8. Re:The problem with C++ is it's too powerful by maxwell+demon · · Score: 1

      And when Joe Shortcut figures out that he can define the "assign" function to slice his ham sandwich ...
      Frankly, I don't see how misusing operator overloading is different from misusing function names.

      OTOH operator overloading is essential if you want to have reasonable syntax for user-defined number types. You don't want to write a.assign(b.plus(c)) or assign(a,plus(b,c)) instead of a=b+c.

      And be assured, the confusion you can cause with operator overloading is nothing compared to the confusion you can cause with ordinary C macros ...

      --
      The Tao of math: The numbers you can count are not the real numbers.
    9. Re:The problem with C++ is it's too powerful by GodfatherofSoul · · Score: 1

      To all the people commenting about operator overloading. It's not a problem when it's used responsibly, but the problem is people abUSE some of C++'s features. So, someone coming in and using a library expecting intuitive behavior gets something wildly eccentric because a developer just wanted a shortcut or hammered a square peg into a round hole.

      --
      I swear to God...I swear to God! That is NOT how you treat your human!
  20. Linking by MrEricSir · · Score: 3, Interesting

    The biggest beef I have with C++ is linking.

    Linking to a library that was compiled in a different C++ compiler (or even a different version of the compiler you have) is somewhere between painful and downright impossible; this is because function name mangling was never standardized and the core libraries are often incompatible.

    Couldn't they standardize this in C++? It would make life so much nicer for those who deal in binaries.

    --
    There's no -1 for "I don't get it."
    1. Re:Linking by lgw · · Score: 1

      They can't really standardize it because it's very platform specific. Your compiler vendor should try not to break things between versions, though (Microsoft really stepped in it when they changed the default for wchar_t from short to a distinct type, and basically broke everything across that boundary by default).

      --
      Socialism: a lie told by totalitarians and believed by fools.
    2. Re:Linking by Prune · · Score: 1

      Mod parent up please--compared to most of the other posts here, this is actually a valid criticism. I think a partial justification here is whole-program optimization/link-time code generation which can span multiple object files and is necessarily compiler specific.

      --
      "Politicians and diapers must be changed often, and for the same reason."
    3. Re:Linking by shutdown+-p+now · · Score: 4, Informative

      It can't be standardized in the language spec itself, because there's no notion of "object files" or even "linking" in general in the spec - it's not tied to a particular implementation technique. That's why you can actually write a conformant C++ interpreter.

      Now a separate standard for C++ ABI is quite possible, and they do, in fact, exist. The trick is getting the compilers to subscribe to them, and the problem is that they already have their existing ABI (usually incompatible with other vendors), and moving to standardized ABI would break compatibility with libraries compiled with older compiler versions. It's not a big deal in Unix world where source code is generally available these days, which is why Unix compilers (e.g. g++ and Intel) converged on a common one; but Windows stuff is still broadly incompatible.

    4. Re:Linking by greed · · Score: 1

      It's worse than that. All the method invocations are done in binary, so if things "move about" in the underlying C structure, you're hosed. It's not just mangling, it's actual data structure layout.

      You'd be hosed in C if you moved structure members around, too; but your functions weren't part of the structure. In C++, they are--or rather, can be. It depends on their virtual-ness... and the inheritance... and probably other things. If you're really, really, really good, you can update class definitions and retain binary runtime compatibility. I've only seen people take that sort of care with compiler runtime libraries--anywhere else, and the time becomes approximately infinite while the benefit of "not having two versions installed" remains constant.

      The solution is to do method invocation with some sort of symbolic runtime search; SmallTalk, Objective C, Perl, Python, and Java all do this in one way or another. But that's why C++ was so appealing when it was young: it was faster than those other languages (at least, those that existed at the time).

    5. Re:Linking by Anonymous Coward · · Score: 1

      It's not up to the language to specify platform ABI standards. Blame your OS vendor. And if your compiler does not follow the specified platform ABI, blame your compiler vendor. But don't blame the language. C, for example, does not specify any ABI. But one typically doesn't have problems with linking C programs from different compiler vendors. That's because virtually all OS/platform vendors specify a strict C ABI standard.

    6. Re:Linking by Anonymous Coward · · Score: 1

      Frankly, you don't know what you are talking about. In C++, a structure defined the same as it would be in C is REQUIRED to be laid out in memory the SAME as C. It is called a POD (plain old data). And the new standard expands this guarantee to a larger range of simple classes.

    7. Re:Linking by Anonymous Coward · · Score: 0

      Um, things don't "move about" in the underlying C structure. The C Standard required that a structure is laid out in memory in the same order as it is define. C++ has the same requirement for structures defines in the same manner as C would.

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

      A conforming implementation can align the fields in the struct however it wants, though.

    9. Re:Linking by Noughmad · · Score: 1

      It would make life so much nicer for those who deal in binaries.

      Those would be the Sith of the digital age?

      --
      PlusFive Slashdot reader for Android. Can post comments.
    10. Re:Linking by jonwil · · Score: 1

      As someone who has been dealing with C++ ABI issues for a while now, it just wont work. Getting all the compiler vendors on a given platform to agree to a standard ABI (particularly on platforms like Windows where there are so many options) is never going to happen.

    11. Re:Linking by MrEricSir · · Score: 1

      Why not? Windows has a standard ABI for C.

      --
      There's no -1 for "I don't get it."
    12. Re:Linking by jonwil · · Score: 1

      Said ABI is not a standard for C, its a standard for Windows. (STDCALL)
      C++ has a much more complicated ABI.

    13. Re:Linking by noidentity · · Score: 1

      If the vendors can't agree on a standard, why do you think a standards body can? Besides, as someone else said, the C++ standard doesn't specify object files or linking; that's open to the compiler, since platforms differ widely in what they support and how things are compiled and built into a program.

    14. Re:Linking by maxwell+demon · · Score: 1

      A conforming implementation can align the fields in the struct however it wants, though.

      That's true in C as well.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    15. Re:Linking by sjames · · Score: 1

      It could have been included in the spec from the very beginning. Just state that if object code is produced at all it must conform to the attached ABI.

      Now that conflicting implementations are already out there it's a lot harder to re-converge. The best they can do is a multi-step process starting with emitting the new standard symbols with aliases to the old non-standard.

    16. Re:Linking by shutdown+-p+now · · Score: 1

      It could have been included in the spec from the very beginning. Just state that if object code is produced at all it must conform to the attached ABI.

      ABI is more than just name mangling, though - it's also things like how parameters are passed, how exceptions propagate, etc. You need that also to make link-compatible object files from different compilers. But all that stuff is inherently architecture-specific, and sometimes (e.g. in case of exceptions on Windows) also OS-specific. It doesn't have a place in a spec that is inherently platform-agnostic.

      Should a separate ABI have been done earlier? Probably, but the problem is that C++ gained popularity before it was a committee-designed language. Originally it was pretty much defined by what AT&T implemented in CFront. By the time they got the first design committee going, there were already a bunch of implementations playing catch-up. And the language was still changing quickly at the time - consider all the template stuff, for example. Defining ABI was, on one hand, too hard, and on the other, few actually cared. By the time there was a solid standard in place, there were already a bunch of heavily-used, entrenched and incompatible implementations.

    17. Re:Linking by 21mhz · · Score: 1

      Defining an ABI for C++ is hard, because language features were added without much consideration to what would it require at the linkage level, especially with dynamic linking. The whole idea of sticking to the C linkage model while piling up features that required generation of vaguely located code, was broken to begin with. I had some good fun investigating weak linkage problems when somebody decided to unload a dynamic module. We found around three dosen emissions of one commonly used template-instantiated function in various shared libraries and modules. God help you if some emitted definitions for a weak symbol end up incompatible for some reason.

      --
      My exception safety is -fno-exceptions.
    18. Re:Linking by shutdown+-p+now · · Score: 1

      Oh yes, ODR violations on templates can appear in very non-obvious circumstances, and be insanely hard to debug. Why the compilers still don't do proper checking at link time (to see that all instantiations match per ODR rules; can be as simple as hashing the original tokens and storing that in the object file to compare) is beyond my understanding.

    19. Re:Linking by 21mhz · · Score: 1

      Oh yes, ODR violations on templates can appear in very non-obvious circumstances, and be insanely hard to debug. Why the compilers still don't do proper checking at link time (to see that all instantiations match per ODR rules; can be as simple as hashing the original tokens and storing that in the object file to compare) is beyond my understanding.

      Perhaps because, by doing that, they would essentially make any compiler options affecting code generation matter for the ABI, and this would make linkage intolerably fragile.

      --
      My exception safety is -fno-exceptions.
    20. Re:Linking by David+Greene · · Score: 1

      Hrm...look here. If you're developing an x86 compiler these days and not adhering to this standard, you've pretty much locked yourself out of customers.

      --

    21. Re:Linking by jonwil · · Score: 1

      An ABI spec is all well and good but it doesn't solve the fact that Visual C++ and GCC are never going to implement the same C++ ABI. Microsoft is never going to implement the GCC ABI (or the one in that standards doc which may well be the same, I havent checked GCC recently)
      GCC is never going to implement the Microsoft ABI (its undocumented and has lots of corner cases plus the GCC-on-windows people generally dont like things that have been figured out by reverse engineering Microsoft binaries)

    22. Re:Linking by shutdown+-p+now · · Score: 1

      Perhaps because, by doing that, they would essentially make any compiler options affecting code generation matter for the ABI

      Er, no, they won't. Again, I'm talking about hashing the original sequence of tokens forming the source code for the template at hand, not about hashing the generated code. That is, it exactly matches the way ODR is defined in the language standard, which also requires that definitions for the same object in various translation units have to match token-for-token.

    23. Re:Linking by 21mhz · · Score: 1

      Ah, sorry for misreading. That could work indeed.
      It should even be doable with the current ELF, as it has symbol tags already.

      But still, redundant code emissions are a lousy solution, resulting in code image bloat and more porous cache utilization at runtime. There is also RTTI, which is either slow or broken across DSO boundaries.

      --
      My exception safety is -fno-exceptions.
    24. Re:Linking by sjames · · Score: 1

      Sure, there's more to it than that and I don't expect it to be a constant across significantly different platforms like Windows and Linux (though consistency between *BSD and Linux would be nice), but there's no reason it can't be constant across compilers in the same platform.

      Back in the days of cfront, the issue was down to the underlying C compiler and any C++ specifics could actually be consistent across platforms.

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

      You're mistaken. The C++ standard does describe the process of linking: it states that the processed Translation Units are combined to produce the final program. It doesn't specify object files, though. That makes sense when you realise that a compiler could very well use another IPC mechanism, or that the linker may in fact be in the same process as the compiler. In such designs, there's no need for object files.

      As for C++ ABI's, you're right: those are indeed best handled by suplemental standards.

  21. Re:c++ 1x sucks by FuckingNickName · · Score: 1

    My experience with C++ developers in the late 90's was that 99% of them knew only a tiny, tiny percentage of the language.

    My experience is that 99% of people muddle through life with a combination of hubris and clandestine effort.

    A similar proportion express that their knowledge and talent is well above average and insist that almost every challenge is trivial.

    This group is overrepresented on Slashdot.

  22. Re:c++ 1x sucks by DMiax · · Score: 1

    It's a long time before anyone starts to use nullptr. NULL is still shorter to type and too entrenched in the documentation. What I do not understand is why tey kept NULL there.

    Is there any reason not to break backward compatibility? If there is any of that in some legacy code you can split your codebase in two and compile with different versions. Other languages break legacy code at every version and still manage to stay around. I think this is because every code big enough that you cannot rewrite is probably modular. I am usually against patching instead of fixing, especially on something that should be used by everyone. Of course I never designed a language, so maybe I am wrong...

  23. C++0x compiled! by hackingbear · · Score: 4, Funny

    According to Wikipedia, "C++0x" is pronounced "see plus plus oh ex". After three rounds of macro preprocessing, four expansions of template substitutions, and reversing five levels of dynamic cast operator overloads, the name is eventually compiled to something readable: C plus plus? Oh, my ex-programming language!.

    1. Re:C++0x compiled! by Prune · · Score: 2

      I often wish Slashdot had an option whereby one could hide all posts moderated as 'Funny'--after all, it's Slashdotters making a judgment of humor...

      --
      "Politicians and diapers must be changed often, and for the same reason."
    2. Re:C++0x compiled! by melikamp · · Score: 1

      "C++0x" can be naturally interpreted as 1337 "CHOx".

    3. Re:C++0x compiled! by narcc · · Score: 1

      I often wish Slashdot had an option whereby one could hide all posts moderated as 'Funny'--after all, it's Slashdotters making a judgment of humor...

      Considering that humor is subjective, and this is slashdot...

      Have you considered the possibility that you're just not smart enough to 'get' the jokes?

      I suppose it's also possible that you're simply humorless and uninteresting, but having seen your other posts, I'm going to go with the former.

    4. Re:C++0x compiled! by harmonise · · Score: 2

      Look at your comment preferences. You can change the value that is assigned to comment moderation. Funny is at +1. Just change it to -5 and you'll never see another "funny" post.

      --
      Cory Doctorow talking about cloud computing makes as much sense as George W Bush talking about electrical engineering.
    5. Re:C++0x compiled! by Anonymous Coward · · Score: 0

      How insightful!

    6. Re:C++0x compiled! by m50d · · Score: 1

      Uh, you can set posts listed as funny to be adjusted by -5 in your preferences.

      --
      I am trolling
    7. Re:C++0x compiled! by azgard · · Score: 1

      So C++ originally stood for "C plus plus? My programming language!" ?

    8. Re:C++0x compiled! by Anonymous Coward · · Score: 0

      Wondeful! Many thanks

    9. Re:C++0x compiled! by Anonymous Coward · · Score: 0

      Looks like that touched a nerve!

      Appeal to subjectivity is a lousy excuse for poor taste, in humor or otherwise. And the trolling attempt of insulting the intelligence of the GP by suggesting he missed the punchline is undeniably unfunny. One can easily appreciate the great classic French wit and the mid 20th century British humor, yet see nothing amusing in the nerdy, meme-laden, pseudointellectual trash that passes for humor around here. Your superannuated ass should be mature enough to know better.

  24. Re:Could they not have named it something sensible by Anonymous Coward · · Score: 1

    Sigh. Why do we still have to go through this? That is the designation to distinguish when you are talking about the new standard. That is NOT its name. The language is still just C++. ALL ISO language standards committees do this. When the new standard comes out, the language will be called C++. You write things like C++03 and C++0x or C90 and C99 to distinguish between them.

  25. Re:Could they not have named it something sensible by Korin43 · · Score: 3, Informative

    Because it's still just C++. C++0x is just one particular version, like C++98 or C++03. Java 1.6.23 doesn't exactly roll off the tongue either.

  26. Re:Could they not have named it something sensible by Anonymous Coward · · Score: 0

    C++-oh-X is as easy to say as any of your suggestions, and the word is "cue" you weak-minded trumpster.

  27. C++0x? by Anonymous Coward · · Score: 0

    Cocks?

  28. Re:c++ 1x sucks by David+Greene · · Score: 1

    Does anyone actually use any of the features of C++?

    Yes. So far I've used:

    • Right angle brackets
    • shared_ptr
    • unique_ptr
    • binders
    • Variadic templates
    • auto

    And that's just in my own code, not counting features that libraries use (rvalue references, for example). I'd use a lot more if they were implemented in g++.

    The next C++ standard is going to be a huge improvement in usability, especially for writing generic code.

    --

  29. Your queue by Anonymous Coward · · Score: 0

    Actually it is my cue to inform you that you used the wrong word that sounds like the letter 'Q'.

  30. Learn about namespaces! by Anonymous Coward · · Score: 0

    thats all

  31. Re:c++ 1x sucks by shutdown+-p+now · · Score: 3, Funny

    It's a long time before anyone starts to use nullptr.

    If you ever ran Visual Studio 2010, you have used a product that uses nullptr in some parts of its source.

    (while we're at it, it also has C++0x lambdas)

  32. Re:c++ 1x sucks by jgrahn · · Score: 2

    It's a long time before anyone starts to use nullptr. NULL is still shorter to type and too entrenched in the documentation.

    In which documentation? "The C++ Programming language" mentions it twice, and says it's a C thing which you should avoid -- just use 0. Which is what I do.

    Of course you can still *call* it "the NULL pointer" when you talk about it.

  33. Chalk by tempest69 · · Score: 1

    Which in turn will be mispronounced to Chalk, which is a kinda workable language name.
    It Makes me suspect that the erase feature is fast and dirty.

  34. ITS OVER 9000++! by TiggertheMad · · Score: 1

    well lets be fair: C++ is a flexible and powerful, it was designed to be. If you have a developer that isn't very good, they will produce code that is a unorganized mess. In the hands of a skilled dev, there is nothing wrong with C++. They can produce some very elegantly designed data structures. But this is true of any language.

    You are in essence condemning fire because it can cause burns.

    --

    HA! I just wasted some of your bandwidth with a frivolous sig!
    1. Re:ITS OVER 9000++! by maxwell+demon · · Score: 1

      They can produce some very elegantly designed data structures. But this is true of any language.

      Hmmm ... I'd like to see how you produce some very elegantly designed data structures in classic BASIC :-)

      --
      The Tao of math: The numbers you can count are not the real numbers.
    2. Re:ITS OVER 9000++! by TiggertheMad · · Score: 1

      Hmmm ... I'd like to see how you produce some very elegantly designed data structures in classic BASIC :-)

      Its simple, you jusy write a BASIC program that starts up a C++ IDE.

      Joking aside, proper use of GOSUBs could produce a functional programming language like structure. If you pass a few addresses (PEEK and POKE if I recall), I think you could get some ad-hoc simple object-like behavior. It would probably look as convoluted as COBAL, but it could be done. But, yeah BASIC was shit.

      --

      HA! I just wasted some of your bandwidth with a frivolous sig!
  35. Re:c++ 1x sucks by Desler · · Score: 1

    "The C++ Programming language" mentions it twice, and says it's a C thing which you should avoid -- just use 0. Which is what I do.

    And then you have to do all sorts of workarounds for it when you have overloaded functions where it thinks you are passing it to the one that takes an integer instead of the one assuming a pointer.

  36. C++: a good academic exercise. Not much else by Anonymous Coward · · Score: 0, Insightful

    A few years ago, I was invited to a musical performance. It was performed by a lady I knew who was completing her PhD in musical performance. She was hoping to round up people to attend the performance. I, along with about 4-5 others went as a group, and in a hall that can hold about 350, there were 20 or so in total. There were three people at the front -her teachers- grading her performance. The pieces were quite.... longhair. One was immensely atonal. It seemed to be a mere exercise in accurately hitting notes at one end of the piano keyboard, then at the other end, and then back and fourth a few dozen times. It did not sound like music in any traditional sense of the word. Why am I talking about this when the Slashdot piece is about C++? C++ is a good academic exercise. It provides nothing else. C, is a great, all purpose, fully functional, Turing complete language (full stop). It didn't need anything major added to it. It was and is fine. A few cleanups here and there, a few cases where things could be done a bit better, but its expressive, logical and elegant. So then we have C++. Elegance is gone. Out the window. We traded clarity, for obscurity. And what did we trade it for? What? Well now thats the big question, isn't it? What exactly did we get? Overblown? Overhyped? What real good functionality do we get, that we did not have before? Is there anything useful in C++ that did not exist in C? NO, thats the whole point. We were fine with C. C is complete. Its a bit like the movie Highlander. It was fine on its own, but then Highlander 2 comes along. OH MY THE DISAPPOINTMENT! What a failed exercise! What a waste of time and effort! I've heard people making arguments for C++ for a long time. They fail. Elegance, simplicity, beauty were replaced by something matching Cobol in verbosity, and binary in readability. Oh, we are told, you just need to examine a few thousand classes to understand... and thats where it fails in elegance. Like its object oriented, overloaded, overblown brethren, it hypes it virtues, fails on those, and ruins what was elegant. This truly isn't anything about zeal, this is the practicality of the language itself. Its an academic exercise, best left in academia. It provides nothing useful that hasn't been done better elsewhere.

  37. Bjrane: by Anonymous Coward · · Score: 0

    WHEN are you going to implement dynamic memory allocation tracking?
    Memory leaks are one of the major headaches in C++. That's the main reason people use C# over C++. Mix that in with exceptions and I doubt any application beyond the most trivial won't memory leak.

  38. Oh God! Black text on a dark blue background! by Anonymous Coward · · Score: 0

    What is this? "My First HTML Page" class at some high school?

    1. Re:Oh God! Black text on a dark blue background! by maxwell+demon · · Score: 1

      Maybe you've got the style blocked by some extension? I only had the blue background until I told RequestPolicy to allow fsdn.com. Then the background of the text turned white.

      --
      The Tao of math: The numbers you can count are not the real numbers.
  39. Header files by Twinbee · · Score: 1

    I wonder if they'll *finally* get rid of those cumbersome backwards things called header files.

    --
    Why OpalCalc is the best Windows calc
    1. Re:Header files by Anonymous Coward · · Score: 1

      To be honest, I find header files absolutely fantastic, especially for getting an overview of a class and its capabilities _WITHOUT_ using an IDE. In C# and Java, this is impossible without wading through the entire implementation file or using a bloated IDE and fumbling around with the overview of the class you're reading, ie. click scroll scroll scroll scroll click scroll scroll scroll right-click click! scroll scroll scroll scratch head scroll scroll scroll

      It also means you can distribute development libraries and the relevant header files so other developers can link to the library without you having to give away the code to the actual library, so it is very neat.

    2. Re:Header files by Twinbee · · Score: 1

      Both of those issues can be solved through a small add-on utility which can parse through the text and give you a summary. Even the text editor could do that on the fly in theory.

      But to force error-prone duplication in the form of a header file is a pain which should have disappeared a long time ago.

      --
      Why OpalCalc is the best Windows calc
    3. Re:Header files by JesseMcDonald · · Score: 1

      I find header files absolutely fantastic, especially for getting an overview of a class and its capabilities _WITHOUT_ using an IDE. In C# and Java, this is impossible without wading through the entire implementation file...

      It's pretty much impossible in C++ too, if the header declares any templates or inline functions, since their definitions have to go into the header file along with the declarations. The STL, for example, consists almost entirely of (dense) header files mixing interfaces with implementation details. It's not always that bad, of course, but then you have mandatory duplication, complex preprocessing, multiple-inclusion and related issues to deal with.

      In Java, at least, the public API(s) of a class should be defined in one or more interfaces, which are easy enough to scan through, and all you need care about regarding the class itself is that it implements certain interfaces conveniently listed on the first line of the class definition. If you happen to need an overview of a class file for which you lack source code all you have to do is provide it to javap, no IDE required:

      $ javap -classpath /usr/share/java/hsqldb.jar org.hsqldb.Database
      public class org.hsqldb.Database extends java.lang.Object{
      int databaseID;
      java.lang.String sType;
      java.lang.String sName;
      //...
      public synchronized org.hsqldb.lib.FileAccess getFileAccess();
      public synchronized boolean isStoredFileAccess();
      }

      --
      "The state is that great fiction by which everyone tries to live at the expense of everyone else." - Bastiat
    4. Re:Header files by mswhippingboy · · Score: 1

      If I recall correctly, IBM VisualAge C++ (4.0 I believe) made the creation and inclusion of header files optional many years ago. I never used that feature but I do remember it being available. Whether this was done in the compiler itself, or just masked by the IDE I can't say. Seemed like a neat feature at the time though.

      --
      Sometimes the light at the end of the tunnel is the headlight of an oncoming train.
    5. Re:Header files by smellotron · · Score: 1

      It's pretty much impossible in C++ too, if the header declares any templates or inline functions, since their definitions have to go into the header file along with the declarations.

      Seems pretty easy to me:

      // foo.h
      #ifndef FOO_H // feel free to rag on include guards...
      #define FOO_H

      int rdtsc();

      template <typename T>
      T string_cast(const std::string &s);

      #include "foo.inl"
      #endif

      If you're really curious, I guess you can peek into the implementation, but there's nothing required about it:

      // foo.inl
      inline int rdtsc() {
      // few lines of inline asm...
      }

      #include <sstream>
      template <typename T>
      T string_cast(const std::string &s) {
      std::istringstream s;
      T t;
      s >> t;
      return t;
      }

      If the user doesn't peek into the inl file

    6. Re:Header files by JesseMcDonald · · Score: 1

      How is that any better than putting everything in one file, perhaps with a comment separating the declarations from the definitions? Splitting one header file into two does not appear, IMHO, to add much value. So far as the language itself is concerned everything in the ".inl" file is just as visible to client code as the top-level header; there is nothing to prevent declarations in the ".inl", and in fact if you should happen to leave out one or more stand-alone declarations at the top level you probably won't even get a warning.

      The Java version, on the other hand, avoids the redundancy of manually storing type information in two separate source files, and you can still get the overview you want—guaranteed to match the class it was generated from—via a standard command-line JDK tool every Java developer has access to.

      And, as I said, if you want to separate interfaces from implementations in Java there are, well, interfaces for that. Just put the public API in one file, and the class implementing that interface in another. The use of interfaces is good practice in any event, and much more flexible than simply separating declarations and definitions as in C++.

      --
      "The state is that great fiction by which everyone tries to live at the expense of everyone else." - Bastiat
    7. Re:Header files by smellotron · · Score: 1

      How is that any better than putting everything in one file, perhaps with a comment separating the declarations from the definitions?

      I didn't intend to argue that it's better than everything in one file; it's just a continuation of the overall conversation:

      I find header files absolutely fantastic, especially for getting an overview of a class and its capabilities _WITHOUT_ using an IDE.

      It's pretty much impossible in C++ too, if the header declares any templates or inline functions, since their definitions have to go into the header file along with the declarations.

      Your statement implies that inline/template definitions clutter the header files, presumably because they're defined inline. I'm just demonstrating that it's trivial to eliminate the clutter. Sure it may be more work than using javap, but it's really not a lot of work.

  40. Re:c++ 1x sucks by Anonymous Coward · · Score: 1

    You don't have to learn the whole language to get advantage from it.

    Procedural programming style with C++ is just as easy as with C and you get the benefit that if you want to use something neat like stl::string you can.

    I feel most sorry for the people who are stuck with using pure C. Usually either by choice (maybe the 0.0001% speed boost matters?) or by lack of C++ runtime libraries (kernel level programming). If you can take the day or two it takes to learn C you now know enough to create meaningful programs in C++. There's nothing wrong with C-style programming in a C++ environment. If anything the overuse of classes and objects by end-users is a problem with C++, the language itself is fine.

  41. Re:c++ 1x sucks by Homburg · · Score: 2

    NULL is defined to be integer 0 in C++, so you have to do these workarounds when you use NULL, as well; indeed, one of the advantages of using 0 is that it serves as a bit of a reminder that you need to keep these workarounds in mind.

  42. Re:C++: a good academic exercise. Not much else by Anonymous Coward · · Score: 0

    Each to their own I suppose. It has been useful to me, for writing plenty of software across multiple platforms. Just because you have a love of C doesn't mean everything else is dreadful. You don't have to use it, nor do you have to whinge.
    Many people I know think that Jazz music sounds dreadful, but that doesn't make it bad. They don't have to listen to it, and it would be better if they don't whinge about it.

    If you miss the interplay of the backing section with the lead lines and the swapping of lead lines and interplay in Jazz, I suppose it would be lost on you. But that's not a problem. No need to whinge about it.

  43. Re:c++ 1x sucks by maxwell+demon · · Score: 1

    So you don't value the fact that there's now a well-defined memory model for multithreading, as well as a standard interface to it so you can do cross-platform multithreaded code without #ifdef or relying on third-party code?
    And you don't value that they removed the restriction that you couldn't use local classes as template parameters?
    And you don't value the fact that returning standard library classes by value will now be much more efficient, thanks to move semantics?
    And you don't value that regular expressions are now supported in the standard library?

    --
    The Tao of math: The numbers you can count are not the real numbers.
  44. I lolled by shish · · Score: 1

    imminent

    C++0x

    Did anybody else laugh out loud seeing those two words next to each other?

    --
    I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
  45. Terrible libraries are a fact of life by tepples · · Score: 1

    If [operator +] does something unexpected, chances are you [...] are using a terrible library

    Terrible libraries are a fact of life. In many cases, you don't have the clout to change the specification of your program to use different libraries. So we need a language that doesn't encourage the creation of terrible libraries.

    1. Re:Terrible libraries are a fact of life by heironymous · · Score: 1

      While I am loathe to seem to defend the position of an anonymous coward who uses the term "retard" as a pejorative...

      Yes, terrible code is a fact of life. And a language feature like operator overloading can either ameliorate or exacerbate that. But I suggest that it's more than merely a matter of taste to support infix operators. Their ubiquitous use in mathematics indicates that they help reasoning about expressions. I miss them in Java.

    2. Re:Terrible libraries are a fact of life by Anonymous Coward · · Score: 0

      So we should dumb down languages because library writers can't code? Bullshit. I agree with you (I even gave examples in my post of how it may not be your fault), I disagree with your resulting opinion about operator overloading, though.

  46. Platform dictates language choice by tepples · · Score: 1

    I'm the type to make it easier, or switch to a language where it is easier.

    Until you end up on a platform that only runs one language. For example, Xbox 360 XNA and Windows Phone 7 run only C# (or other languages isomorphic to C#), and BlackBerry runs only Java. For a few months, while Apple and Adobe were feuding over AIR, iPhone and iPod touch ran only Objective-C and C++ in apps and JavaScript in web pages.

    1. Re:Platform dictates language choice by SanityInAnarchy · · Score: 1

      I'm the type to make it easier, or switch to a language where it is easier.

      Until you end up on a platform that only runs one language.

      How would I "end up" on such a platform? The only time I've ever done so was HD-DVD, and that was JavaScript and XML. Could've done without the XML, but its DOM wasn't bad, and JavaScript wasn't bad.

      For example, Xbox 360 XNA and Windows Phone 7 run only C# (or other languages isomorphic to C#), and BlackBerry runs only Java.

      Are you talking about languages or platforms?

      If you mean languages, don't both of those platforms support any CLI language? Doesn't BlackBerry support any JVM language?

      For a few months, while Apple and Adobe were feuding over AIR, iPhone and iPod touch ran only Objective-C and C++ in apps and JavaScript in web pages.

      Which is why I'll never target a native app at iOS.

      --
      Don't thank God, thank a doctor!
    2. Re:Platform dictates language choice by tepples · · Score: 1

      If you mean languages, don't both of those platforms support any CLI language?

      In theory, yes, but more or less all languages that compile to verifiably type-safe IL are isomorphic to C#. There is a C++-like language called C++/CLI that compiles to IL, but its syntax for verifiably type-safe pointers, references, and arrays is incompatible with that of standard C++. And no, XNA and Silverlight can't run dynamic languages (DLR) because their CLR lacks Reflection.Emit.

      Doesn't BlackBerry support any JVM language?

      It would, as far as I know. I've never had a chance to use let alone program for a BlackBerry device.

    3. Re:Platform dictates language choice by SanityInAnarchy · · Score: 1

      And no, XNA and Silverlight can't run dynamic languages (DLR) because their CLR lacks Reflection.Emit.

      Really?

      Doesn't BlackBerry support any JVM language?

      It would, as far as I know. I've never had a chance to use let alone program for a BlackBerry device.

      I'm not sure if it's relevant anymore, but for the record, JRuby exists for Android -- and Android isn't even a proper JVM.

      --
      Don't thank God, thank a doctor!
    4. Re:Platform dictates language choice by tepples · · Score: 1

      XNA and Silverlight can't run dynamic languages (DLR) because their CLR lacks Reflection.Emit.

      Really?

      I apologize. I had in mind the version of Silverlight used as the primary API for applications on Windows Phone 7, not desktop Silverlight.

    5. Re:Platform dictates language choice by SanityInAnarchy · · Score: 1

      Ah, I didn't know that... weird. I wonder if it's the same for XNA.

      Regardless, my response is still the same -- that the platform is proprietary is already a reason I wouldn't want to touch it. That it controls distribution is worse. That it dictates a single language for no good reason, in addition to the other two, makes me want to avoid it like the plague.

      Of course, I still wish browsers had some sort of standard VM, to make it easier to run other languages on them, but JavaScript might even be fast enough. There was a proof-of-concept Ruby VM implemented in JavaScript, which ripped Ruby bytecode out of a server-side interpreter and interpreted it in JavaScript, and it ran faster than on the native Ruby interpreter.

      --
      Don't thank God, thank a doctor!
    6. Re:Platform dictates language choice by tepples · · Score: 1

      that the platform is proprietary is already a reason I wouldn't want to touch it.

      The only reason I'd ever want to touch XNA is that it's the only way individuals and home-based businesses can develop for a video game console instead of being limited to PCs. Some genres don't work well on the PC because the PC is traditionally associated with single-player or networked multiplayer. There just aren't enough home theater PCs or MAME cabinets around for things like fighting games, multiplayer platformers, or party games to be successful on the PC platform, apart from token exceptions (SF4, Trine, and Rabbids respectively).

    7. Re:Platform dictates language choice by SanityInAnarchy · · Score: 1

      These are all true, but endlessly frustrating to me. For example:

      Some genres don't work well on the PC because the PC is traditionally associated with single-player or networked multiplayer.

      I suspect those games still work decently well with networked multiplayer, but PCs are no less capable of this than consoles. The only limiting factor is what other hardware they're connected to -- monitor, controllers, etc.

      There just aren't enough home theater PCs

      Why the hell not?

      Apparently, people have this impression that it's complicated or expensive to build one, which is why convergence is going in a perverse direction, with computers capable of playing YouTube built in to newer TVs. Controllers aren't exactly hard to find, either, with all three of the major consoles using exclusively standard cables and technologies (USB and Bluetooth) such that they can pretty trivially be connected to a PC.

      I understand the reasons for all of these, but it's still frustrating. Every now and then, I consider getting in the business of selling pre-built home theater PCs, ready to game with. Then I file that away with the idea of selling computers with Linux pre-installed, maybe even with options for Wine, virtualization, or dual boot already set up.

      --
      Don't thank God, thank a doctor!
    8. Re:Platform dictates language choice by tepples · · Score: 1

      There just aren't enough home theater PCs

      Why the hell not?

      I've attempted to cover the reasons I know of for lack of HTPC penetration in this article. But now, from C++ vs. C# to cross-platform APIs vs. XNA to PCs vs. consoles, we've strayed way off-topic; let's please continue on the article's discussion page.

  47. Hello World taking over two-thirds of RAM by tepples · · Score: 1

    Well, variable declared at the top of the function are the least evil c-ism.

    Furthermore, this requirement hasn't been in C for a decade.

    The real problem is a lack of understanding of RAII, and a fear of exceptions.

    Fear of exceptions, STL containers, iostream, and the like may come from having worked on a platform with less than a megabyte of RAM. Case in point: Hello World takes 180 KiB out of a handheld device's 256 KiB of program RAM, and that's after turning on size optimizations, Thumb (compressed instructions), and experimental dead-code elimination in the linker.

    1. Re:Hello World taking over two-thirds of RAM by lgw · · Score: 1

      That's really just iostreams, which I've never liked (I always use printf and some form of ToString(), personally). The vector and string classes are quite reasonable in the compilers I've worked with, and proper coding with RAII and exceptions does not, by itself, add much to object size. Most of the myths of "ZOMG, Hello World is HUEG!!!!!eleventyone!!" have been statically linking the language runtime library in C++ but not in C. I written small (but non-trivial) programs that were in the 30K range on Windows.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    2. Re:Hello World taking over two-thirds of RAM by tepples · · Score: 1

      Most of the myths of "ZOMG, Hello World is HUEG!!!!!eleventyone!!" have been statically linking the language runtime library in C++ but not in C.

      Rest assured I took this into account. Every executable for Game Boy Advance is statically linked because its BIOS does not implement even the C standard library, let alone that of C++. So I built each of these:

      • C++ Hello World with statically linked Newlib <cstdio> and a tty supporting ANSI escapes from devkitPro's libgba: 25 KiB, much of that for an ANSI tty.
      • C++ Hello World with custom conio-style tty: even smaller than that.
      • C++ Hello World with statically linked GNU libstdc++ <iostream>: much bigger.

      And even on Windows, programs compiled with MinGW (port of GCC) haven't been able to dynamically link to Microsoft's C++ library due to incompatible ABIs. C++ ABIs as a rule tend to be far less compatible across compiler vendors than C ABIs, and that's probably the solid basis underlying this myth you speak of.

      I written small (but non-trivial) programs that were in the 30K range on Windows.

      The size of a program includes the size of any DLLs that you are required to include with it. Which implementation of the C++ standard library are you using?

    3. Re:Hello World taking over two-thirds of RAM by lgw · · Score: 1

      The sizes you cite match my experience - the bloat in C++ executable size comes from certain libraries; libraries that aren't very appealing in a constrained environment in the first place.

      The size of a program includes the size of any DLLs that you are required to include with it. Which implementation of the C++ standard library are you using?

      Well, I'd adjust that statement slightly: the size of a program includes the size of any DLLs you are required to distribute with it. The size of the platform is different from the size of the programs that run on that platform, after all (and even contrained environments often have lots of useful libraries in ROM, or functionality in firmware to tatke advantage of to keep your program small). A well-behaved Win32 program uses the system libraries and language runtimes found on the target platform, as the implementation may be different between Windows platforms.

      I just did a quick test on Windows with a recent Visual Studio. HelloWorld.exe (with printf) is:

      • 28k - With just stdio.h
      • 29k - Adding windows.h (which most programs need to do)
      • 28k - Adding #define WIN32_LEAN_AND_MEAN 1
      • 37k - Using iostream instead of printf

      Not bad at all, though iostreams are still bloated.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    4. Re:Hello World taking over two-thirds of RAM by lgw · · Score: 1

      Ahh, those were building debug!

      • 7k - Building release, with printf.
      • 9k - Building Release, with iostreams.

      That leaves little room for complaint; while I have worked on platforms whehre that extra 6-8k would be a problem, we just used assembler directly there.

      --
      Socialism: a lie told by totalitarians and believed by fools.
  48. Literal strings in whose native language? by tepples · · Score: 1

    you need to be able to handle literal strings.

    If you have literal strings in your program, end users who don't speak English won't be able to use it. That's why you're supposed to wrap your strings with gettext macros, so that they get translated to UTF-8 strings in the chosen language pack at runtime.

    1. Re:Literal strings in whose native language? by t2t10 · · Score: 1

      There are many uses of literal Unicode strings besides showing them to users.

    2. Re:Literal strings in whose native language? by tepples · · Score: 1

      There are many uses of literal Unicode strings besides showing them to users.

      And most compilers that I've seen will allow UTF-8 code points in literal strings. What's so special about using UTF-16 vs. UTF-8?

    3. Re:Literal strings in whose native language? by t2t10 · · Score: 1

      We're talking about language standards here, not what specific compilers do. Current C++ support for Unicode and wide character sets is totally broken and unusable.

      It looks like C++0x tries to improve things, but it's too little too late, since we now have a mess of incompatible, vendor-specific solutions in place, and since almost no third party libraries support it. In addition, C++0x waffles on its support, so that there are now a handful of different, incompatible character types to choose from, pretty much guaranteeing massive incompatibilities.

      It will take years before the dust settles over Unicode strings in C++ (if it ever does), and that's too late for something as fundamental as decent string support.

      Broken Unicode support in C++ was the last straw for my company and the reason we basically don't use the language anymore for new projects.

  49. Re:Could they not have named it something sensible by simula · · Score: 3, Informative

    C++0x is the draft name. If it is published by the ISO in 2011 then it will be C++11.

  50. You Know What I'd Like to See in the Language? by Greyfox · · Score: 1

    Ruby-style package management. I'm back on java at the moment, but I fell in love with the Gem system the moment I saw it. Actually I'd like to see a high level package management interface exported by the operating system itself that package managers of all sorts could communicate with, and a C++ package manager that talks to THAT. It's amazing how much of a difference having access to high quality open source libraries makes on the development process.

    --

    I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  51. jumping the shark by t2t10 · · Score: 1

    C++ jumped the shark some time in the early 90's; it's been going downhill ever since, becoming more and more bizarre and bloated.

  52. rope only suitable for self-hanging by poppopret · · Score: 0

    What's wrong with overloading "()" and "->"? That's indispensable for smart pointers and function-like objects (callable things with optional state... i.e. closures).

    Exactly.

    I've seen some pretty horrible resource leaks and reentrancy problems because of allegedly smart pointers that are neither smart nor pointers. I've seen function-like objects become a witch's brew of nasty bugs.

    Beginners love that shit, but then they get themselves into a mess and need somebody like me to rescue them. I do, once I get past my "WTF!!!" reaction to whatever wild feature it is that they are using.

    BTW, in most cases this holds true for threads as well. Use fork() and ppoll() if you want to do the job without bugs.

    1. Re:rope only suitable for self-hanging by shutdown+-p+now · · Score: 1

      I've seen some pretty horrible resource leaks and reentrancy problems because of allegedly smart pointers that are neither smart nor pointers.

      Ah. Imagine that: in Java, I can write a method named "getName()" that will, in fact, do "rm -rf /". Shock! Horror!

    2. Re:rope only suitable for self-hanging by The+End+Of+Days · · Score: 1

      Inexperienced or stupid people can make mistakes doing anything. That's not a reason to prevent experienced people from doing it correctly.

  53. truer words by mevets · · Score: 1

    "C++ is disproportionally used where performance really matters."

    But, as a freelance software dev, this disregard for proportion, is more than bread and butter.

    It covers coke + hookers too. Thanks BS! I hope you keep at it for a while yet....

    1. Re:truer words by Gorobei · · Score: 1

      >But, as a freelance software dev, this disregard for proportion, is more than bread and butter.

      It covers coke + hookers too. Thanks BS! I hope you keep at it for a while yet....

      Every minute I stay in this room, I get weaker, and every minute Charlie squats in the bush, he gets stronger. Each time I looked around the walls moved in a little tighter.

      Staying on the cutting edge makes C&H a petty cash expense, not a line item.

  54. Re:c++ 1x sucks by maxwell+demon · · Score: 1

    Some implementations (e.g. g++) give a warning if you use NULL in a non-pointer context. This is not possible with the literal 0 (because the compiler has no way to know that this specific instance of the literal 0 was meant to be a null pointer, and not a zero).

    --
    The Tao of math: The numbers you can count are not the real numbers.
  55. Re:Could they not have named it something sensible by lennier · · Score: 1

    C++0x is the draft name. If it is published by the ISO in 2011 then it will be C++11.

    Typical C++ design. To save two bytes of RAM they skipped the century testing in the name itsefl, so in 2098 the ISO committee will crash with double-pointer-allocation errors.

    --
    You are not a brain: http://books.google.com/books?id=2oV61CeDx-YC
  56. Remember: The SCO Group owns C++ by walterbyrd · · Score: 1

    Darl McBride (ex CEO of The SCO Group.) : "And C++ programming languages, we own those, have licensed them out multiple times, obviously. We have a lot of royalties coming to us from C++. (August 15, 2002, [1])"

    http://en.wikiquote.org/wiki/Darl_McBride

  57. A POX on his house! by FlyingGuy · · Score: 1

    For even writing the piece of shit.

    --
    Hey KID! Yeah you, get the fuck off my lawn!
  58. Calls to virt funcs during member con/destruction? by Ungrounded+Lightning · · Score: 1

    When:
      - a base class has a virtual member function
      - the base class exposes its "this" pointer externally (for instance: by linking itself into a list)
      - a derived class overrides the virtual member function
      - the derived class of the base class has members of object type that have constricution and/or has calls to external functions in member initializers
      - the construction or other initialization of the derived class members BEFORE executing the body of the derived class constructor calls the virtual function.
    what version (base, derived, something breaks) of the function is executed?

    Similarly for destructors.

    IMHO the specification should REQUIRE that the BASE class version of the virtual function is the one that is executed at any stage prior to the execution of the first line of the body of the constructor and after the execution of the last line of the body of the destructor, while the DERIVED class version is executed during the execution of the body of the constructor, destructor, and at all times between them.

    This was "broken" in 1985ish, when a project I was associated with tried to use C++ as its language. (Treating the constructor and destructor cases separately gives you four binary combinations of behavior of which one is "right" and three are "wrong". Cfront and cfront-derived compilers got it "wrong" one way, three C++ compilers available on IBM PCs got it "wrong" a second way, and gcc got it "wrong" the third way.

    I tried in both ANSI standardization processes to get it "fixed", i.e. defined as I suggest above. I was rebuffed both times. It was declared explicitly undefined behavior in the first ANSI C++ standard and "don't do it" in the second.

    Question: Has it been fixed, or even defined, YET?

    This is NOT an academic issue. C++ (unlike, for instance, Smalltalk and Objective C) has construction semantics that promote and demote the behavior of objects of derived classes in a way that keeps the debugging of unchanged parts of base classes intact when modifications are derived from them, which is one of the things that makes C++ code more robust. And its ability for classes to have members of object type has potential to greatly reduce memory management overhead compared to webs of heap-allocated pieces in the Smalltalk style.

    But this oversight in the specification of behavior on construction and destruction forced that project to the web-of-little-heap-things style regardless, and also has the potential to sucker the programmer into creating extraordinarily subtle bugs.

    So didja fix it, guys? PLEASE tell me you fixed it!

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  59. Re:C++: a good academic exercise. Not much else by jjohnson · · Score: 1

    Most, if not all, of the AAA game industry uses C++, as does Microsoft Windows from about 2000 on, along with Active Directory and SQL Server.

    I'm sorry, you were saying something about how C++ is just academic wankery? Why is the games industry and Microsoft not satisfied with plain old vanilla C, then?

    To take one stab at an answer: because anyone building anything major in C invariably implements part or all of an object or templating system to manage the complexity.

    --
    Anyone who loves or hates any language, platform, or manufacturer, doesn't know what they're talking about.
  60. Seen on Dice.com by sycodon · · Score: 1

    Forward looking company is looking for a self starting, dynamic and versatile C++0X developer. Must have 2 years in depth experience in C++0X.
    Starting rate is $39k

    --
    When Fascism comes to America, it will call itself Anti-Fascism, and tell you to give up your guns.
  61. Re:Could they not have named it something sensible by sjames · · Score: 1

    One louder?

  62. This is deliberate by Anonymous Coward · · Score: 0

    Compilers that have different ABIs use different mangling schemes so that you don't combine incompatible code -- you get big error messages up front, rather than mixing code that assumes different layouts, or different calling conventions, etc.

    When compilers implement shared ABIs (as some C++ compilers do), linking code produced by them just works.

  63. Re:Could they not have named it something sensible by Anonymous Coward · · Score: 0

    Treat the ++ as silent, and an obvious solution presents itself.

    Personally, I think C++ doesn't merit a roll-off-the-tongue name, drawing as much inspiration as it does from INTERCAL ;)

  64. Re: "heck even lisp" by Kaz+Kylheku · · Score: 1

    Lisp is a compiled language, so you don't need C extensions so much, other than to call a foreign API. When you use CPU-intensive routines like cryptography, regular expressions, etc, in a Lisp program, those things are also written in Lisp. The performance is comparable to using C libraries, though Lisp programs can call C libraries easily, and Lisp routines can be passed as callbacks to C code.

    Lisp supports the business model of writing a tamper-resistant proprietary application, distributed to users in binary form, just like C++.

    You can program using Python syntax and semantics in Lisp thanks to the CLPython implementation, which works by compiling the Python code to Lisp forms, which are then compiled by your Lisp compiler. Since Lisp is an extensible language, CLPython appears to you as a library that you add to your program, which then lets parts of your program to be written in Python.

  65. Re:c++ 1x sucks by AuMatar · · Score: 1

    You're not helping make a case for it. The reason nobody has ever wanted lambdas is because they're ugly, confusing, and difficult to maintain. The code is cleaner and better formatted using an actual function.

    --
    I still have more fans than freaks. WTF is wrong with you people?
  66. Don't Boost me by 21mhz · · Score: 1

    Some additions are long overdue, but boy is the syntax ugly. I guess there are only so many neat ways to hack the parser for the already overcomplicated language.

    And of course, Boost demonstrates everything that is wrong with the C++ mainstream these days, including extreme template bloat and failure to address the existence of shared libraries. For practical programming, I'd recommend C++-by-Qt and Vala.

    --
    My exception safety is -fno-exceptions.
  67. The C++ committee has no business inventing! by Kaz+Kylheku · · Score: 1

    Committees should standardize what is out there. Once that is done, they have achieved their purpose and it's time to disband.

    The problem with the C++ committee is that their egos prevent them from going their separate ways.

    Once a committee thinks that it is so important that it can start inventing new features and dictating them to the programmers and implementors, it is the beginning of a disaster.

    Almost never should a draft language contain features that no compiler has. This should only happen very early in the standardization, when there is no other way to solve some conflict between dialects.

  68. Re: "heck even lisp" by t2t10 · · Score: 1

    You can program using Python syntax and semantics in Lisp thanks to the CLPython implementation,

    Great! That lets you combine the poor libraries of CommonLisp with the syntactic limitations of Python.

    The performance is comparable to using C libraries,

    It is possible to get C-like performance out of a CommonLisp compiler, but you have to jump through hoops to do it, and the necessary declarations are different from compiler to compiler (and sometimes even between versions).

  69. Re:c++ 1x sucks by shutdown+-p+now · · Score: 2

    The reason nobody has ever wanted lambdas

    Why do you speak for other people? I don't know a single experienced C++ developer who wasn't excited about lambdas. For one thing, they finally make STL algorithms actually usable, because you don't have to write insane amount of boilerplate.

    For that matter, consider the fact that someone bothered enough to write Boost.Bind and Boost.Lambda, and that even more people used that. This alone shows that a lot of people wanted lambdas.

    they're ugly, confusing, and difficult to maintain.

    Ugly is subjective.

    Confusing - every mainstream language today except Java has them. Heck, VB - VB of all things! - has them, and VB code monkeys don't find it confusing. Perhaps you should catch up with times?

    Difficult to maintain - what, more difficult than hand-written functors with explicit state capture and all that entails? I highly doubt so.

    The code is cleaner and better formatted using an actual function.

    When comparing lambdas to functions, you miss the crucial point of lambdas, which is the fact that they can capture state - that's what makes them so useful. If you e.g. need a function object to pass to std::find_if, and you need to compare against a value of the local variable in that function object, it's trivial to do with lambda:

    int foo(int x1, x2) {
        std::vector<int> xs;
    ...
        auto iter = std::find_if(xs.begin(), xs.end(), [&](int x) { return x >= x1 && x <= x2; });
    ...
      }

    The above is concise (compared to the old way, anyway; Rubyists would probably chuckle), and perfectly clear in its intent.

    On the other hand, you cannot use find_if that way with a plain function at all. You can do it with a handwritten class with overloaded operator(), but then you have to declare the field to save the state, and make sure you initialize it properly. What's worse is that it's tucked away from where it's actually used, so the call to find_if is that much less readable due to need to jump to the definition of the class.

  70. Entertaining Rant on C++ by shmert · · Score: 1

    One of my favorite rants on C++: http://bit.ly/bchSYy

    --
    You drank my drink, you drunk!
  71. C++ is the best of the worst by LostMyBeaver · · Score: 1

    C with Classes... oops I mean C++ is actually a fantastic language when combined with a proper, modern set of libraries. At the moment the only thing we have is Qt. I've heard from avid Boost users how great their system was, but their code tends to be ugly as since and far more complex than necessary.

    While I still code every day in C++, and sadly because of lack of a useful standard library, I work on "roll your own" on our platform, my daily projects tend to be written in VM based languages with bindings to C++ where necessary. C++ is just too old and far too limited to be considered as the base of a new project these days.

    Of course, when it comes to UI development, Qt is just the only option available to a cross platform developer. You have 3 choices these days.

    Develop a new UI for every platform in the native toolkit.

    Use GTK+, Windows.Forms, SWT etc... which actually looks like shit on every platform other than what they were written for in the first place... or in the case of SWT is just plain weird looking on all platforms.

    Use Qt which looks, feels and behaves properly on the platforms it supports.

    In any of the three choices, you still have to customize for every platform because only an idiot would ship a program designed to look great on Windows for Mac, or a designed for Mac for KDE, or designed for KDE on a mobile phone etc... but, Qt makes it easier than most.

    So, these days, while I've love to work in a great language like C# as opposed to a ancient clunker like C++ or C, to make anything even moderately professional in style and features, I need to use Qt and use C++ to do it (don't bother mentioning Jambi, Java was a great experiment, but it's obsolete now)

  72. When is this ghastly language going to die? by SmirkingMan · · Score: 1

    C++ : An octopus made by nailing extra legs to a dog

  73. Re:c++ 1x sucks by Mystra_x64 · · Score: 1

    So you don't like auto because you prefer to type more... I see.

    --
    Quick way to get 30% Funny 70% Troll: defend Opera browser on /.
  74. Please fix the headers issue! by master_p · · Score: 1

    It takes a lot of time to maintain header files. I assume that almost 40% of a project is spent on writing and maintaining header files.

    It is a job that could be done perfectly by the computer, and it could be easily fixed with some simple changes:

    1) When the preprocessor finds an #include directive (for example "foo.hpp"), it checks if the header exists.

    2) If the header does not exist, then try to open the file 'foo.cpp' and extract the header automatically. Put the header in the same folder as the implementation file.

    3) If the header exists, then compare its date and time with the date and time of the implementation file. If the header is older than the implementation file, extract a new header from the implementation file.

    4) cache all headers of all projects into a compiler's directory... a sort of precompiled headers mechanism that is independent of projects and completely automatic.

    These simple changes will boost c++, even much more than the changes in the language itself. I understand that these changes have little to do with the language(*), but, nevertheless, they are extremely significant.

    (*)perhaps for this to work some new toplevel keywords may be required; for example, using 'public:' and 'private:' at translation unit level would help the compiler extract the header as needed.

  75. Some easy improvements c++0x could have. by master_p · · Score: 1

    There are some very easy improvements that have missed:

    1) giving lambda types names. Without specific names for lambda types, functions cannot be statically overloaded for lambdas. They could have named the type '__anonymous_function' or '__lambda_function', where T is the function's signature.

    2) giving a type to the literal {1, 2, 3...}. Standard literals have a type (for example, 3.14 is a double, 3.14f is a float, 5 is an integer, 5L is a long etc). This literal does not have a type, and uniform construction over the initialization list has to be a special case for the compiler.

    3) giving a type to the literal {1, 3.14, "a"}. Since the new language would have tuples, the type of this literal could be the relevant tuple.

    4) allowing functions to be invoked by passing them a tuple, instead of an arguments list. For example, a function foo(int a, double d) could have been called by foo({1, 3.14}) or foo(t) where t is std::tuple.

    5) removing the restriction of having to have a template prototype in order to specialize it. Why not make classes like functions and allow classes to be parametrized with 0, 1 or more template arguments? for example, one could have a class Point, which is the original implementation (say, over integers) and then a new class Point, which contains a double implementation. The compiler would then choose the appropriate class, based on selection of type.

    6) a way to enumerate the members of a struct, function stack record and translation unit variables at compile time. This would open the door for some easy to implement introspection library, as well as other possibilities (a tracing collector, for example).

    7) a way to invoke functions with assignment syntax or without parentheses when they have no arguments. For example, a class could have the functions 'name()' and 'name(string s)', which could be used like 'name = foo.name' and 'foo.name = "bar"' respectively. This could open the door to having object properties via convention.

    8) named arguments. A lot of code is of the form:

    x = new X;
    x->setA(a);
    x->setB(b);
    x->setC(c); ...

    This could be avoided by having named arguments:

    x = new X(A = a, B = b, C = c);

    Plus it would make the code much more readable.

    9) default parameters not only at the right side of a function header, but in any position. A function could be invoked by simply omitting the relevant argument. For example:

    void foo(int x = 0, int y = 0, int a, int b);
    foo(,,1, 2);

    1. Re:Some easy improvements c++0x could have. by David+Greene · · Score: 1

      4) allowing functions to be invoked by passing them a tuple, instead of an arguments list. For example, a function foo(int a, double d) could have been called by foo({1, 3.14}) or foo(t) where t is std::tuple.

      I agree this would be very useful. We can get something close to it with variadic templates but it's ugly.

      5) removing the restriction of having to have a template prototype in order to specialize it.

      I don't see much advantage here. Prototypes are easy to provide.

      6) a way to enumerate the members of a struct, function stack record and translation unit variables at compile time.

      Tuples provide something close for structs, anyway. There's a named tuple paper out there somewhere but I can't seem to find it via Google at the moment. Some introspection would certainly be useful.

      8) named arguments.

      This is #1 on my list of missing features. Default arguments as they stand are dangerous. It's too easy to add a non-default argument and have something that used to map to a default argument instead map to the new argument. This causes all sorts of problems. Default arguments should have been required to be used in conjunction with named arguments, so if a call does not pass all arguments, it would have to name the ones it does. I don't buy Bjarne's explanation for leaving them out in D&E. Other languages have solved those problems.

      default parameters not only at the right side of a function header, but in any position.

      This is another way to eliminate the danger of default arguments. If callers were required to add trailing commas for defaulted arguments, the problems go away.

      --

  76. LISP by Anonymous Coward · · Score: 1

    And strangely LISP has had Lambdas since the 50s and has experienced neither of these problems.

    Sounds like you're a fan boy making excuses to me.

  77. Just like the metric system? by jonaskoelker · · Score: 1

    It's not a big deal in Unix world where source code is generally available these days, which is why Unix compilers (e.g. g++ and Intel) converged on a common one; but Windows stuff is still broadly incompatible.

    Just like everyone else except the US is using this non-standard and incompatible "metric system". ;-)

  78. Re:c++ 1x sucks by T.E.D. · · Score: 1

    ...and if you ever ran VS 6, you have used a prodcut that tries to use null pointers in many parts of is source.

  79. Re:Could they not have named it something sensible by marcosdumay · · Score: 2

    I hope we are not using C++ anymore by 2098...

  80. Re:Calls to virt funcs during member con/destructi by Hythlodaeus · · Score: 1

    I'm not sure of the answer to your question, but the answer to your problem is not to do this:

    - the construction or other initialization of the derived class members BEFORE executing the body of the derived class constructor calls the virtual function.

    This is a circular dependency that will never make logical sense, much less have a sensible implementation. If you find yourself needing to do this, there should be a way to renormalize your object model so that the member objects are not dependent on (or even aware of) the existence of the thing they are destined to be members of (at least until all the parties involved have completed their constructors, but preferably maintaining orthogonality through the entire life cycle)

    --
    For great justice.
  81. Re: "heck even lisp" by Kaz+Kylheku · · Score: 1

    You can program using Python syntax and semantics in Lisp thanks to the CLPython implementation,

    Great! That lets you combine the poor libraries of CommonLisp with the syntactic limitations of Python.

    The performance is comparable to using C libraries,

    It is possible to get C-like performance out of a CommonLisp compiler, but you have to jump through hoops to do it, and the necessary declarations are different from compiler to compiler (and sometimes even between versions).

    Common Lisp has great libraries, and can easily call foreign API's. Lisp can call C functions, pass Lisp functions to C as callbacks. Lisp compilers have extensions that let you manage argument data right on the stack. Recently I needed to call some Win32 functions from Clozure, and found all the goodies there to do the job with minimal overhead.

    Common Lisp declarations for type and optimization are part of the ANSI standard, and generally do the same thing across different compilers.

    "possible to get C-like performance" (Lisp) is a heck of a lot better than "impossible to get C-like performance" (CPython, Ruby, ...). To get "C like performance" from C, you also have to jump through hoops sometimes.

    Of course, I would like "same from compiler to compiler", but when that is not available, my next choice will be "different from compiler to compiler". My third choice after that would be "only one compiler", and an unfortunate fourth would be "no compiler" (CPython, Ruby).

  82. ABI incompatibility by tepples · · Score: 1

    A well-behaved Win32 program uses the system libraries and language runtimes found on the target platform

    Practically, this means that a well-behaved Win32 program is built with Microsoft tools, not free tools. This wasn't practical until Microsoft committed to making Visual Studio Express available to all Windows users with a cable, DSL, or better connection. (Satellite and 3G are out because downloading the 2 GB of VC++ Express and Windows SDK would consume a big chunk of the monthly transfer cap.) By then, MinGW had already frozen into an incompatible C++ ABI.

    1. Re:ABI incompatibility by lgw · · Score: 1

      Practically, this means that a well-behaved Win32 program is built with Microsoft tools

      This has pretty much always been true. Even extremely cross-platform libraries like ACE are pretty crappy on Windows, and if you care about the Windows platform you end up with #ifdefs for the platform specific stuuf, and two different build environments. That's hasn't been particularly onerous even in large environemtns, in my experience.

      This wasn't practical until Microsoft committed to making Visual Studio Express available to all Windows users with a cable, DSL, or better connection

      That's a myth, equivalent to suggesting that you can't build for Unix without downloading Emacs. You have never needed Visual Studio to build programs for Windows, and it has always been the worst choice for a build system (though it's one heck of a great debugger). The Windows DDKs and Platform SDKs (recently renamed to Windows SDK) were free downloads to just get the compiler and libraries, not the gigantic editor. I haven't checked recently, but traditionally the DDKs and SDKs were pretty small (the new SDK includes all the .NET crap, so that may no longer be true), and made it very straightforward to use VI and command-line builds with (n)make files if that's the IDE you prefer.

      --
      Socialism: a lie told by totalitarians and believed by fools.
  83. Size of Windows SDK by tepples · · Score: 1

    The Windows DDKs and Platform SDKs (recently renamed to Windows SDK) were free downloads to just get the compiler and libraries

    I checked on Microsoft.com today, and the current Windows SDK comes on a 1.4 GB DVD image. Good luck downloading that much data in one sitting on satellite or 3G.

    1. Re:Size of Windows SDK by lgw · · Score: 1

      That's .NET for you. The Win2003 platform SDK was a still-hefty 400 MB, but most of that was docs and samples. Basically, any such tool you get from MS in recent years is at least a CD worth of cruft, because they stil think in terms of physical media distribution and see anything less that 700MB as wasted space (it wouldn't surprise me if the current SDK includes Visual Studio, silly as things have become). It wasn't always that bad however. At least the current DDK is still only a CD image, not a DVD image, but still.

      --
      Socialism: a lie told by totalitarians and believed by fools.
  84. Re:c++ 1x sucks by jgrahn · · Score: 1

    "The C++ Programming language" mentions it twice, and says it's a C thing which you should avoid -- just use 0. Which is what I do.

    And then you have to do all sorts of workarounds for it when you have overloaded functions where it thinks you are passing it to the one that takes an integer instead of the one assuming a pointer.

    In ten years of C++ use I never ended up in that situation -- it's probably very rare to overload on integer types and raw pointers which may be null. But I suppose that's one reason they added nullptr.

  85. Re:c++ 1x sucks by jgrahn · · Score: 1

    Sadly, designers do not have much interest in 'fixing' things when they can design new stuff AND increase the number of places their design can be used. That is the problem with C++... the people steering it want a language to solve all problems, and increasingly it becomes worse at solving any,.. or at minimal the increasing number of solutions to any given problem embedded in C++ makes understanding it more and more difficult.

    You make it sound as if they are pushing out troublesome new vanity features in C++ weekly, making the language worse and worse. Examples, please?

    In *my* world, the current standard is 13 years old, and the only important thing that has happened since then is that gcc and VC++ have stopped sucking.

  86. Re:Calls to virt funcs during member con/destructi by Ungrounded+Lightning · · Score: 1

    This is a circular dependency that will never make logical sense ...

    This is SO not true. I'll give you some examples in a bit.

    If you find yourself needing to do this, there should be a way to renormalize your object model so that the member objects are not dependent on (or even aware of) the existence of the thing they are destined to be members of (at least until all the parties involved have completed their constructors, but preferably maintaining orthogonality through the entire life cycle)

    Again not true. The issue is not that the members have an awareness of the eventual object. The issue is that the base class EXPORTS knowledge of and access to common behavior of all classes derived from the base class but the details of which vary depending on which derived class is in question. The promotion of the instance to the derived class "switches on" the details of the behavior - but if this occurs, and is invoked, before the derived class is able to initialize the underpinnings of the behavior, things break.

    One example from the project: Garbage collection via a mark-and-sweep algorithm:
    - All heap-allocated objects subject to garbage collection are members of classes derived from a base class ("Heaper") whose constructor hooks the objects into a list of all allocated Heapers and whose destructor unhooks it.
    - The virtual function in question is the mark-yourself part of the pointer-following marker. (Its guts are generated by a preprocessor that parsed the class declaration.) In a Heaper-derived class it knows about the pointers to other Heaper-class objects at its level. It calls the baseward version of itself and if it returns TRUE calls the mark-yourself functions of all the objects pointed-to at its level. At Heaper itself the function marks the object itself and returns TRUE if it was unmarked.
    - When garbage collection is invoked the Heapers are all unmarked. The collector first calls the mark-yourself functions pointed to by "smartpointers" that constitute the data-structure roots, then walks the list of Heapers, freeing the unmarked and unmarking the marked.

    The problem arises because constructors of member objects of the derived class may cause memory allocation (either temporary or permanent) and this may invoke the garbage collector. If the class has already been promoted to the derived type (i.e. if calling its mark-yourself virtual function gets the derived class version) the garbage collector will try to follow the derived class pointers - which may not be initialized yet. Oops!

    Another case: Exception handling. (This project was running before "catch" and "throw" were more than reserved words.) The similar problem occurs because destructors are such a virtual function. If an exception is thrown from a member object and the class under construction was promoted too soon, you end up running the destructor of the derived class before the constructor was run, again while some or all of the member variables are uninitialized.

    These are two concrete examples from the project. The general case is "promoting/demoting at the 'wrong' stage runs behavior whose underpinnings are not constructed or already destructed". For instance: Hooking a display object into a display list that's interpreted by a periodic process running in another thread. If it's time to display while the object is under construction or destruction, and the promotion/demotion timing was "wrong", the display processing manger invokes services whose infrastructure are not yet constructed or already destructed.

    With "correct" timing of promotion/demotion you can have an object that is always consistent, even if only partially formed. (Constructors and destructors, for instance, can have "stage of construction" member variable(s) that modulate(s) the behavior of other member functions depending on whether their underpinnings are ready, and this can be initialized to "nothing ready" before the object is promoted a

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  87. Re: "heck even lisp" by t2t10 · · Score: 1

    Common Lisp declarations for type and optimization are part of the ANSI standard, and generally do the same thing across different compilers.

    I was a CommonLisp user for many years and that's not true. CommonLisp had a lot of potential, but it never quite got it right.

  88. Re:c++ 1x sucks by afabbro · · Score: 1

    Confusing - every mainstream language today except Java has them.

    And even Java will soon. http://www.javac.info/.

    --
    Advice: on VPS providers
  89. Re:Calls to virt funcs during member con/destructi by Hythlodaeus · · Score: 1

    In the garbage collection case, either
    1. The parent should not have been hooked to garbage collection before its members were contstructed
    or
    2. Garbage collection should be suppressed during a constructor

    In the exception case, a constructor that is going to throw has the responsibility of cleaning up its members before it throws. When a constructor throws, the destructor is not run. If a constructor fails and exceptions aren't available, it should still clean up its members and set a flag to let the destructor know not to do anything.

    --
    For great justice.
  90. Re:Calls to virt funcs during member con/destructi by Ungrounded+Lightning · · Score: 1

    In the garbage collection case, either
    1. The parent should not have been hooked to garbage collection before its members were contstructed

    That gives you the class-hierarchy doubling I described earlier. The "be collectible" flag has to be cleared by the final level of class derivation, which can not have further classes derived from it. This breaks the class paradigm by requiring you to distinguish leaf classes that can exist from their immediate all-but-collectible precursors which can be further modified.

    or
    2. Garbage collection should be suppressed during a constructor

    Out of memory. Crash! Also all the leaf/stem problems if 1.

    They both break the class paradigm another way: The garbage collectible behavior is supposed to be INHERITABLE. So it should all be encapsulated in the base class. Why are you forcing it to be moved to a derived level which has NOTHING TO DO with this behavior, just to work around an issue with the compiler's code generator?

    In the exception case, a constructor that is going to throw has the responsibility of cleaning up its members before it throws. When a constructor throws, the destructor is not run. If a constructor fails and exceptions aren't available, it should still clean up its members and set a flag to let the destructor know not to do anything.

    The problem is not the constructor throwing. Constructors know what they're constructing and can handle it.

    The problem is a member constructor throwing. Does it have to understand everything that might contain it (including things that were written years later by a different team)? How can it do that? How can it do that without breaking the entire point of the encapsulation information-hiding paradigm?

    What happens if something called by something called by something ... called by a member constructor throws. Now everything that throws has to understand how to unwind every layer between it and the object that catches.

    If the promotion of the object occurs in the way I described as "correct" it's trivial to solve both these problems - and others - through the activation of the appropriate levels of the virtual member functions. If it happens otherwise they aren't readily soluble - and either aren't solved at all or aren't solved in a practical way by your suggestions.

    --
    Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  91. Re:c++ 1x sucks by AuMatar · · Score: 1

    Functors are a complete hack and should never be used. If you find yourself ever wanting to use functors or lambdas- you're doing it wrong.

    Yes, that means the entire part of the STL dealing with generic functions is doing it wrong. They're unmaintainable code. THe correct way to do it is to write the entire loop as a separate function, or to embed it as a standard while/for/do loop. Templates should only be used for container classes.

    The correct way to write your code is

    iter=xs.begin();
    while(iter != xs.end()){
          if(*iter>= x1 && *iter = x2)
                  break;
    }

    Perfectly readable, no thought needed. Your way is confusing, overly complex, and utterly unscalable to anything beyond a one liner, it should never be used and would fail any code review I was on. In 10 years of doing professional C++, I've never seen anyone actually want to use generic functions, you are literally the only person I've ever talked to outside of academia who liked them.

    --
    I still have more fans than freaks. WTF is wrong with you people?
  92. Re:c++ 1x sucks by shutdown+-p+now · · Score: 1

    I see - you're one of those guys who, back in 60s, insisted that structured programming is a confusing idea that came out of academia and is therefore worthless for real-world programming, and that GOTO is perfectly readable. I'm not going to try to convince you otherwise - if you fail to see the obvious clues that things have moved on since hard-coded loops, it's your own problem.

  93. Re:c++ 1x sucks by AuMatar · · Score: 1

    Keep telling yourself that. In reality- nobody writing C++ uses functors. Nobody uses the boost lambda. ANd nobody wants to start, on either. It just isn't a readable method of programming.

    --
    I still have more fans than freaks. WTF is wrong with you people?