Slashdot Mirror


Interview Update With Bjarne Stroustrup On C++0x

An anonymous reader writes "DevX interviewed Bjarne Stroustrup about C++0x, the new C++ standard that is due in 2009. Bjarne Stroustrup has classified the new features into three categories: Concurrency, Libraries and Language. The changes introduced in Concurrency makes C++ more standardized and easy to use on multi-core processors. It is good to see that some of the commonly used libraries are becoming standard (eg: unordered_maps and regex)."

470 of 589 comments (clear)

  1. Nice name, chief. by snarfies · · Score: 4, Funny

    I saw the headline and thought I was seeing some 1337 form of "cox."

    huhuhuuhuhuh he said "form."

    1. Re:Nice name, chief. by ozmanjusri · · Score: 2, Funny
      I saw the headline and thought I was seeing some 1337 form of "cox."

      Nah, Stroustrup just decided to save time, so he's included the first buffer overflow in the language's name.

      --
      "I've got more toys than Teruhisa Kitahara."
    2. Re:Nice name, chief. by mikiN · · Score: 1

      Actually, I'm feeling very disappointed by the new name. All previous incarnations of the language had a name that was a valid expression (and thus a C statement) parseable by even its oldest incarnation, thus stressing backwards compatibility. This incarnation's name parses to a fsckin' syntax error! Why add an unterminated hex constant (let alone fail to add parentheses and drop the redundant unary plus)? What was wrong with the ol' post-increment?
      With just slightly more creativity they could've come up with a better name than this.
      What deplorable state the world of programming has gotten to...

      --
      The Hacker's Guide To The Kernel: Don't panic()!
    3. Re:Nice name, chief. by mikiN · · Score: 1

      s/and drop/or drop/

      --
      The Hacker's Guide To The Kernel: Don't panic()!
  2. Interesting suffix by GroeFaZ · · Score: 1

    will it be applied to C as well?

    --
    The grass is always greener on the other side of the light cone.
    1. Re:Interesting suffix by xenocide2 · · Score: 3, Informative

      Yes. It's already been done once, aka C99. This isn't the thing that will replace C++, it's the next revision of the language, with multithreading support etc. Once C++ has worked out the hard stuff, C will have it's own next revision based on that.

      Once everything's finished, it should be finalized as C++09. It may carry on another year, in which case you might call it "C++0xa" ;)

      --
      I Browse at +4 Flamebait

      Open Source Sysadmin

    2. Re:Interesting suffix by Anonymous Coward · · Score: 1, Insightful

      Haha, disregard that, I suck C0x!

  3. Objective C and C++ by Midnight+Thunder · · Score: 3, Interesting

    If anyone has used both Objective-C and current C++, can anyone tell me whether the new specification is a clear improvement on either if these?

    --
    Jumpstart the tartan drive.
    1. Re:Objective C and C++ by thermian · · Score: 4, Interesting

      No, not really.

      In fact C++ is barely managing to hold its own any more against C# and Java.

      It's not that C++ isn't good, its just that its harder to do things in it then it is to do those same things in either C# or Java. Harder to do means more expensive, and businesses all over are having to tighten their purse strings.

      I keep finding that for fast number crunching apps, C beats C++, and for less intensive work its usually easier to use Java or C#, or indeed python, then it is to use C++.

      Also, its certainly true to say that in the UK C++ is not anywhere near as useful in terms of getting yourself a job as it used to be.

      --
      A learning experience is one of those things that say, 'You know that thing you just did? Don't do that.' - D. Adams
    2. Re:Objective C and C++ by Free+the+Cowards · · Score: 4, Informative

      Objective-C is essentially unrelated to C++ in every way. C++0x does not change this fact at all. Comparing the two makes just slightly more sense than comparing C++ and Prolog.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    3. Re:Objective C and C++ by Ed+Avis · · Score: 1

      What exactly are the advantages of C over C++? Assuming a programmer with good taste.

      --
      -- Ed Avis ed@membled.com
    4. Re:Objective C and C++ by ardor · · Score: 1

      Well, if you use generic programming properly, you can in fact beat C with C++. Expression templates are an example.

      --
      This sig does not contain any SCO code.
    5. Re:Objective C and C++ by larry+bagina · · Score: 2, Interesting

      Objective C is C with a dynamic/runtime-based OO on top. C++ is C with a static/compile-time based OO on top. Plus lots of other syntactic sugar (operater overloading, references, templates, namespaces, etc). And did I mention that Bjarne Stroustrup hates the C language? Not surprisingly, there's a lot more syntactic sugar in the new standard. I hope you don't have diabetes!

      --
      Do you even lift?

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

    6. Re:Objective C and C++ by thermian · · Score: 1

      With C you can write blisteringly fast code, because it lets you do anything you want.

      Of course that has its downside, because it 'lets you do anything you want', regardless of whether what you're doing is batshit insane or not.

      It is, to be blunt, a bit of a barstard to use.

      I've been using it for years, and its a real love/hate thing. I love the speed I can get using it, but getting from blank file to a finished application is harder work in C then in any other language I've encountered, except possibly Poplog.

      --
      A learning experience is one of those things that say, 'You know that thing you just did? Don't do that.' - D. Adams
    7. Re:Objective C and C++ by lubricated · · Score: 1

      Technically there isn't any, c is a subset of c++ so anything you can do in c you can do in c++.

      In my experience with number crunching applications. C++ coded very in the style of straustrop(sp?) with good maintainability with iterators templates and stuff like that runs slower than C code. Since both do the same number of floating point ops, my gut feeling is that this has to do with memory usage. The C++ number crunching programs I work with are limited by how fast they can access the data in RAM and not how many flops the processor can push. With good C++ coding practices you have fast very maintainable code. With good C practices you have very fast maintainable code.

      --
      It has been statistically shown that helmets increase the risk of head injury.
    8. Re:Objective C and C++ by gbjbaanb · · Score: 1

      Agreed just STL, functors will make your life incredibly easy once you grok them.

      Thing is, to say that C++ is no good because other languages are easier suggests that everyone should be a VB programmer.

      There are different tools for different jobs, to standardise on one because its the latest cool thing is short-sighted and naive.

    9. Re:Objective C and C++ by TomorrowPlusX · · Score: 3, Funny

      If you're writing C++, the spec is an improvement. If you're writing Objective-C, you probably don't care because you've already got a great language.

      Also, you'll gnash your teeth because god knows how long it will take for apple to provide a compiler toolchain ( gcc? llvm? clang? ) which supports the new features.

      --

      lorem ipsum, dolor sit amet
    10. Re:Objective C and C++ by bill_kress · · Score: 2, Insightful

      The more I look at it, Java's Just in time compiler is just about as fast as C++.

      The biggest difference tends to be how you program.

      When you really learn to program OO, you tend to create many small objects that outlive the object that created them.

      In C++, that would mean running thousands of mallocs a second, and having some other random (arbitrary) object delete them later.

      That's not the way to code C++. Since you are constantly required to think of object lifetime, you usually have an object die with the method that created it. When you are doing that, you can put it on the stack instead of allocating it on the heap. Stack allocations tend to be much cheaper because there is no deallocation.

      But if you actually coded C++ OO, not caring where objects were destroyed, keeping many more small objects around, etc, your performance would be as bad as Java or worse.

      For something that doesn't allocate at all--well a simple test was just created on Cedric's weblog that compared a good algorithm in different languages and C++ couldn't match Java's performance until it was compiled with -O3.

      For java, apps just keep getting aster (even for programs that have already been deployed). To increase the speed of a deployed C++ program, you need new hardware.

      A VM system CAN BE superior to a compiled one in every way since it can be compiled to exactly the same (or much better) assembly code if the VM determines that would be best. Not sure why this whole speed thing keeps coming up. When I see a Java program written to avoid memory allocation, it tends to perform almost exactly like it's C++ counterpart.

    11. Re:Objective C and C++ by maxchaote · · Score: 2, Informative

      The success of C has been largely due to the fact that it makes one basic assumption that no other language aside from Assembler ever made: The programmer is always right. Modern C++ is getting further and further from its origins as an alternative precompiler to C. Valid C code is no longer valid C++ code as it once was. I think most C programmers would welcome a few additions to or improvements on the language such as objects and additional memory allocators, but once you start telling a C programmer "No, you can't pass that value in there" or placing restrictions on the programmer you wind up limiting their freedom to code effectively and you get away from the purpose of a compiler, which is to make programming easier. Yes, strongly-typed languages prevent mistakes from getting into the code, but the purpose of a compiler is not to prevent mistakes: that's the programmer's responsibility. I've stopped coding in C++: I'm going back to C. Of course, Objective C is looking more and more appealing, since it's been a part of gcc for a few years...

    12. Re:Objective C and C++ by cduffy · · Score: 4, Insightful

      Generally speaking, I agree with your post. However...

      Technically there isn't any, c is a subset of c++ so anything you can do in c you can do in c++.

      That's a really, really awful way to think about C.

      C has a completely different set of best practices and design principals; anyone who puts "C/C++" on a resume I'm reviewing loses points as opposed to listing them separately.

    13. Re:Objective C and C++ by againjj · · Score: 1

      Objective-C is essentially unrelated to C++ in every way. C++0x does not change this fact at all. Comparing the two makes just slightly more sense than comparing C++ and Prolog.

      Actually, it makes more than "just slightly more sense". C++ is an imperative OO language based on C, as is Objective-C, while Prolog is a declarative logic programming language based on formal logic. Objective-C and C++ intersect roughly at the C language, but they don't intersect with Prolog at all. That said, the question does betray an ignorance of Objective-C and C++ being two completely separate extensions of C.

    14. Re:Objective C and C++ by Free+the+Cowards · · Score: 1

      I'd argue that it's still very slight. C++ as commonly used and even more as commonly discussed here on Slashdot tries to avoid C as much as possible. And the non-C bits of C++ are about as different from Objective-C as you can get. It's true that they still share C (mostly), but most of the time this fact doesn't change very much.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    15. Re:Objective C and C++ by mdarksbane · · Score: 2, Informative

      I still haven't seen anything matching it for real time stuff. Not that I wouldn't mind, at all.

      But writing I don't think I've seen OpenGL code in another language that wasn't incredibly slow. Maybe that's just momentum, but regardless, it's still the state of things.

    16. Re:Objective C and C++ by Quetzo · · Score: 1

      I could not agree with you more, especially on the going back to C bit.

      After 6+ years in C++, I have realized that C is *just right* for certain libraries.

      I have not stopped coding C++, but I am slowly moving to C on the lower level performance critical portions of my libararies.

    17. Re:Objective C and C++ by Narishma · · Score: 1

      And if you use those same best practices and design principles in C++ it will still work the same. So really C is a subset of C++.

      --
      Mada mada dane.
    18. Re:Objective C and C++ by Free+the+Cowards · · Score: 2, Informative

      Not to mention that C is not a subset of C++. The differences are minor and mostly subtle but they are there and they matter. For example, this trivial bit of very typical C code will not compile in a conforming C++ compiler:

      char *x = malloc(10);

      I'd suggest asking your "C/C++" interviewees to produce some code that's legal C but not legal C++. It will at the very least be amusing to watch them squirm.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    19. Re:Objective C and C++ by Midnight+Thunder · · Score: 1

      Also, you'll gnash your teeth because god knows how long it will take for apple to provide a compiler toolchain ( gcc? llvm? clang? ) which supports the new features.

      Actually this probably depends more on the open source community. Apple will probably simply merge in support when they are ready.

      --
      Jumpstart the tartan drive.
    20. Re:Objective C and C++ by immcintosh · · Score: 3, Insightful

      No, not really.

      Nothing else in your post either supports, or even directly addresses this assertion.

      It's not that C++ isn't good, its just that its harder to do things in it then it is to do those same things in either C# or Java. Harder to do means more expensive, and businesses all over are having to tighten their purse strings.

      This is the same bullshit that's trotted out there every time this topic comes up, and it's no more true now than it ever was, which is not at all. If you do a little looking around, you'll find very elegant libraries that support every single feature you'll see in ANY other imperative language, and MANY declarative language features to boot. If you're against code reuse and third party libraries on some sort of general principle, then you're kinda missing the whole point of C++.

      I'll be blunt, maybe an ass, maybe a troll, but having used all three of those languages extensively, I can say with almost absolute certainty that the only reason you should be having so much more trouble doing things in C++ (ESPECIALLY as compared to those two languages) is that you're either a very poor C++ programmer or have a pathological aversion to third party libraries.

      In fact C++ is barely managing to hold its own any more against C# and Java.

      Another thing that's been very much in the vogue to say lately, but I just haven't seen any meaningful evidence for. I think Bjarne covered this topic fairly even-handedly in TFA, and if he's to be believed then C++ usage is not suffering like popular belief seems to indicate. The crux of it being that web scripting was never a strong domain of C++ in the first place, and in actual applications programming C++ is still the leader of the pack.

    21. Re:Objective C and C++ by immcintosh · · Score: 1

      To give you a straightforward answer, first off, Objective-C and C++ really are two very different languages. The new specification is of C++, and has no effect or relation with respect to Objective-C.

      With that out of the way, I for one feel that the new spec is a VERY clear improvement over the current C++ spec on a number of fronts. Not to be rude, but if you RTFA it really does go over them point by point. I for one am going to enjoy the "auto" keyword greatly. Rvalue references will eliminate a lot of annoyance in having to do the same repetitive optimization workarounds. And just in general the syntax is going to get a lot cleaner. So the answer, in short, is yes, it is a clear improvement, and one that I'm looking forward to.

    22. Re:Objective C and C++ by Poltras · · Score: 1

      C++ often occurs imperceptible code (for example, constructors, destructors, temporary variables, copy-ctor, ...) that can slow the final product. This can be circumvented, but in most case is not because the programmer is not experienced enough.

      The case is, although I prefer C++ as a language, I'm well aware that people needs a hell of a lot more experience in C++ than in C to write code that is both faster and easier to maintain. Also, if readability by none-expert is an issue, C is always easier to understand. If you have a team of talented C++ developer, it's going to be 99.5% as fast as C, and will take less time to maintain and code new features. The level of expertise of such a team is an order of magnitude more than the same results in C, though.

    23. Re:Objective C and C++ by bill_kress · · Score: 1

      How about assembly? Hand code that and you can beat the PANTS off C, probably a few times better performance unless you really know how to tweak your C code.

      Yeah, if you are not programming OO, C is still going to be pretty hard to beat, but I don't think that includes C++. There is a Realtime Java now, not sure how it compares in speed to C, but I don't doubt it'll be pretty close to C++.

    24. Re:Objective C and C++ by petermgreen · · Score: 1

      The difference as I see it is what the language makes easy for you to do and what the language makes difficult for you to do. If the easy operations are also the ones that perform well you will get code that performs well.

      Java encourages you to make lots of short lived objects. Since java has no concept of reference parameters or structures returning more than one primitive from a function requires you to use a object on the heap (or use static fields but that opens up it's own can of worms most notablly thread safety). Using a persistant object is one soloution but it also complicates the code a lot so generally people make throwaway objects.

      In C and C++ on the other hand you can just return that data through pointers or references to either individual objects on the stack or pointers to objects on the stack whereas creating short lived heap objects is a pain.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    25. Re:Objective C and C++ by smellotron · · Score: 1

      Name something you can do in C that you can't in C++.

    26. Re:Objective C and C++ by smellotron · · Score: 1

      You're doing it wrong. I think what you mean is, "For most developers, it's harder to write well-performing C++ than it is to write well-performing Java."

    27. Re:Objective C and C++ by Alpha830RulZ · · Score: 1

      and in actual applications programming C++ is still the leader of the pack.

      But in terms of what people are doing, how much of that these days is applications programming, in the sense that you are using the term?

      I think that the weight of development these days has moved away from things that are delivered in setup.exe's.

      --
      I was taught to respect my elders. The trouble is, it's getting harder and harder to find some.
    28. Re:Objective C and C++ by StackedCrooked · · Score: 1

      In fact C++ is barely managing to hold its own any more against C# and Java.

      I make desktop applications for both Windows and Mac. C# and Java are not very suitable for this. C++ is still the standard choice.

    29. Re:Objective C and C++ by mgiuca · · Score: 1

      Well if it's an improvement on any of them, judging from the name, it'll be C++ ... er, right?

      </confused>

    30. Re:Objective C and C++ by Kent+Recal · · Score: 1

      Preserve your sanity.

    31. Re:Objective C and C++ by smellotron · · Score: 1

      Touche'.

    32. Re:Objective C and C++ by immcintosh · · Score: 1

      I can only speak from personal experience, which gives me good cause to disagree strongly with your claim. Perhaps much of what you use are web apps, I can't speak to that. In my usage, however, an absolutely overwhelming majority of the software I use is, as you put it, the sort of thing you'd find in a setup.exe. That goes for both home usage and what I use at the large company I work for (we have a web portal, but everything substantive still goes on in native applications).

      I'll admit that the "buzz" certainly has moved away from traditional application development, but fads are what fads are. I've never really thought this whole Web 2.0, everything in a "cloud" business C++ is long past its popular fad phase.

      That's all anecdotal though, so maybe the "average" mileage is different.

    33. Re:Objective C and C++ by Alpha830RulZ · · Score: 1

      I'm just measuring by the job postings I see. The majority of the positions I see are for functionality that is delivered via a server through a browser or a device. Those apps are mostly delivered through PHP/Ruby/Python/Java+X/.Net. While I agree that there is still a bunch of core application development out there, my point is just that I think that is a minority of the function points being delivered now.

      --
      I was taught to respect my elders. The trouble is, it's getting harder and harder to find some.
    34. Re:Objective C and C++ by bill_kress · · Score: 1

      Java uses a methodology that makes heap allocations perform more like stack allocations.

      Also, creating many small objects helps with code maintainability and reuse, significantly. (that's what OO programming is when done correctly)

      As you said, C++ discourages that.

      So to combine and rephrase what we have said, C++ has this design flaw that makes good OO code difficult to write and slow, Java has corrected that for the most part by simplifying and speeding up areas C++ is not good at that are required for good OO code.

    35. Re:Objective C and C++ by immcintosh · · Score: 1

      A quick search of dice.com reveals 23,169 jobs for PHP, Ruby, Python, Java, and C# combined (using a search returning any of those keywords). It reveals 7,926 for C++ alone. I'm not so worried for C++ ;)

    36. Re:Objective C and C++ by speedtux · · Score: 1

      With C you can write blisteringly fast code, because it lets you do anything you want.

      Actually, the fact that you can do whatever you want in C is what prevents it from being blisteringly fast: compilers simply cannot infer aliasing relationships correctly.

  4. Re:It hurts you to learn C++ is still being used. by mangu · · Score: 2, Insightful

    You can't figure out why

    Try writing a large program that needs to do heavy number-crunching in Java/Ruby/Perl/Python, or whatever is your preferred language.

  5. On of the features: by Daimanta · · Score: 4, Funny

    "control of alignment"

    I'd like chaotic good please

    --
    Knowledge is power. Knowledge shared is power lost.
    1. Re:On of the features: by meringuoid · · Score: 5, Funny
      I'd like chaotic good please

      I hate to be the one to break the news, but C++ isn't the only thing that's been revised recently...

      --
      Real Daleks don't climb stairs - they level the building.
    2. Re:On of the features: by Anonymous Coward · · Score: 1, Insightful

      Hopefully C++'s revision is better than the crapfest that is "D&D" 4.0.

    3. Re:On of the features: by mr_mischief · · Score: 1

      Hopefully C++'s revision is better than the crapfest that is "D&D" > 2.0.

      FTFY.

    4. Re:On of the features: by smellotron · · Score: 1

      Hopefully C++'s revision is better than the crapfest that is anything more complex than sticks and dirt.

      FTFY :)

    5. Re:On of the features: by ginbot462 · · Score: 1

      Only on slashdot will a discussion of C++ turn into a discussion of D&D. It's like a auxiliary to Godwin's or something.

      --
      Atlas Shrugged : Thematic Story :: Battlefield Earth : Organized Religion
  6. I can. by bigtallmofo · · Score: 4, Funny

    Yes.

    --
    I'm a big tall mofo.
  7. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 4, Insightful

    Been there, done that.

    Most of the time, the potentially reduced running time of the C++ implementation never comes close to the months saved in development.

    And when it does, it's trivial to go in and write the speed-sensitive portions of the program in a faster language.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  8. Garbage Collection? No? BAH! by WolverineOfLove · · Score: 2, Informative

    I want to like C++, heck, it was the first language I learned. But after so many hours of memory leaks and pointer-induced errors... My friend had mentioned at one point there was going to be transparent garbage collection in the C++0x standard. Unfortunately... looks like it's tabled for now: http://en.wikipedia.org/wiki/C%2B%2B0x#Transparent_garbage_collection Oh well.

    1. Re:Garbage Collection? No? BAH! by luzr · · Score: 2

      But after so many hours of memory leaks and pointer-induced errors...

      Memory leaks? In C++?! Well, if you are still managing the memory using new/delete, then you perhaps deserve it. Modern C++ code should not contain more than one delete statement per 10000 lines. If you have more, you should learn the language first.

    2. Re:Garbage Collection? No? BAH! by gbjbaanb · · Score: 2, Insightful

      I want to like C++, heck, it was the first language I learned. But after so many hours of memory leaks and pointer-induced errors...

      perhaps you didn't learn it very well. Check out RAII for one way round your problem, learn about references and destructors for another, and learn about auto_ptr/shared_ptr if you still have difficulties.

      If you absolutely must have a GC, put one in. Mono uses this one, so I assume they think its quite good. Stroustrup says that GC has a place in memory management, but it should be the last resort not the first. I agree - if you can't program without getting so lost you lose memory all over the place, GC will not magically help you* as you'll end up losing track of other non-memory resources instead**.

      * - unless you're an ex-VB programmer, in which case you need all the help you can get :-)

      ** - eg. you create an object that opens a file, if you 'leak' that object, the GC will collect it for you when it feels like it, so you may end up trying to reopen that file only to find that its still in use. There's still 'soft leaks' that the GC will not manage where your objects are still referenced even though you think they aren't.

    3. Re:Garbage Collection? No? BAH! by CyberKrb · · Score: 4, Informative

      You surely are a careless coder, then. C/C++'s memory/pointer-related problems are due to careless/clueless programmers, not due to the language itself. You clearly fail to understand the language, yet pretend to answer with authority. Do you use (or even know) the RAII idiom? that smart pointers have been there for years? Yes, I mean auto_ptr and shared_ptr. How about the Boost library (which is being included partly in C++0x). Garbage Collectors are non-deterministic by nature; Therefore, they are a real no-no for real projects (think real-time systems or massive number crunching, where memory pools are common).

    4. Re:Garbage Collection? No? BAH! by master_p · · Score: 1

      You surely are a careless coder, then.

      And you surely don't seem like a person who's had to code a complex C++ app in mimimum time, then.

      C/C++'s memory/pointer-related problems are due to careless/clueless programmers, not due to the language itself.

      The language does everything to undermine the programmer in this respect. It's not helpful at all. Of course, all errors are human errors, but there is a limit at which programming languages are not longer convenient.

      You clearly fail to understand the language, yet pretend to answer with authority.

      If you were ever called to program a complex project in C++ (complex in the sense of complex relationships between objects), you will see that there is a lot of merit to what the guy said.

      Do you use (or even know) the RAII idiom?

      RAII is tremendously good in dealing with resources other than memory. Complex object relationships are difficult to manage with RAII.

      that smart pointers have been there for years?

      No, they haven't. They are not yet part of the standard; smart pointers will be available in the next standard revision. Which means that in order to make a source-level cross platform app for all major compilers, all major compilers should provide those smart pointers.

      Smart pointers also have great technical challenges hidden in them. I will explain below.

      Yes, I mean auto_ptr

      Auto_ptr is a complete disaster, because it requires the programmer to track who's got the ownership of the resource, which is a highly difficult job, the difficulty of rises exponentially with each additional statement.

      and shared_ptr.

      Some technical problems that one should be aware of when using smart pointers:

      1. you should never pass 'this' to a shared_ptr. Your object will be deleted.
      2. the above is a big issue, because it forces a style of programming that is not object-oriented: for every job that a shared_ptr is required, it must be done outside of an object by another object. This complicates programming a lot.
      3. If you forgot that you have a shared_ptr somewhere and then you instantiate another shared_ptr from a raw ptr, then there will be two reference counts for this object, the object will be deleted when the second shared_ptr goes out of scope, leaving the first shared_ptr with dangling references.
      4. it's very easy to introduce a memory leak, using shared_ptrs (i.e. circular dependencies), especially through sub-classing: a base class might not have a circle, but a derived class might do so. And it's a very difficult problem to track.

      How about the Boost library (which is being included partly in C++0x).

      Yesterday I had to code my own smart pointer classes: a shared_ptr class used for lifetime management, a weak_ptr class for using weak references, and a strong_ptr class for using weak_ptrs. Boost's design is wrong: you shouldn't have to instantiate a shared_ptr in order to use a weak_ptr, because in some cases the object is not shared yet (for example, when constructing an object). The best solution is to use a strong_ptr to pin down the object that a weak_ptr contains.

      Garbage Collectors are non-deterministic by nature; Therefore, they are a real no-no for real projects (think real-time systems or massive number crunching, where memory pools are common)

      Garbage collection is not a panacea, but it's certainly way more useful than the set of auto_ptr, shared_ptr, weak_ptr and intrusive_ptr that boost or C++ proposes. And there is nothing that does not allow you from using memory pools and garbage collection.

    5. Re:Garbage Collection? No? BAH! by speedtux · · Score: 1

      I agree - if you can't program without getting so lost you lose memory all over the place, GC will not magically help you

      The purpose of GC is not to make memory management easier, it is to make software safe. Since hell will freeze over before C++ will be a safe language, one might as well not bother with GC in it at all.

      Stroustrup says that GC has a place in memory management, but it should be the last resort not the first.

      Stroustrup is an idiot.

    6. Re:Garbage Collection? No? BAH! by speedtux · · Score: 1

      Yes, I mean auto_ptr and shared_ptr.

      shared_ptr is horrendously inefficient compared to garbage collection.

      Garbage Collectors are non-deterministic by nature; Therefore, they are a real no-no for real projects (think real-time systems or massive number crunching,

      And you think that shared_ptr is "deterministic"? A shared_ptr going out of scope can cause arbitrary delays. Heck, a simple "delete p" can cause arbitrary delays.

      If you want efficient, predictable memory management, garbage collection is the only way to go.

      where memory pools are common).

      Memory pools have been used in garbage collected languages since long before C++ even existed.

  9. Re:It hurts you to learn C++ is still being used. by Tenrosei · · Score: 1

    Most/All NDS games are Written in C++. C++ is a great language because it allows you to do so many things and still run fast. BTW i love this quote from Bjarne: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows your whole leg off." -Bjarne Stroustrup

  10. Ha! Yeah right. by bigtallmofo · · Score: 3, Funny

    Try writing a large program that needs to do heavy number-crunching in Java/Ruby/Perl/Python

    Those languages are way too high level. What you make up in development time will nowhere near compensate you for the greater processing time. I mean, CPU costs are through the roof these days!

    But I have to say - even C++ is too high level. I hand code assembler with vi. That's what real number crunchers do.

    --
    I'm a big tall mofo.
  11. LOL C++0x0Rz by jeffb+(2.718) · · Score: 5, Funny

    ...or, as a former manager explained it, "When C++ is your hammer, everything looks like a thumb."

    1. Re:LOL C++0x0Rz by Xeth · · Score: 5, Funny

      No, no. It's "C gives you enough rope to hang yourself. C++ gives you enough rope to hang yourself and every programmer who comes after you"

      --
      If your theory is different from practice, then your theory is wrong.
    2. Re:LOL C++0x0Rz by fermion · · Score: 2, Insightful
      I have written code in low level languages, and written code in high level languages, and find the issue is skill and discipline. To be specific, when on does not know who to use a hammer, then everything does look like a thumb. OTOH, when one codes in Java, everything looks like a condominium. When one codes in C# everything looks like an office park. One advantage of C++ is that it allows some enforcement of rules, but allows the skilled coder to relax those rules when some justified. Again, it requires someone with skill to know the difference.

      An interesting thing is I have written some highly structured code in some rather low level languages. To do so required a skilled architect and an agreement between developers that we were going to honor the rules, even if the complier did not punish us. It can be an expensive way to develop, as competent computer people costs money, which is why it is often more economical to allow the complier to do the thinking.

      --
      "She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
    3. Re:LOL C++0x0Rz by ghmh · · Score: 1

      No++. It's "C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot."

    4. Re:LOL C++0x0Rz by JoCat · · Score: 3, Funny

      "C lets you shoot yourself in the foot. C++ lets you reuse the bullet."

    5. Re:LOL C++0x0Rz by Kent+Recal · · Score: 1

      ..and when one uses python then everything suddenly starts to make sense.

      SCNR

  12. C#++? by WED+Fan · · Score: 2, Funny

    So we are going to create the unmanaged form of C#?

    --
    Politics is the art of looking for trouble, finding it everywhere, diagnosing it incorrectly and applying the wrong fix.
    1. Re:C#++? by Noodles · · Score: 4, Insightful

      Because performance is important to some people.

    2. Re:C#++? by WED+Fan · · Score: 1

      Boy, you missed it.

      In the section where the interviewer tries to get him to compare with other languages, he says he prefers not to. But, some of the changes being considered look like a melding of ideas from Java and C# to name a few.

      The question is, why go that far?

      Tackle some of the changes in technology, but by and large, leave the language alone. It is good as it stands.

      --
      Politics is the art of looking for trouble, finding it everywhere, diagnosing it incorrectly and applying the wrong fix.
    3. Re:C#++? by neokushan · · Score: 4, Insightful

      If it was as good as it stands, then newer languages such as C# wouldn't take off.
      Don't get me wrong, I love C++ and it's my primary programming language, but to say it's perfect as it is, is just silly.

      --
      +1 IDisagreeSoHeMustBeATrollOrAnAstroturferOrAShill
    4. Re:C#++? by drxenos · · Score: 5, Informative

      No it's not. The standard does not define concurrency issues. Not how to spawn threads and create mutexes, but lower-level issues, like coherency. This is sorely needed for truly portable code. Rvalue references will help a lot with the creation of temporaries that are just copied and destroyed. You see this now in all the specializations in the libraries for the swap function. With rvalue references, you can write a single template that will be optimal for all types. Currently template error messages are a mess. several lines of unreadable garbage because your type doesn't supply a member or operator that the template needs. Concepts will lead to concise, easy to understand error messages. typedecl and the new use for the auto keyword will reduce verbosity, and stop the nightmare that is figuring out the type of a complex template (i.e., when using Spirit, et. al.). Lambdas and closures will simplify using the STL algorithms without having to create a lot of functors. REH

      --


      Anonymous Cowards suck.
    5. Re:C#++? by Austerity+Empowers · · Score: 2, Insightful

      The day when McDonalds can get away with requiring MS CS, MS EE, AND get an abundance of qualified applicants for fry cook positions is rapidly approaching.

      Goodbye helloworld.c, hello wantfrieswiththat.cxx

    6. Re:C#++? by Anonymous+Cowpat · · Score: 1

      Hi there.
      We use Fortran, and can speak for ourselves.
      Thanks.

      --
      FGD 135
    7. Re:C#++? by Duhavid · · Score: 3, Insightful

      "MBA's will not need programmers anymore, so we'll be able to code OSS full time!"

      You realize that is what they said when they introduced COBOL, right?

      --
      emt 377 emt 4
    8. Re:C#++? by johanatan · · Score: 3, Interesting

      Why does everyone think that 'simplifying the usage of STL algorithms without creating a lot of functors' is the only use for lambdas and closures? What about making your own code tighter by factoring symmetric blocks into one?

    9. Re:C#++? by Haeleth · · Score: 2, Insightful

      Why does everyone think that 'simplifying the usage of STL algorithms without creating a lot of functors' is the only use for lambdas and closures?

      It's not that people think that's the only use for them; it's that that's the killer use.

      It's a lot easier to persuade people to learn a new feature by saying "this will make your life easier" than by saying "this will let you write better code". Most people don't care how "tight" their code is, as long as it works. What they care about is how easy it is to write and maintain.

    10. Re:C#++? by drxenos · · Score: 1

      Why does everyone make baseless assumptions about "everyone." I was just citing examples, not writing a book. Where did I say "only use for lambdas is X"? List every use of a language feature is not possible, especially in a forum like Slashdot.

      --


      Anonymous Cowards suck.
    11. Re:C#++? by RHSC · · Score: 2, Funny

      WRITE(*,*)"It doesn't get any better than this"

    12. Re:C#++? by Creepy · · Score: 1

      The question is, why go that far?

      yeah - why bother when Microsoft will just deprecate it and replace it with proprietary underbar functions anyway?

    13. Re:C#++? by Yetihehe · · Score: 5, Insightful

      If you make language even an idiot can use, idiots will be using it. Like with VB.

      --
      Extreme Programming - Redundant Array of Inexpensive Developers
    14. Re:C#++? by kdemetter · · Score: 1

      It depends on what you use it for .

      C++ is used for low level programming , C# is high level programming.

      You want to create an application that uses forms to do some business processing , and send it to database , use C# . You want an application that has to calculate prime numbers , or some other heavy mathematical issue , use C++.

      Both have their uses , and it's fine that way. Offcourse , that doesn't mean C++ can't be improved.

    15. Re:C#++? by neokushan · · Score: 2, Insightful

      Well that's just it, C++ is designed to be as general a language as you can manage (which is why so many people don't "get" it or complain that it's complicated because not much is done for you in comparison to other languages) which is why other languages may be better suited to certain tasks.
      The example you gave for C# is a pretty good one, but it still highlights that there are areas where C++ isn't well suited to certain tasks and until it is, it's fair to say there's room for improvement.
      Thus I welcome any improvements to the language, especially as Bjarne certainly seems to know what he's doing.

      --
      +1 IDisagreeSoHeMustBeATrollOrAnAstroturferOrAShill
    16. Re:C#++? by johanatan · · Score: 1

      'Tight' code is easier to maintain. It requires less effort to read and after all, there's only going to be one writer of your code and n readers. And, after having used lambdas and closures in other languages (some of which are purely functional), I have a little bit different sense of what is 'killer' apparently. Yes, STL is awesome. And, using it more concisely is more awesome, but it's the code that I personally write on top of it where I can express elegant simplicity.

    17. Re:C#++? by johanatan · · Score: 1

      No, it's just that you're not the first person I've heard saying that. Our STL guru at MS repeats the same mantra and so I assume that it must have come from on high (i.e., the committee or Bjarn himself) in that form. I would personally like to see people writing their own code more succinctly as much as (or even more than) using the STL more concisely, but encouraging that might be equivalent to encouraging functional programming in general--something which hasn't caught on quite yet apparently.

    18. Re:C#++? by Anonymous Coward · · Score: 2, Interesting

      Nonsense. Microsoft puts huge effort into promoting C# over languages in insidious ways - like putting hundreds of times more effort into ensuring their OS and applications interact well with it, and exposing functionality through C# preferentially to other languages. Why? Not because it's better or easier for them or the user, but because they can't control C++, Java, etc. Programmers working in those languages are also inherently able to develop software for non-Windows systems / browsers. The languages can stipulate that non-portable extensions creating OS or vendor lock-in aren't to be offered. Portable skills are an even bigger threat to Microsoft's near monopoly on the desktop, and aspirations on the server, than portable languages and toolkits. Put Microsoft's muscle behind a language and of course it's going to "take off". And Java's success isn't so much a negative reflection on C++ as a product of having embraced a different and inherently valuable deployment technology: the "web" browser.

    19. Re:C#++? by master_p · · Score: 1

      Not how to spawn threads and create mutexes, but lower-level issues, like coherency.

      Programmers need those though.

      Rvalue references will help a lot with the creation of temporaries that are just copied and destroyed.

      RValues is a disaster waiting to happen. Move semantics is wrong, as the auto_ptr fiasco proved.

      You see this now in all the specializations in the libraries for the swap function.

      It's silly, swapping aggregates should be pointer swaps, not value swaps.

      Currently template error messages are a mess. several lines of unreadable garbage because your type doesn't supply a member or operator that the template needs. Concepts will lead to concise, easy to understand error messages.

      That's because the compiler writers did not make a good effort to make error messages comprehensible. If the error message started from the line of template instantiation, instead of the template code, there would not be such a problem.

      Lambdas and closures will simplify using the STL algorithms without having to create a lot of functors.

      But the lambda function syntax is silly. Using [] to declare a lambda? it's silly. Having to declare which outer variables should be in the closure? double silly.

      They forgot the most important thing: garbage collection...

    20. Re:C#++? by syousef · · Score: 3, Insightful

      If you make language even an idiot can use, idiots will be using it. Like with VB.

      So lets make the language as difficult as possible. That way only good programmers will even be able to write code in it. Never mind the fact that they'll have to spend all their mental effort getting the code to work instead of focusing on the problem they're trying to solve.

      The fact that an easy versatile language makes it easy for idiots to program in it is no reason to artificially make a language overly complex. That's insane. It's like making a hammer that requires a PhD to use just to prevent bad handymen from doing handywork.

      In other words plenty of good code was written in VB by non-idiots who didn't want to focus on the language but had a practical problem to solve. You can leave the morons to survival of the fittest.

      --
      These posts express my own personal views, not those of my employer
    21. Re:C#++? by ciggieposeur · · Score: 1

      Well that's just it, C++ is designed to be as general a language as you can manage

      No, that's Lisp.

      C++ is designed to be the fastest runtime language as BS can manage, pushing all of the optimization work to the compiler and allowing people to pay the performance price for only what they need.

    22. Re:C#++? by drxenos · · Score: 1

      I never said threading support wasn't needed. It will be in a TR.

      Rvalues are one of the best thing to happen to the language. One of the reasons auto_ptr is bad is it doesn't have the language's support for rvalues.

      Vectors, et. al., do swap pointers. What is your point?

      Making good error messages is not possible without knowing the intent. All the compiler knows is the template could not be instantiated with the given arguments. It doesn't know whether you need to fix the template or the parameters.

      I wholeheartedly agree with you on the lambda syntax. They go way to far to avoid adding new keywords.

      GC is suppose to be in a later TR.

      --


      Anonymous Cowards suck.
    23. Re:C#++? by neokushan · · Score: 2, Interesting

      Efficiency is just one of the goals of the language, but general use is another. That's why you can do absolutely ANYTHING with C++. Give me a task another language can do that C++ can't.
      That's what I mean by being "general".

      --
      +1 IDisagreeSoHeMustBeATrollOrAnAstroturferOrAShill
    24. Re:C#++? by master_p · · Score: 2, Informative

      No, auto_ptr is bad because of move semantics, not because of lack of rvalues.

      RValues are bad because they will encourage people to write move constructors, thus making it difficult to tell who owns the data.

      My point about swap is that rvalues are not required for it.

      Regarding the templates, 99% of the time the problem is at the point of instantiation, not inside the template. The priority should have been the point of instantiation: the first line should show the point of instantiation, and the last line the actual template.

      GC will never come in C++, let's not fool ourselves.

    25. Re:C#++? by SerpentMage · · Score: 1

      Funny the parent is modded 5 as insightful and you are completely ignored. I agree with you completely.

      I think the time for "men and macho" languages is over. I quite programming C++ about 5 years ago. Man am I glad. I can actually focus on getting code to work.

      A simple thing like integrating source code from other places STILL does not work properly. Components are extremely painful and a piece of cake elsewhere...

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    26. Re:C#++? by SerpentMage · · Score: 1

      That is such a BS argument...

      I have been doing number crunching since 15 years ago (am a mechanical engineer who has written his own CAD program).

      Want to know what people said around 1991 when it came to number crunching?

      "You want to create an application that uses forms to do some business processing , and send it to database , use C++ . You want an application that has to calculate prime numbers , or some other heavy mathematical issue , use Fortan."

      So where is Fortran today? Not used much actually. C# can be used for number crunching, you just have to be careful how you code your algorithm.

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    27. Re:C#++? by drxenos · · Score: 1

      Well, I respect your opinions, but we will have to agree to disagree.

      --


      Anonymous Cowards suck.
    28. Re:C#++? by gbjbaanb · · Score: 1

      and so is salary...

      (£46k average for c++, 41 for c#, 39 for ".net", 37 for ".net developer". Check out Linux adoption too!)

  13. Re:And Then COBOL 2009 by niklask · · Score: 1

    Have you ever tried writing a large-scale simulation code, for say dark matter/cosmology or cosmic-ray propagation in Java or C#? Please let me know when your code has finished executing.

  14. Re:Ha! Yeah right. by Anonymous Coward · · Score: 1

    Why the hell would you waste precious cycles running an assembler? That's what grad students are for!

  15. Re:It hurts you to learn C++ is still being used. by Anonymous Coward · · Score: 2, Interesting

    Most/All NDS games are Written in C++. C++ is a great language because it allows you to do so many things and still run fast. BTW i love this quote from Bjarne:
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows your whole leg off."
    -Bjarne Stroustrup

    Yeah except he's absolutely wrong. C++ makes it much easier to shoot yourself, but the effect is more like dropping an atomic weapon on yourself.

    I think Alan Kay put it best:
    "Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind."

    Kay goes on further to categorically state that C++ does not support object oriented programming because of the static type system.

  16. Re:And Then COBOL 2009 by Tenrosei · · Score: 4, Insightful

    hours finding memory leaks? How bad are you at debugging? Plus there are tons of tools to assist with memory leak detection. However, protection is no substitute for abstinence. Learn to write code better. BTW go do some embedded software with C# or Java.

  17. Re:And Then COBOL 2009 by bunratty · · Score: 2, Insightful

    I have C++ code that I maintain. It was written in 2004. I also use Firefox, Notepad++, FileZilla, 7-Zip, which are all written in C++. It seems like most the applications I run are written in C++, with many written in C and some Microsoft programs perhaps written in C#. Java killed C++? You wouldn't be aware of it from the software on my computer.

    --
    What a fool believes, he sees, no wise man has the power to reason away.
  18. Early interview still more interesting by rava · · Score: 4, Funny

    There's only one interview with Stroustrup that's worth reading: http://www.nsbasic.com/desktop/info/interview.shtml

    --
    {Science sans conscience n'est que ruine de l'âme}
  19. Re:And Then COBOL 2009 by TheRealMindChild · · Score: 1

    C++? Isn't that dead and buried? Bjorne created one interesting thing in his life and he is hell bent on keeping it alive--after Java and C# have buried it. Anyone ever tried to get a C++ job? They are few and far between.

    Maybe if you are the kind of programmer/developer that endlessly creates one-off database front end applications, this is true. C/C++ jobs are not hard to find at all. They just have a different target than you are apparently willing to work with. Try analytics. Try custom driver development.

    --

    "When life gives you lemons, don't make lemonade. Make life take the lemons back!" -- Cave Johnson
  20. Why not just call it C++#? by tjstork · · Score: 2, Insightful

    That's what this is... automatic memory management...bigger libraries... restricting pointers more and more....

    I mean, C++ is evolving so badly it makes Pascal suddenly look a lot better as a compile time language.

    --
    This is my sig.
    1. Re:Why not just call it C++#? by Ed+Avis · · Score: 3, Insightful

      Trust your uncle Bjarne. If you don't use it, you don't pay for it. You need not worry that the language is turning into C# or Python. It's still just as efficient for bare-metal programming as C ever was (and more so in some cases, with template specialization at compile time).

      As for 'automatic memory management', that was one of C's big features. Remember the 'auto' keyword?

      --
      -- Ed Avis ed@membled.com
    2. Re:Why not just call it C++#? by Anonymous Coward · · Score: 2, Insightful

      Uh, things like smart pointers have been a standard part of C++ for well over a decade. Way back when C++ first took off, a lot of people got it into their heads that it was just "C with classes", and that stuck around for a hell of a long time because of poor compiler support for the more advanced features. But seriously, you're working with a totally out of date concept of what C++ is. You're like the people who last used Windows when it was 3.11 and haven't updated their understanding of it.

    3. Re:Why not just call it C++#? by tjstork · · Score: 1

      As for 'automatic memory management', that was one of C's big features. Remember the 'auto' keyword?

      LOL. However, the auto keyword always had problems with thus:

      mystruct *getmystruct()
      {
      auto mystruct value;
      return
      }

      --
      This is my sig.
    4. Re:Why not just call it C++#? by Anonymous Coward · · Score: 1, Informative

      It doesn't have automatic memory management. By which I assume you mean garbage collection.

      If you meant smart pointers and RAII, then I must inform you that C++ already had those, they just weren't standardised (i.e. you had to use boost or roll your own).

    5. Re:Why not just call it C++#? by oldhack · · Score: 1

      That's right, C++ is the Perl of programming language.

      --
      Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
    6. Re:Why not just call it C++#? by Eli+Gottlieb · · Score: 4, Insightful
    7. Re:Why not just call it C++#? by RightSaidFred99 · · Score: 1
      Uhh, huh? You do understand that the reason nobody uses C++ anymore for a large number of applications is precisely because it's not more like Java and C#? Don't get me wrong, C++ has its place and is still obviously used heavily. But look in the enterprise development domain, for example. Largely .NET and Java dominated. In fact, barring footprint or specific and _rare_ performance issues, C++ is almost never the right choice nowadays unless you have to use it for e.g. drivers, kernel code, high performance scientific computing, etc... OK, that's actually a lot of things ;) I guess what I mean is that as a language, C++ is pretty lame and 1990's-ish but as a platform is is useful and required at times.

      This is an attemt to bring people back into the fold. I wonder how many professional C++ developers don't use something like Boost already anyway. This just standardizes it. If you don't want all that crap, don't use it in your apps.

    8. Re:Why not just call it C++#? by immcintosh · · Score: 1

      Um, I'm sorry, but... what the hell are you talking about? Restricting pointers? What? Did we read, like, different articles or something? I don't know if I'd call smart pointers the kind of "automatic memory management" I'd ever complain about. All they really are is essentially a regular * that has the decency to delete itself the moment all its references go out of scope. And completely 100% optional at that. As will be garbage collection if it ever becomes part of the core standard (it certainly won't in this next revision). And what's wrong with a bigger library? You don't have to USE the extra features, and they're mostly all templates anyway, so it's hardly increasing the size of your binary when you don't. I don't know about you, but I prefer to have the features available for me when and if I want them...

      How is this +4 Insightful? Am I missing something?

    9. Re:Why not just call it C++#? by lubricated · · Score: 1

      That's inane. It's battling for marketshare, instead of focusing on the strengths of C++ and making it the best language for certain tasks, they are making it a shitty language for everything. I doubt it can ever catch up to languages that have a better head start and compilers and debuggers that have never sucked as much as C++ ones still do.

      --
      It has been statistically shown that helmets increase the risk of head injury.
    10. Re:Why not just call it C++#? by noidentity · · Score: 1

      That's what this is... automatic memory management...bigger libraries... restricting pointers more and more.... I mean, C++ is evolving so badly it makes Pascal suddenly look a lot better as a compile time language.

      Because it's not Microsoft's language, for one. Also, you really should evolve your reading comprehension, because C++ will not be adding automatic memory management (GC), merely better guarantees so that GC libraries can be more portable. But reading the interview wouldn't have helped for your goal of a half-assed swipe at C++.

    11. Re:Why not just call it C++#? by ultrabot · · Score: 1

      Damn, where ary my mod rights when I seed them (+1 funny)

      --
      Save your wrists today - switch to Dvorak
    12. Re:Why not just call it C++#? by speedtux · · Score: 1

      As for 'automatic memory management', that was one of C's big features. Remember the 'auto' keyword?

      The "auto" keyword has nothing to do with "automatic memory management", it simply designates stack allocated variables (redundant these days).

    13. Re:Why not just call it C++#? by Ed+Avis · · Score: 1

      Yes - stack allocated variables which automatically get allocated memory when you enter a scope and are automatically freed when you leave the scope. Believe or not this automatic management (and yes 'auto' does stand for automatic) was once considered a big feature! It is so useful that 'auto' quickly became the default.

      The next step, of course, is automatic freeing of objects on the heap, which is what the other poster was talking about when he said 'automatic memory management'. But if you really think that having memory managed automatically is always a bad thing, you wouldn't be using C at all.

      --
      -- Ed Avis ed@membled.com
    14. Re:Why not just call it C++#? by speedtux · · Score: 1

      Believe or not this automatic management (and yes 'auto' does stand for automatic) was once considered a big feature!

      People don't call this "automatic memory management" anymore, and haven't since the 1970's. "Automatic memory management" nowadays only refers to garbage collection or reference counting.

      So, the statement that "automatic memory management was one of C's big features" is wrong and misleading if you make it in the 21st century.

      But if you really think that having memory managed automatically is always a bad thing, you wouldn't be using C at all.

      I think automatic memory management is a good thing, and I fault C for not having it. But I've also used C for 25 years; just because a language is poorly designed doesn't mean one can avoid using it.

  21. I just don't get it.... by AmazingRuss · · Score: 5, Insightful

    ...what do people find so difficult about C++? Use the standard libraries, exception handling, and make sure your news all have deletes, and it's no more difficult than any scripting language. I actually prefer it over scripting languages, which have their place, but feel all sloppy and unspecific. It's like the difference between building a house out of 2x4s and building one out of sticks you found laying on the ground.

    1. Re:I just don't get it.... by Free+the+Cowards · · Score: 5, Interesting

      Well, here's what I personally dislike about C++. You don't have to agree with them, but this is how I feel and I think it's how many other people do as well. Certainly when talking to people who prefer other languages over C++, they have expressed similar sentiments.

      1. Lack of libraries. The C++ standard library basically gives you file IO, containers, and that's it. If I want to do something like fetch the contents of an HTTP URL, parse XML, serialize objects, compute dates and times, use regular expressions, compress data, or even just simple, basic Unicode support, then I have to hit some external library that I may have to install and probably can't rely on existing on another machine.
      2. Flexibility. In C++ it is essentially impossible to make, say, a dictionary where each key can refer to an object of a completely different type. This is what you refer to as "sloppy", but I actually find this flexibility to be essential in designing good software. The fact that C++ does not allow it forces me to either twist my program's design in unnatural ways to fit the language, or do a lot of extra work to twist C++ to fit my program's design.
      3. Manual memory management. In any complex program, balancing your news with deletes is not as simple as you make it out to be. Object ownership is a tough problem. Lots of C++ code solves this problem by making a lot of defensive copies, which in turn hurts performance greatly.
      4. Errors. Make one simple typo in a template instantiation and you can generate literally pages of twisted, non-obvious errors. This makes it much harder to get a C++ program to compile than it should be.
      5. Nonportability. C++ compilers tend to differ massively in just how well they adhere to the C++ specification. Creating portable C++ code is much harder than it ought to be, especially when you take into account the necessary dependence on external libraries I mentioned above. And then you need a build system to go with all of that, which brings its own set of headaches.
      6. Readability and writability. With all the type information being declared all over the place, big template declarations, and the like, I find that C++ takes considerably more effort to both read and write.

      The really big issues for me are the flexibility and the lack of libraries. The rest is less important. But with C++ it's like building a house out of 2x4s that you're not allowed to cut to length, whereas with moer modern languages it's more like building a house out of prefabricated rooms, with a ready supply of 2x4s and tools to shape them as you need if the prefabbed rooms don't fit your needs.

      Please note that this is just my opinion, and you asked for it. Feel free to disagree, but please don't flame.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    2. Re:I just don't get it.... by Hognoxious · · Score: 3, Funny

      It's like the difference between building a house out of 2x4s and building one out of sticks you found laying on the ground.

      Error 2317 - Invalid analogy - no wheels. Bailing...

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    3. Re:I just don't get it.... by umghhh · · Score: 2, Insightful

      There is nothing preventing anybody from bad habits in coding and putting nails into own foot. Whether you use hammer or nailgun it makes your foot ache all the same.

    4. Re:I just don't get it.... by SupplyMission · · Score: 3, Insightful

      Flexibility. In C++ it is essentially impossible to make, say, a dictionary where each key can refer to an object of a completely different type. This is what you refer to as "sloppy", but I actually find this flexibility to be essential in designing good software. The fact that C++ does not allow it forces me to either twist my program's design in unnatural ways to fit the language, or do a lot of extra work to twist C++ to fit my program's design.

      If you're not offended by the idea of using the Boost libraries, the boost::any class will let you be sloppy like that.

      Manual memory management. In any complex program, balancing your news with deletes is not as simple as you make it out to be. Object ownership is a tough problem. Lots of C++ code solves this problem by making a lot of defensive copies, which in turn hurts performance greatly.

      The boost::shared_ptr class has changed the way I write C++ code. It's a header-only class, so it's possible to only include it, and nothing else from Boost, in your project.

      Readability and writability. With all the type information being declared all over the place, big template declarations, and the like, I find that C++ takes considerably more effort to both read and write.

      I have found that wise use of typedefs can hugely improve readability and writability. On the other side of the coin, some people go overboard with typedefs, essentially making worse the problem they originally intended to solve. Like code formatting or any other convention, it has to be used where it makes the most sense. (Avoid developers with hammers who think everything is a nail, or needs to be turned into a nail, so they can hit it.)

      For example, I find this to be quite readable and writable:

      typedef std::vector<SomeHairyClass> SomeHairyList;
      typedef std::map<CuddlyKeyClass, SomeHairyList> HairyListMap;
      HairyListMap foo;

      Saying all that without some judicious use of typedefs would of course be nearly unreadable, especially if later you have to make use of iterators and nested types in the vector or map.

      The really big issues for me are the flexibility and the lack of libraries. The rest is less important. But with C++ it's like building a house out of 2x4s that you're not allowed to cut to length, whereas with moer modern languages it's more like building a house out of prefabricated rooms, with a ready supply of 2x4s and tools to shape them as you need if the prefabbed rooms don't fit your needs.

      On the contrary, I find that C++ gives you all the 2x4's, wood panelling, nails, screws, and all the tools you need. You just have to become a half-decent carpenter before you can start building your house. It's just a little bit harder to quickly make working prototypes (build a home from prefab parts), but as you indirectly pointed out, there are plenty of other languages that are better suited to that building style. The right tools for the right job.

      Please note that this is just my opinion, and you asked for it. Feel free to disagree, but please don't flame.

      Duly noted, just adding mine to the discussion. :)

    5. Re:I just don't get it.... by HappySmileMan · · Score: 1

      QT libraries fix all of those.

      Of course it's not standard, and it only counts as portable assuming other people have the libraries. Which I guess means it fails point 5 outright depending on how you interpret it.

    6. Re:I just don't get it.... by Skreems · · Score: 1

      I'm tempted to say you don't know what you're talking about, since using exceptions is one of the worst thing for making all your 'new's actually hit matching delete statements.

      Seriously, though, there's a ton of random scary things that can go wrong. Odd flow stuff can break deletions causing memory leaks. Simple operations can cause memory corruption leading to crashes. And god forbid you get to the point of compiling code into multiple libraries, because then you run into memory ownership issues. Yes, it's possible to write correct code in C++, but since it's built to let you have control over more parts of the language there are more things that can go wrong, and more things you can break. It takes more time to make it correct.

      --
      Slashdot needs a "-1, Wrong" moderation option.
      The Urban Hippie
    7. Re:I just don't get it.... by Eli+Gottlieb · · Score: 1

      Well once you get past the people who can't handle C++ because they have Java Minds, you arrive at two main things that make C++ a bugger: templates and operator overloading. They make it a real, true FUCKING BUGGER to look at a piece of code and understand what it actually does.

    8. Re:I just don't get it.... by twistedcubic · · Score: 1

      2. Flexibility. In C++ it is essentially impossible to make, say, a dictionary where each key can refer to an object of a completely different type. This is what you refer to as "sloppy", but I actually find this flexibility to be essential in designing good software. The fact that C++ does not allow it forces me to either twist my program's design in unnatural ways to fit the language, or do a lot of extra work to twist C++ to fit my program's design.

      std::map does this, if I understand your description. I think you're just nitpicking the rest.

    9. Re:I just don't get it.... by gbjbaanb · · Score: 2, Informative

      no, I think he meant a map where the value part can be any type, not just the one stated in the definition.

      eg.
      map.insert(1, "hello");
      map.insert(2, 69);
      map.insert(3, myobj);

      etc. Boost::any is what he's after in that case so its a pretty moot point.

    10. Re:I just don't get it.... by Ana10g · · Score: 1

      Ok, so I hadn't realized that my dev environment included boost until about a week ago, and am still coming up to speed on boost. I echo the GP's concerns (I've largely been a Java developer), and am examining the boost documentation as we speak.

      The other issue I take with general C++ development is documentation. I've been fairly spoiled by Javadoc over the years, and while I know things like Doxygen exist, they aren't widely used for the C++ language (to my knowledge). A brief examination of the boost libraries, however, yields a wealth of documentation. I'm quite impressed!

      Let me say this. The "Smart Pointers" defined as part of the boost library look fantastic. I'm going to incorporate them as we speak. Have a look at the examples, they really are useful.

      --
      just an analog boy living in a digital age.
    11. Re:I just don't get it.... by Narishma · · Score: 1

      You mean Qt.

      --
      Mada mada dane.
    12. Re:I just don't get it.... by Jerry+Coffin · · Score: 1

      As an example of what I mean, check out the C++ coding guide for one of the biggest users of C++ - Google: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml [googlecode.com]. You suggest "use standard libraries, exception handling, and make sure all your news have deletes", but Google engineers say don't use exceptions, don't use iostreams except for logging, and avoid a whole slew of C++ features like RTTI, multiple inheritance, automatically generated constructors / copy constructors / assignment operators, operator overloading, etc.

      Some of these are a simple matter of the chosen application domain. Keep in mind that nearly everything Google does:

      • uses a web interface
      • uses a distributed back end.
      • needs to be highly scalable.

      These mean that nearly all external communication needs to be via sockets or something similar. Although people have written code to make iostreams talk through sockets, the concepts involved are sufficiently different that it rarely works very well. Ergo, for a web-based communication, you need a different model from iostreams.

      The combination of web-based and highly scalable also implies that most data being stored in the back-end shouldn't generally be in normal files either -- you're generally going to store the user's data in something like a database instead. For the few things (e.g. Google's index of the web) that really are shared across the entire application, they have their own file system and such, so you access them as they require -- which probably doesn't fit with iostreams very well either.

      RTTI and multiple inheritance are like parachutes: most people should and will never use them. A few will use them once in a while, and a tiny proportion (who most people think are mildly insane) use them on a regular basis. Like a parachute, however, you should be glad it's there even if you never use it (directly) -- if you ever need it, you'll really need it, and then there's really no substitute.

      At least some of their advice also stinks of simple elitism -- the people writing the standard making it clear they they know how to use this feature safely and well, but don't trust the peons who have to follow the standard to do the same. In fairness, that attitude is somewhat justified -- for an obvious example, just knowing how to program (even extremely well) does not imply knowing how to write exception-safe code. In fact, recent college graduates rarely know much about exception safety. Worse, even once you do know, it requires substantial discipline to really do it.

      The same applies to quite a few things like compiler-generated copy constructors. If you design your classes well otherwise, they're not a problem at all -- but from what I've seen, roughly 99% of recent college graduations not only haven't been taught to design their classes well, but have been actively taught to design their classes poorly!

      In short, most of the conclusion to be drawn from the Google coding guidelines comes down to two things:

      1. Google codes primarily for a fairly specific domain
      2. Most colleges do a lousy job of teaching programming
      --
      The universe is a figment of its own imagination.
    13. Re:I just don't get it.... by korbin_dallas · · Score: 1

      Perhaps you should read the C++ FAQ.
      That will give you a big clue.

      The copy I have is 566 pages of 'Gotchas' for C++.

      And thats just the C++ language, not STL and not Boost.

      For example we have over 30 coders here doing 'C++'....in name only,
      the deep intertwining and people reaching over into classes and the
      sheer number of public variables is enough to make me puke.
      9 out of 10 coders do C++ wrong. Try to debug that.

      --
      They Live, We Sleep
    14. Re:I just don't get it.... by Viol8 · · Score: 1

      "compute dates and times, use regular expressions, compress data,"

      Err, those are standard C libraries, never mind C++. Do you seriously think every C/C++ programmer has to write some assembler to read the system clock every time they need to get the time? Or have to work out their own calender every time they want to print the date in 3 days time?

      "In C++ it is essentially impossible to make, say, a dictionary where each key can refer to an object of a completely different type"

      Rubbish. Just use void pointers in the dictionary to point to objects of whatever type you want.

      "balancing your news with deletes is not as simple as you make it out to be."

      If you're a rubbish coder then no , its not simple. Use java.

      "Lots of C++ code solves this problem by making a lot of defensive copies, which in turn hurts performance greatly."

      Wtf are you talking about?

      "

    15. Re:I just don't get it.... by EsbenMoseHansen · · Score: 1

      I'm tempted to say you don't know what you're talking about, since using exceptions is one of the worst thing for making all your 'new's actually hit matching delete statements.

      If you are using delete, you are most likely doing something wrong. If you are new'ing many objects, you are most likely doing something wrong. Writing exception safe is not hard, and besides, is the same for every sort of language. Remember that it is not just your new/deletes, but (more commonly, too!) you lock()/unlock(), open()/close(), beginTransaction()/endTransaction() and so on that have to balance. If you want to know how much Java people struggle with getting that right, try searching on finally. Or try writing a program that copies one file to another, in C++ and Java :)

      --
      Religion is regarded by the common people as true, by the wise as false, and by rulers as useful.
    16. Re:I just don't get it.... by mikael · · Score: 1

      It's when you start building complex systems with multiple inheritance chains combined with templates based objects that have their own dynamically allocated/dellocated objects that things can get a bit tricky.

      There are little gotchas that aren't intuitive... Example:
      If you class B which inherits class A, and defines function 'func( int ival )' which has different parameters from function 'func( float fval )' in class A, you have to use the 'using' keyword to make sure you still have the function from class A.

      The thing that annoys me with templates is that you have to define all the functions in one big super-blob of code in a single header file rather than in a separate source files. I prefer to see a nice simple clean header file that lists all of the functions that are available, and have all the actual implementation in a separate file.

      As many other commenters will point out, there are slightly different implementations for doing different things (reading/writing directories, multi-threading, strings). This means that low-level blocks of code or header files have to be #ifdef'ed

      It's no big deal if you are writing a coursework for class on a single system, but when you are writing cross-platform application code on a contract, it's a moronic waste of time, since there are more productive things you could be doing.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
    17. Re:I just don't get it.... by dkf · · Score: 1

      ...what do people find so difficult about C++?

      The real pain in my experience with C++ is that it is difficult to maintain a stable ABI for libraries built with it. The issue is that too many details of the layout of library interfaces vary between different compilers on a single architecture (including different versions of the same compiler, alas) and too many details of the API get bound into the clients of the API, making it difficult to evolve that API without breaking the ABI contract.

      Umm, that sounds technical. To put it simply, it's nice to not have to recompile the world when you do relatively minor adaptations to a library. With C, that's fairly easy to achieve, but C++ makes life much harder and C++ compiler authors don't do much to help. This was a big enough issue that in the end we rewrote the library in question from C++ into C, which was not pleasant but gave us a better handle on maintenance.

      Of course, I'd much rather be scripting, where you can get a program written and your problem solved in seconds...

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    18. Re:I just don't get it.... by dcam · · Score: 1

      2. Can't you just do this with a void pointer? Seems like a bad idea anyway
      3. autopointers.
      6. IMO well written C++ is the most readable code, YMMV

      --
      meh
    19. Re:I just don't get it.... by Alpha830RulZ · · Score: 1

      I agree massively, and would add, C++ is by far the most difficult programming environment I have ever tried to learn. The surface area is large, for many of the reasons you state, and it's brittle as a result. While I understand the reasons that it's adherents appreciate it, there is a reason it occupies an increasing small percentage of the development space. It makes sense for system programming and numerically intensive tasks because of it's undeniable performance advantage, but you have to be a masochist to want to use it for other work.

      --
      I was taught to respect my elders. The trouble is, it's getting harder and harder to find some.
    20. Re:I just don't get it.... by anomalous+cohort · · Score: 1

      make sure your news all have deletes

      Object creation can be fairly complicated, especially in highly OO systems. There are fairly well documented ways of dealing with the complexity of object creation; however, they all boil down to using the new command in a method separate from where the resulting object will get used. Over time, new functionality drives additional layerings and refactorings in the code. Pretty soon it's not so easy to make sure your news all have deletes. This is why garbage collection is so popular.

    21. Re:I just don't get it.... by zobier · · Score: 1

      It's like the difference between building a house out of 2x4s and building one out of sticks you found laying on the ground.

      The relative merit of which depends on whether you're a man or a bird. Use the best tool you can find for the job at hand.

      --
      Me lost me cookie at the disco.
    22. Re:I just don't get it.... by davewalthall · · Score: 1

      Try boost::shared_ptr

    23. Re:I just don't get it.... by smellotron · · Score: 1

      I won't argue with your other points, but...

      Manual memory management. In any complex program, balancing your news with deletes is not as simple as you make it out to be. Object ownership is a tough problem.

      Application code shouldn't be managing memory. That's what smart pointers or other resource-owning utilities exist for. Effectively layered C++ applications have very few ownership issues, and where they exist, they tend to be between threads (a logical issue for the developer to solve, not something that the programming language can do itself).

      Lots of C++ code solves this problem by making a lot of defensive copies, which in turn hurts performance greatly.

      Alternatively, C++ is designed as a language with value semantics. That means when you have a small struct, you copy it around as needed instead of trying to keep a single "entity" accessible everywhere. You'll probably also have better overall performance with that, because you won't be thrashing the cache so much (better locality of reference for stack/member objects, as well as reduced sharing or false sharing of memory between threads).

      Remember: unless you've measured a performance difference, it doesn't exist. Most estimates at performance analysis are wrong.

    24. Re:I just don't get it.... by B4D+BE4T · · Score: 1

      what do people find so difficult about C++? Use the standard libraries, exception handling, and make sure your news all have deletes...

      The standard C++ libraries pale in comparison to the standard Java libraries in terms of ease of use. And making sure all of those news/mallocs have deletes/frees is not always as easy as it sounds. The GP is right. More complex designs are easier to implement in Java, with the speed-sensitive parts coded in C/C++.

    25. Re:I just don't get it.... by tyrione · · Score: 1

      ...what do people find so difficult about C++? Use the standard libraries, exception handling, and make sure your news all have deletes, and it's no more difficult than any scripting language. I actually prefer it over scripting languages, which have their place, but feel all sloppy and unspecific. It's like the difference between building a house out of 2x4s and building one out of sticks you found laying on the ground.

      What do people find so difficult about ObjC and Cocoa? If it's based upon syntax or the MVC then we're back in 1989. The frameworks are deeply rich. My guess is that the only argument will be, ``It's mainly tied to Apple and limiting my cross-platform opportunities.''

      Meanwhile, people writing Cocoa applications on the desktop/portable and handheld are making some serious cash and enjoying a growing and large user base for both the desktop/portable and handheld markets without having to leave the Cocoa platform.

    26. Re:I just don't get it.... by Free+the+Cowards · · Score: 1

      Remember: unless you've measured a performance difference, it doesn't exist. Most estimates at performance analysis are wrong.

      And of course this applies just as much to all the C++ advocates talking about how slow other languages are.

      --
      If you mod me Overrated, you are admitting that you have no penis.
  22. Re:And Then COBOL 2009 by ardor · · Score: 4, Insightful

    I'll consider Java and C# as C++ replacements once they get:

    1. REAL templates, not this generics joke
    2. Proper RAII, which many programmers mistakenly believe to be useful for memory management ONLY (scoped locks come to mind) (Java/C# finalizers are no replacement)
    3. Java: operator overloading

    These points are serious, especially the first, without real templates, generic programming/metaprogramming at compile-time is not possible. These two are one of C++'s biggest strenghts, though.

    To be fair, C# 3.0 is somewhat nice, especially its functional core. Java is a totally uninteresting language with very small expressiveness. Of course, if the job requires it, there is no discussion, but in my spare time, I prefer C++.

    --
    This sig does not contain any SCO code.
  23. Re:It hurts you to learn C++ is still being used. by squarooticus · · Score: 3, Informative

    And when it does, it's trivial to go in and write the speed-sensitive portions of the program in a faster language.

    Agreed. Premature optimization is the root of all evil. Write the control flow in a high-level, easy-to-debug language, and later optimize the pieces running unacceptably slow by rewriting them in C. No object-oriented language with legacy holdovers, static typing, and gross syntax needed.

    Despite knowing it is a fallacy, I will instruct by appealing to my experience: 27 years coding, 10 of that with a salary, and 5 years before that as an entrepreneur. I have forgotten more C++ than most people know, having written everything from a reference-counting garbage collector to an entire content management system in it... and with the benefit of 7 years of professional C++ development, I can say with a straight face that it is the wrong tool for every job.

    --
    [ home ]
  24. Just want to remind everybody by Escogido · · Score: 4, Informative

    http://yosefk.com/c++fqa/ - this site says it all.

    And it's also being argumentative and verbose at that, unlike your routine 'C++ sucks' rant.

    1. Re:Just want to remind everybody by Timmmm · · Score: 1

      Wow, I just started reading that but it is pretty clear that whoever wrote it doesn't know C++ very well. Just reading the const correctness bit (randomly chosen) and he makes false statements like:

      "If the vector itself is declared const (as in const std::vector<T*>), then you can't modify the vector, but you can modify the objects."

      #include <vector>
      #include <string>

      using namespace std;

      class Object
      {
      public:
          void setData(string d) { data = d; }
          string getData() const { return data; }
      private:
          string data;
      };

      void test(const vector<Object>& v)
      {
          v.at(0).getData(); // OK
          v.at(0).setData("test"); // compile error.
      }

      int main()
      {
          vector<Object> v(1);
          test(v);
          return 0;
      }

      In other words, ignore his nonsense.

    2. Re:Just want to remind everybody by Haeleth · · Score: 2, Informative

      Your example uses a const std::vector<T> . He's talking about const std::vector<T*> , i.e. a const vector holding pointers. In such a case, you most certainly can modify the objects those pointers reference.

    3. Re:Just want to remind everybody by immcintosh · · Score: 2, Interesting

      I looked at that, and at first it seemed, well, this is fair. A lot of these things are drawbacks, and it's pretty well laid out. Then I read into it a little further... and I really have to wonder. A lot of it is just WILDLY exaggerated. I mean, the author clearly tried to blow some minor problems up to ridiculous proportions. Some of the stuff in there is just absurd. Gems like this:

      [8.2] What happens if you assign to a reference?

      FAQ: A reference is the object, so of course you assign to the referent object.

      FQA: Which means that you can't understand the effect of a statement as simple as a=b; without knowing whether a is a reference or not. A nice feature complementary to references (which make you wonder what "a" means) is operator overloading (which makes you wonder what "=" means). Be careful as you work your way through a quagmire of C++ code.

      I'm sorry, but that's just inane. Of course you can't know what the effect of an assignment will be without knowing the actual type of what you're assigning to. How is this news? How is this important? Unfortunately a great deal of that site you linked to is filled with useless fluff like this.

      Yeah, that article says a lot. Unfortunately, upon close inspection, very little of it is of much value.

  25. Re:It hurts you to learn C++ is still being used. by Tenrosei · · Score: 1

    Obviously c++ isn't really object orientated it was meant to be an application of object orientation on C. and still be able to run and compile C. Only an idiot would say C++ is the definition of an Object Orientated language. but why did we get on its not object orientated all i said was it runs fast and can be used to do a lot of things. It seems you want to say c++ sucks because its not Object orientated when I didn't claim it was.

  26. Re:It hurts you to learn C++ is still being used. by ardor · · Score: 1

    Yeah except he's absolutely wrong. C++ makes it much easier to shoot yourself, but the effect is more like dropping an atomic weapon on yourself.

    I keep hearing this, and every time I see the actual code, its a horrible mess. C++ has bazillions of features; if people are too stupid to understand them, then they shall not blame it on the language. The same people abhor Lisp because its so complicated, Haskell because its so alien etc. and stay in C#/Java wonderland.

    Of course there are problems with C++, like the horrible, over-complicated syntax, slow compilation, etc. but most people dont come even close to these.

    --
    This sig does not contain any SCO code.
  27. Re:It hurts you to learn C++ is still being used. by salec · · Score: 1

    Well, it is like a fence: it protects you from falling over, but once it runs out, you may fall again. If you put the fence all around you, you won't be able to go anywhere further.

    Similar thing is with protection provided in C++: it works against C kind of stupid mistakes but it brings in a set of its own stupid mistakes. There is always another downfall we are yet to encounter.

    Therefore, and realizing it struck me this very moment, languages should be as permissive and empowering as possible (go ahead, knock your self out completely, foot, leg, everything!), but discipline should be enforced intrinsic to language definition.

    Language should have means to enable us to construct discipline rule set and just blindly check consistency of code and attached discipline (akin to XML idea, although XML is not a programming language). To return to "fence" analogy, programmer (or project architect) should be allowed to construct new safety fences (or even remove old ones if necessary) as needs arise or problems are encountered.

  28. Re:It hurts you to learn C++ is still being used. by iplayfast · · Score: 3, Insightful

    I've found that the biggest advantage for C++ is the portability. I have written an application backend for PC's (back in the days of DOS) and since then ported it through various versions of windows, Linux (for web use), Palms, and Pocket PC's.

    Using C++ allowed me to very easily make the different processor needs, compatible, by writing little compatibility layers, which would swap bigend values, unpack data structures from disk into memory (so is on even boundary). and so on.

    Yes the fast speed was why I originally went with the C/C++ route, but the big benefit has been the portability.

  29. Re:It hurts you to learn C++ is still being used. by johannesg · · Score: 5, Insightful

    ...and roll on the C++-hatred! Second C++ article in a short time, and again lots of venom and anger. "Months saved in development"? Really? What are you doing, implementing your own OS before you start application development? Here's a newsflash: C++ also has support libraries, just like Java, Perl, Python and Ruby. They may not be part of the language specification (and I still think that's a weird idea to begin with, but I'm old-fashioned that way), but that doesn't mean they don't exist.

    Anything you could want for in a modern language is there. And nobody is holding a gun to your head and making you write those scary templates if you don't want to.

    I'm just positively amazed that Slashdot, in theory home of programmer geeks anywhere, should have such a violent dislike of C++. Not that there is nothing to criticize about it, but it is still an amazingly powerful, versatile tool that programmers anywhere would do well to learn.

  30. Re:And Then COBOL 2009 by nate+nice · · Score: 1

    All my favorite video game engines are written in Java I hear.

    This guy is an obvious troll.

    One thing I've noticed is that you're much more likely to work with idiots if working on applications that use Java or C#. As the programming language becomes more powerful, the programmers using it are often far better and of superior education and degree.

    --
    "If you are a dreamer, a wisher, a liar, A hope-er, a pray-er, a magic bean buyer ..."
  31. What's in a name? by bradgoodman · · Score: 1

    "C++0x" - it just rolls off the tounge!

    But to their/his credit, from the Wikipedia entry on the "Haxe" language:

    he name haXe was chosen because it is short, easy, cool, and "has an X inside", which the author claims is necessary to make any new technology a success. /quote

    1. Re:What's in a name? by pauljlucas · · Score: 1

      "C++0x" - it just rolls off the tounge!

      They're not changing the name of the language. "C++0x" simply refers to the C++ specification that is slated for release sometime in the future. Back when they started working on it, they couldn't forecast the year in which it would actually get released; hence "0x" is a placeholder where "x" will eventually get replaced with the last digit of the year the specification is released. As of right now, it's looking like it'll be 2009; hence the specification will become C++09.

      --
      If you reply, do so only to what I explicitly wrote. If I didn't write it, don't assume or infer it.
    2. Re:What's in a name? by jeremyp · · Score: 1

      C+=2
      C++++
      ++C++

      Take your pick.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  32. Fingers Crossed for Native Implementations by bsmoor01 · · Score: 2, Informative

    I really, really, really hope a lot of these things are implemented as compiler- or runtime-level features. I understand the purity aspect of implementing features as templates, but it just bloats my code and slows my compile times. A lot of the compile time for my apps is spent regenerating the same template crap over and over, then waiting on the linker to weed out what's duplicated. It takes forever.

  33. Truer words have never been spoken. by Anonymous Coward · · Score: 5, Funny


    C++ is to C as Lung Cancer is to Lung

    1. Re:Truer words have never been spoken. by jcr · · Score: 3, Informative

      Not sure how long ago I first heard that, and it's still as true today as it was back in '95. I think I first heard it from Greg Anderson, of Anderson Financial Systems (one of the old-time NeXT development shops.)

      -jcr

      --
      The only title of honor that a tyrant can grant is "Enemy of the State."
    2. Re:Truer words have never been spoken. by scotch · · Score: 3, Insightful
      True as in lung cancer affects and destorys lungs, c++ affects and destroys c?

      True today as it was then; i.e. not true at all.

      --
      XML causes global warming.
    3. Re:Truer words have never been spoken. by Casandro · · Score: 1

      Ohh and of course cancer causes tissue to grow in non-functional ways, just like the myriards of features introduced into C++.

    4. Re:Truer words have never been spoken. by tyrione · · Score: 1

      True as in lung cancer affects and destorys lungs, c++ affects and destroys c?

      True today as it was then; i.e. not true at all.

      The original comparison was to Objective-C which is more akin to the Air the Lung breathes to extend it's Self and instead of C++ being that Air it comes with Smog and every damn vapor we could invent to mingle with C.

  34. Re:And Then COBOL 2009 by dedazo · · Score: 1

    How many of you have had to spend countless hours tracking down memory leaks?

    You didn't get a big show of hands here, eh? 1997 called, he wants his raw pointers back. Nowadays we use any of the myriad freely available pointer wrappers and libraries. If you're using any framework at all, chances are you have a pointer class. STL, Boost, ATL, APR, MFC, MC++, etc. They all do. If you are a masochist, that's fine. Just don't assume everyone else is too.

    It's all thanks to Bjorne and his crap C++

    Well, you're probably just trolling here, but C++ is hardly dead, and it's hardly crap. After all, the two languages you claim "buried" it are written in C++.

    --
    Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
  35. Re:And Then COBOL 2009 by UtucXul · · Score: 1

    Anyone ever tried to get a C++ job? They are few and far between.

    Actually I just did a couple of months ago. And I found more than one. In fact I'm sitting here at the one I took posting this while I wait for a whole lot of C++ code to compile.

  36. Re:It hurts you to learn C++ is still being used. by Anonymous Coward · · Score: 1, Insightful

    You are forgetting about the areas where everything is "unacceptably slow" by default. I.E it's never fast enough. (Real time A/V processing for example)

    What is needed in those circumstances is a language that is both "close to the metal" and allows for inline ASM, but also lets you do OO on the structural level.

    What are the options there? D maybe?

  37. Re:It hurts you to learn C++ is still being used. by ardor · · Score: 3, Insightful

    And I can say with a straight face that you are wrong.

    If you base your experiences on pre-2000s C++, you know very little of modern C++. I have been developing in it for more than 10 years, and a few years ago I would have agreed with you, but things have changed. Really.

    --
    This sig does not contain any SCO code.
  38. Re:And Then COBOL 2009 by gladish · · Score: 1

    The amazing part to me is that when people try to compare managed code -- like java or .NET -- to native code c, c+++ they make these wild claims about how much faster native code is. But they fail to mention that most of the managed code is running natively. And as far as your simulation, can you reasonably explain why it would be so much faster in c++ as opposed to say java that we would have to wait forever for it to finish?

  39. Are you kidding, right? by YA_Python_dev · · Score: 1

    You can't figure out why

    Try writing a large program that needs to do heavy number-crunching in Java/Ruby/Perl/Python, or whatever is your preferred language.

    Python + Numpy is probably faster that anything most C++ programmer can write, since it uses libraries that can be optimized for the specific processor they run on, including using multiple processors/cores if available.

    Hand-optimizing code that runs on modern processors is not a trivial task at all (very simple example: caches can have extremely big and very non-intuitive effects on the speed of code).

    Try writing a trivial (5 or 6 lines of code) md5 implementation using only the Python standard library and compare its speed to the GNU md5sum program (written in C). Hint: read blocks with sizes of roughly 10 kB.

    --
    There's a hidden treasure in Python 3.x: __prepare__()
    1. Re:Are you kidding, right? by Skowronek · · Score: 1

      Try writing an algorithm you don't have a canned standard library for...

    2. Re:Are you kidding, right? by niklask · · Score: 1

      You are absolutely right that python+numpy code can be a whole lot faster than c++ code and also easier to write. I have used python+numarray (the numpy predecessor) for a while and it is amazing what you can do. But there are limitations to this too. For example; what do you do when you want to work on that 10000x10000x10000 grid in a simulation. Answer: you look to parallel computing, which is not a strength of python+numpy.

  40. Re:And Then COBOL 2009 by mooingyak · · Score: 1

    Anyone ever tried to get a C++ job?

    I had done some very light/minor C++ dev in my time, so I included it as an item on my resume. Last time I was job hunting (about a year ago), 90% of the calls that I got were for C++ positions, which I really did not want. I ended up removing it to filter out the noise.

    --
    William of Ockham had no beard. The most likely explanation is that it was chewed off by squirrels every morning.
  41. Re:It hurts you to learn C++ is still being used. by geminidomino · · Score: 1

    C++ also has support libraries, just like Java, Perl, Python and Ruby. They may not be part of the language specification (and I still think that's a weird idea to begin with, but I'm old-fashioned that way)

    Agreed. The thought of C++ going the way of PHP (The number of built-ins is OVER NINE^WTHREE THOUSAND!!!) makes my soul die a little.

  42. Time for the C++ haters to post... by serviscope_minor · · Score: 4, Insightful

    We will see the usual litany of C++ hating here in this thread. The hating will be generally based around misconceptions or problems that are 5 years old.

    So to get them out of the way:

    If you're leaking memory or spending time managing memory in C++, then you're using C++ wrong. Get a book written in the last 5 years.

    If you're worried about compiler compatibility (with the exception of export which isn't much use anyway), get a compiler written in the last 5 years.

    If you think that C does some subset of your task better, then write it in the common subset of C and C++ and quit whining. Or, write it in C and link it against your C++ code and quit whining.

    If you think that templates simply provide code bloat, then get a compiler newer than 5 years old.

    If you think C++ is slower than C, then get a good optimizing compiler (you know one written in the last 5 years) and do a benchmark. You will generally find that templates make C++ faster.

    If you think "modern" languages are more expressive, then give "modern" C++ a try (insert comment about recent compilers here).

    Sure there are valid complaints about C++, but the majority of them I hear on slashdot are complete bull. The majority of the remaining complaints will be fixed by C++0x.

    One remaining problem is the lack of a vast array of standard, business oriented libraries. I don't write business oriented code, and I find the C++ STL one of the best libraries out there since it provides really good support for writing efficient algorithms.

    Another problem is the difficulty in parsing C++. Sadly that's never going away.

    But if you're going to complain about C++ compared to recent languages here, make sure that you're talking about recent C++ too, and try to make sure the complaints are accurate.

    --
    SJW n. One who posts facts.
    1. Re:Time for the C++ haters to post... by Black-Man · · Score: 1

      I see RogueWave still sells C++ libraries (esp their network/interop libs) so I'd say STL isn't all that.

    2. Re:Time for the C++ haters to post... by cyberjessy · · Score: 2, Interesting

      Let's see what C++ is missing.

      C++ vs Ruby, Python,
      1. No REPL in c++. For a large project, it takes a while to try out an algorithm.
      2. Generators && Closures && lambdas
      3. Strong "reflection" capabilities too, which means that code can inspect, load and modify other code (in Java, C# too).

      LISP and C# has the above, plus
      1. Static Typing
      2. LISP possible has the more generic syntax conceivable, and code can extend the language to suit the domain. A consequence of Code itself being Data.
      3. Concurrency (one of those things 0x is supposed to solve) is simpler in a language which supports functional programming.

      Do not think that people are complaining about C++ lacking garbage collection. The real problem is with the expressiveness.

      --
      Life is just a conviction.
    3. Re:Time for the C++ haters to post... by Anonymous Coward · · Score: 1, Insightful

      And now, back to reality where some of us actually have to work with C++ for a living every once in a while...

      From professional experience, C++ is unportable, the compilers (still) suck (which is no wonder when you take the complexity of the language into account), simple code always ends up being complex, compile times are worse than ever and C++ still has no data hiding.

      Speaking of C, no C doesn't do a subset of my tasks better. C does all of my tasks better than C++ could ever dream of.

      BTW, I like your oxymoron of having "good" and "C++ compiler" in the same sentence.

      Also, you do realise that portability means that the code has to work on all C++ compilers, right? You can't just go and tell a customer "sorry, your compiler is not the latest alpha version of GCC, go away."

      It becomes even more hilarious by the fact that any version of GCC released in the past 5 years, as you seem to recommend, explodes in your face on every oppurtunity and leaves you with hard to find wrongcode cases.

      In fact, you've said nothing which hasn't been said 5 years ago. Or 10 years ago. The fact is that C++ is still not a usable language, and I somehow doubt that it will ever be one. It's time to throw it out and start over (or just avoid it like the rest of us do)

      Someone already linked to the C++FQA. The problem is that it'll easily take half a day to read it, and most C++ fanatics just jump on one chapter and yell "OMG WTF HE WANTS GARBAGE COLLECTION WHAT A MORON" and then dismiss it and go back to padding themselves on the back about how good C++ is.

      Anyway, enjoy your mess of a programming language. At least it gives me job security by providing a never ending source of completely broken code to fix.

    4. Re:Time for the C++ haters to post... by Anonymous Coward · · Score: 1, Interesting

      Very well said. The C++ language has evolved over the years and compiler technology has improved to bring it a long way. Libraries have also vastly improved including the STL. As for pointers, understanding RAII (Resource Acquisition Is Initialization) techniques and using smart pointer libraries will go a long way to prevent a lot of your bugs.

      I personally code in C++, was java certified ages ago and now do some C# code as well and I've got to say C++ remains a beautiful language to me.

      Every language has pitfalls and one doesn't need to program the same way or use every feature of a language but I think it's nice to be able to do things when you need to. IMHO C++ is a language that provides options. The real trick for the skilled programmer is knowing when to use which feature and writing code in a fashion that is easily maintained years later by others.

      The cowboy/whiz-kid mentality, or the lazy programmer mentality doesn't lead anywhere. In C++ it leads to memory leaks and random crashes and in other "modern" languages code that is so heavy on resources it's inefficiency is just amazing.

      Just remember NASA and other venerable institutions, including the linux kernel are still written in C/C++

    5. Re:Time for the C++ haters to post... by ucblockhead · · Score: 1

      If only any of those languages could run at a fraction of the speed of C++, we might be able to ditch it.

      --
      The cake is a pie
    6. Re:Time for the C++ haters to post... by dreamchaser · · Score: 1

      I have found over the years that most C++ haters never bothered to really learn the language. Most of them started with C and then took the habits they learned there and never changed them for C++. Despite being mostly a superset of C, C++ is a very different language and requires a very different approach to leverage properly.

    7. Re:Time for the C++ haters to post... by johanatan · · Score: 1

      C++ has generators, closures, & lambdas. It also has static typing and supports generic programming. And lastly, it supports functional programming. So, that leaves REPL--there are interpreters for C++ too. However, it's hard to find one that matches your compiler exactly (at least if you're using VC). Extending the language to suit the domain is achieved (among other things) by operator overloading (take a look at boost for instance). If you want to treat code as data, look at functor (or lambda) dispatch maps (and/or dynamic library loading or even generating, compiling and execing auxillary processes). And, garbage collection is also done for C++--a quick google search should find a handful of implementations to choose from. So, what does that leave from your list?

    8. Re:Time for the C++ haters to post... by juancnuno · · Score: 1

      Another problem is the difficulty in parsing C++. Sadly that's never going away.

      First of all, I am one of those haters. But you said that and I was reminded about this. A reformulation of the C++ syntax to be parsable by a LALR parser.

    9. Re:Time for the C++ haters to post... by Timothy+Brownawell · · Score: 1

      But if you're going to complain about C++ compared to recent languages here, make sure that you're talking about recent C++ too, and try to make sure the complaints are accurate.

      • Poor encapsulation. Things like this: class Foo_impl; class Foo { Foo_impl * _impl; }; should not be needed or useful.
      • The same thing that makes templates fast and flexible, also means that you can't dynamically link them.
      • No standard way to print a stack trace on crash/exception.
      • Can't link an executable generated with one compiler with an .so generated by another compiler.
      • No typesafe version of dlopen().

      On the other hand templates and RAII are made of pure awesome, and all the newer languages seem to want to break my RAII and castrate my templates.

    10. Re:Time for the C++ haters to post... by serviscope_minor · · Score: 1

      I don't normally respond to AC, but someone modded this insightful.

      And now, back to reality where some of us actually have to work with C++ for a living every once in a while...

      That would be me too. In fact I use it for a living most days, along with a host of other languages.

      From professional experience, C++ is unportable, the compilers (still) suck (which is no wonder when you take the complexity of the language into account),
        simple code always ends up being complex, compile times are worse than ever and C++ still has no data hiding.

      I have code running happily on VC++ ang GCC. The portability problems are to do with OS constructs, not the language. And what on earth do you mean by "no data hiding"? There's "private" and PIMPL if you want to go further. Of course you can still screw around with raw pointers, but C++ is not designed to stop you shooting yourself in the foot.

      Speaking of C, no C doesn't do a subset of my tasks better. C does all of my tasks better than C++ could ever dream of.

      Well, then you're an idiot who doesn't know how to code, because you could simply write in the common subset of both languages. There, you get C code compiling in a C++ compiler. So, remind me how C does it better if C++ can do it the same?

      But of course, you loose many of the benefits of C++ that way. Do yourself a favour and look up std::sort versus qsort benchmarks in terms of both speed and code size.

      BTW, I like your oxymoron of having "good" and "C++ compiler" in the same sentence.

      I haven't had much trouble with GCC recently. I haven't had an ICE in as long as I can remember.

      Also, you do realise that portability means that the code has to work on all C++ compilers, right? You can't just go and tell a customer "sorry, your compiler is not the latest alpha version of GCC, go away."

      There are only a few extant C++ front ends these days. My code works on two of them (gcc and VC++). I suspect it would work on more as well, as the code is standard compliand and the remaining front end has a good reputation.

      It becomes even more hilarious by the fact that any version of GCC released in the past 5 years, as you seem to recommend, explodes in your face on every oppurtunity and leaves you with hard to find wrongcode cases.

      I dispute your claim. Post a code snippet which goes wrong on gcc 4.1.2, 4.3.0 or 4.3.1 (the ones I have installed). I think you're making stuff up.

      In fact, you've said nothing which hasn't been said 5 years ago. Or 10 years ago. The fact is that C++ is still not a usable language, and I somehow doubt that it will ever be one. It's time to throw it out and start over (or just avoid it like the rest of us do)

      So I have been hallucinating about my job for the last 5 years, then?

      Someone already linked to the C++FQA. The problem is that it'll easily take half a day to read it, and most C++ fanatics just jump on one chapter and yell "OMG WTF HE WANTS GARBAGE COLLECTION WHAT A MORON" and then dismiss it and go back to padding themselves on the back about how good C++ is.

      No, the FQA guy seems to think that GC is the only valid way of doing memory management. Most of his complaints also seem to be about C++ letting you do dangerous operations.

      Anyway, enjoy your mess of a programming language. At least it gives me job security by providing a never ending source of completely broken code to fix.

      You do not understand what job I do. I don't work as a code monkey somewhere fixing my own broken code. I work in a job where I have to solve various problems using whatever tools are around. Noone cares what tools I use or how I use them, as long as the problem is solved. Yet I still use C++ for much of it.

      --
      SJW n. One who posts facts.
    11. Re:Time for the C++ haters to post... by serviscope_minor · · Score: 1

      First of all, I am one of those haters. But you said that and I was reminded about this. A reformulation of the C++ syntax to be parsable by a LALR parser.

      For some reason, the guy decided to change the semantics of switch statements. It seems pointless as it doesn't change parsing anf makes translation between the two syntaxes harder.

      It is unlikely to catch on, though, unless a decent translator is written.

      --
      SJW n. One who posts facts.
    12. Re:Time for the C++ haters to post... by mr_mischief · · Score: 3, Funny

      To be fair, the majority of complaints you hear about most programming languages on Slashdot are complete bull. People complain about the ones they don't like or don't know well enough and praise the ones they do like.

      Once in a while you'll get someone who admits their pet language has faults and warts who explains why they use it anyway. On rare occasions, you might even hear someone say that a language they dislike has their language beat in some way or another. None of these are the rule, though.

      Personally, I think of the C family of languages as an actual family... The patriarch C is somewhat portable macro assembly all grown up with some new tricks his dad never knew. C++ is C's little brother on steroids, complete with the unsightly rippling veins and man boobs. Java is C++ castrated and off the juice. Perl is the awkward bastard child of C and sed with a great skill for vocabulary but a wild of ADHD. C# is Java's soap-opera style evil twin. Objective C is C++'s hot female tree-hugging cousin from northern California who can't quite understand why the family always bickers and can't just get along. D kind of married into the family (probably to Objective C) and brought in a bunch of non-C things back to a style that suits C pretty well, even if he is a young punk. Cmm is the weird survivalist uncle none of C's kids, nieces, and nephews really want to spend time with at the holidays.

      It's a pretty dysfunctional family, but on some level they all belong together. They're not as sophisticated as the Lisp family down the street. They don't coordinate as well as the Concurrents. The Pascal and Modula clan talks a lot more and is stricter with their rules. The C family just keeps getting useful work done, though, and that's why people keep coming back to them.

      My primary language is Perl, but then again I'm an awkward guy with a gift for vocabulary and a wild case of ADHD. At least I know who my father is.

    13. Re:Time for the C++ haters to post... by quickbasicguru · · Score: 1

      What do you mean? Common Lisp at least has some good compilers; for example, with proper and sufficient declarations SBCL can compile code that rivals C for speed, at least for numerical code.

    14. Re:Time for the C++ haters to post... by Josef+Meixner · · Score: 1

      Let's see what C++ is missing. C++ vs Ruby, Python, 1. No REPL in c++. For a large project, it takes a while to try out an algorithm.

      Not in C++, but in VS is the ability for incremental compilation. But honestly I think it is one of the worst things to use to program. It leads to the "hmm, lets use -1. Nope, +1? Yes, it works. That has to be correct then" approach which leads to terrible code which is adapted to exactly one example data set. REPL is not needed in any programming method I am familiar with.

      That is something I sure don't miss at all and I have programmed in Smalltalk which at least has a much more powerful version of that idiom. Sorry.

      2. Generators && Closures && lambdas

      Lambdas will be in C++0x (hopefully). Closures would probably violate one of the fundamental principles of C++: "If you don't use it, you don't pay for it". Generators (if you are talking about what I think you are) would need the ability to dynamically extend the program. Apart from the obvious security problems that can pose, it doesn't sound as if there was any way to add that to C++ in a way the standard could describe, as it would depend on linker semantics of the underlying OS (if you even have an OS) and that traditionally isn't specified in a C++ (or C) standard.

      3. Strong "reflection" capabilities too, which means that code can inspect, load and modify other code (in Java, C# too).

      That is a rarely needed capability in my opinion and has the same issue as "Generators". C++ is and was not intended to be able to modify its own code. Though a way to access typing information at compile time would often help with templates and so some new things in that respect are also in the draft for C++0x.

      LISP and C# has the above, plus 1. Static Typing

      As is C++. Or is that one of those philosophic things that C++ has cast operators allowing to interpret anything as anything else? That is a result of the intent to still maintain the ability to work very close to the hardware. But apart from a problem with static_cast (downcasts in an inheritance hierarchy) the "new" casts will not violate the static typing or at least tell you they do and in what way.

      2. LISP possible has the more generic syntax conceivable, and code can extend the language to suit the domain. A consequence of Code itself being Data. 3. Concurrency (one of those things 0x is supposed to solve) is simpler in a language which supports functional programming.

      Concurrency is only simpler in a pure functional language (side effects free), so Lisp doesn't belong in that category either (because of "let"). And side effect free languages have big problems to define interaction with some kind of UI. There is no free lunch.

      So basically your complaint is, that C++ is not LISP. So why don't you just program in Lisp then and instead want to turn C++ into something unthinkable? Or can you imaging working in a language where you can cast a pointer to a lambda function into a char*, add 5 to that pointer and cast it again to access the second statement in the lambda function?

    15. Re:Time for the C++ haters to post... by bill_mcgonigle · · Score: 1

      What do you mean? Common Lisp at least has some good compilers; for example, with proper and sufficient declarations SBCL can compile code that rivals C for speed, at least for numerical code.

      And many people claim that python is a subset of Lisp. I wonder if that's so why nobody has compiled python to Lisp so you could use one of those good compilers.

      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    16. Re:Time for the C++ haters to post... by bill_mcgonigle · · Score: 1

      The hating will be generally based around misconceptions or problems that are 5 years old.

      I recognize several of these since I learned C++ in 1993, on Symatec C++, then g++. It wasn't pretty. I found perl the same year and limited my exposure to static languages to performance and kernel interfacing from there on.

      But I digress, the question I really wanted to ask is what was so special about 5 years ago? That's a good 25 years into the language, and a decade and a half after the first go at standardization. One would not expect massive problems, say, a decade after Stroustrup, 2nd Edition. I realize STL came later, but why would the language itself be in such disarray? And they're doing another rev next year? Is it starting over with 5 more years of pain then?

      --
      My God, it's Full of Source!
      OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
    17. Re:Time for the C++ haters to post... by chthon · · Score: 1

      And code generated by SBCL is as fast as C++, but unfortunately does not fit in an embedded system.

    18. Re:Time for the C++ haters to post... by Kent+Recal · · Score: 1

      Oh, many people already have ditched it and the number is only increasing.
      The approach to performance critical applications nowadays is to write them in a high-level language and optimize only the relevant parts with inline C (or asm if you're so inclined).

  43. Confucius say by Profane+MuthaFucka · · Score: 1, Troll

    Confucius say "Those who do not understand Lisp are doomed to reinvent it - poorly."

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

      Confucius also say "Those who do not understand different programming paradigms are bound to start flamewars for no reason."

    2. Re:Confucius say by tom1974 · · Score: 1

      You've been quoting Confucius the past 3000 something posts, is this some kind of study you're conducting?

  44. Re:It hurts you to learn C++ is still being used. by Hognoxious · · Score: 2, Funny

    I have on numerous occasions...and you know what? It was just as slow in Java.

    Fixed that for you. Maybe it's how you program?

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  45. Re:It hurts you to learn C++ is still being used. by FishWithAHammer · · Score: 4, Insightful

    You do know that you don't have to screw around with any of that in a managed language, right? "Very easily make the different processor needs compatible" my ass--Java/C# do it on their own.

    --
    "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
  46. Re:It hurts you to learn C++ is still being used. by pherthyl · · Score: 1

    and with the benefit of 7 years of professional C++ development, I can say with a straight face that it is the wrong tool for every job.

    Just goes to show that no matter how experienced you are, you still have things to learn.. I program in C++/Qt full time at work, and for my side business. I did some years of Java, and every time we eventually ran into performance problems. Not to mention terrible platform integration. So I use C++ with a good cross-platform class library (Qt). No performance problems, just as easy to program as Java (although eclipse is nicer than most C++ IDEs), cross-platform, and integrated much better into any platform than Java is.

    C# is right out, since it's not cross-platform. Any scripting language is not suitable for large scale apps (and performance is a problem). C is way too low-level to be productive compared to OO languages.

    You used C++ for the wrong jobs, or used it with the wrong class libraries (MFC for example). Sucks for you, but if you use the right tools it just can't be beaten.

  47. And then there was one by synriga · · Score: 1
    Much like in Demolition Man where in the future all restaurants are Taco Bell, in the future there will be only one programming language.

    Thank the maker that I won't live to see it.

  48. Re:It hurts you to learn C++ is still being used. by ratboy666 · · Score: 1

    Sure - pick a reasonable Scheme implementation. Something like Gambit www.iro.umontreal.ca/~gambit/

    Full number tower. Reasonable compiler. Sane syntax and semantics. Templates for performance? Sure, just partially specialize functions. Since functions are first-class, you CAN operate on them (just like templates, but without losing your mind). Macros that work, and, if you REALLY like infix notation, Gambit support "six" syntax -- a C-like syntax for Scheme.

    Compile your code when you are done (both an interpreter and a compiler). Need MORE optimization? Drop in C bits; right in-line with the Scheme code. Or, for "better-than-C" compilation, move to Stalin. en.wikipedia.org/wiki/Stalin_(Scheme_implementation) Possibly the most aggressive optimizing compiler in (common) use.

    Back to you -- why C++?

    --
    Just another "Cubible(sic) Joe" 2 17 3061
  49. C++ has one major problem by Barnett · · Score: 5, Insightful

    C++ is an extremely powerful programming language and that is why I use it every day. But it has one major problem: It is too complicated. As long as you do programming full time you are OK but if too much of your time is spent on the application side of things you quickly get in trouble. This is what people like BS don't seem to get - not everyone can spend 100% of their time studying the language.

    1. Re:C++ has one major problem by noidentity · · Score: 1

      As long as you do programming full time you are OK but if too much of your time is spent on the application side of things you quickly get in trouble.

      Examples?

    2. Re:C++ has one major problem by Barnett · · Score: 1

      Whenever I need to take a break from C++ development for more than a month or two I find myself having to dig into the reference manuals when I get back. This can get very time consuming and frustrating. Let me use myself as an example. I have spent the last 15 years as a full time C++ SW developer and yet there are still things about the language that I do not fully understand. But that has not stopped me from creating successful C++ applications. All I am saying is that the language is too complicated for *real world* SW developers.

    3. Re:C++ has one major problem by mr_mischief · · Score: 1

      I'm sure there are parts of your native natural language you don't fully understand. There's too much to know in most languages that anyone would know all the vocabulary, tenses, voices, spellings (especially with ideographs), idioms, slang, connotations, and etymologies perfectly without a reference or at least a doctorate in the language. Yet we tend to use subsets of the natural languages very effectively. Some people have massively larger subsets of their native natural language mastered than others and still they use a reference from time to time.

    4. Re:C++ has one major problem by noidentity · · Score: 1

      I was looking for concrete examples of "getting into trouble", because often such things are due to misunderstanding of the library/language, rather than inherent problems.

    5. Re:C++ has one major problem by Barnett · · Score: 1

      Consider:
      std::string s = "abc";
      s.find( 'b', 1 ); // OK, returns 1
      s.find( 'b', 2 ); // OK, returns npos
      s.find( 'b', 4 ); // Runtime error
      s.find( 'b', 3 ); // ???
      Is the last one safe or not? If you use this function all the time you will know the answer. None of the reference manuals that I have can give me a quick answer.

    6. Re:C++ has one major problem by Barnett · · Score: 2, Interesting

      I spend a lot of time on analysis and design. By the time I get down to programming a few months may have past since my previous project. That is the problem. Are you suggesting that C++ programmers should only do full time coding and let other people do the analysis and design work?

    7. Re:C++ has one major problem by noidentity · · Score: 1

      Since I don't use string::find much, I'd guess the last one is valid, since a "past-the-end" index is a useful value to allow (in quotes since pos isn't technically an iterator). Reading the 2003 standard (ISO/IEC 14882:2003(E)) section 21.3.6.1, it seems all four are valid, with the last two returning npos, since no value can be found that satisfies pos<=result and result+1<str.size(), and the function has no preconditions listed. Are you saying that some implementations don't merely return npos for the one you have marked "runtime error"?

    8. Re:C++ has one major problem by Barnett · · Score: 1

      No, you are right, all four are valid and return npos. I must have been confused again. Go figure.

  50. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 5, Insightful

    No, the "premature optimization" thing applies to all areas. Especially areas where it's never fast enough.

    Why? It's simple: resource management.

    You have X amount of resources to put into your product. X is always finite. It's kind of tough to measure X, but you can think of it as lines of code, man-years, or even just dollars. The amount of resources you have varies a lot depending on your budget, how much time you have, and the quality of the programmers you have. But the important thing is that X is always limited.

    Now you have two approaches:

    1. Spend X on making the code fast from the start, and keep spending X until you run out.
    2. Spend X on making the code functional and with good design. When appropriate (i.e. when the design is good and the code works), start spending X on making the program go faster. Keep spending X on speed until you run out.

    Paradoxically, I hold that #2 will produce a faster program. This is because the X you spend on making the program faster in #2 will be more effective, because you've already laid the groundwork for it. It's always difficult and time consuming to optimize code that doesn't even run yet. It's much more efficient to optimize code that already works. So the result, even though you spend less X on speed, is a faster program.

    Think of it as transporting a lot of material into the wilderness somewhere. If you first spend some of your resources on building a road, you'll get the job done for less time and money than if you just start hauling stuff into the woods immediately.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  51. To all the C++ haters by Palshife · · Score: 1, Insightful

    You're doing it wrong.

    --
    Attention deficit disorder is a complicated issue, spanning several major... HEY LET'S GO RIDE BIKES!
    1. Re:To all the C++ haters by jejones · · Score: 3, Funny

      Please elaborate; I'd like to hate C++ more effectively.

  52. auto rocks by ultrabot · · Score: 5, Interesting

    The new "auto" declarations really fix one of the biggest gripes with C++. Everybody is dead tired of doing


    std::map::iterator it = m.begin()

    Now you can just do:

    auto ip = m.begin()

    It takes much of the pain away from static typing...

    --
    Save your wrists today - switch to Dvorak
    1. Re:auto rocks by TomorrowPlusX · · Score: 1

      I will not miss all the typedef'ing I do to keep my iterators sane. I'm looking forward to the new for loop which automatically handles containers as well.

      It blows my mind when a simple for loop declaration ends up more than 72 chars long.

      --

      lorem ipsum, dolor sit amet
    2. Re:auto rocks by jonaskoelker · · Score: 2, Insightful

      std::map::iterator it = m.begin()

      That'd be "map<signed short int, unsigned long int>::iterator it = m.begin()". And you can write "using namespace std;" instead of "std::", saving a net minus 15 characters ;)

    3. Re:auto rocks by ultrabot · · Score: 1

      Yeah, but I added an apology as an AC. And of course "using namespace" is a cardinal sin ;-)

      --
      Save your wrists today - switch to Dvorak
    4. Re:auto rocks by smellotron · · Score: 1

      From the boost multi-index tutorial: typedef multi_index_container< employee, indexed_by< ordered_unique<identity<employee> >, ordered_non_unique<member<employee,std::string,&employee::name> >, hashed_unique<member<employee,int,&employee::ssnumber> > > > employee_set

  53. Re:It hurts you to learn C++ is still being used. by YodaToad · · Score: 1

    A couple questions for you then:

    1. If it was already written in one language why did you rewrite it in the other?
    2. If it wasn't written in both languages how would you know it was just as fast?

    If you really did write it in both languages I'd be surprised if it really was the "large program" the grandparent was talking about.

  54. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    Wow, I don't know what I wrote to deserve such a response.

    Speaking from my own personal experience, developing anything sizable in C++ takes much longer than in other languages. Maybe there are C++ gurus out there for whom this is not true. If so, good for them. It does not change my situation. For me, C++ is the wrong tool for the job, end of story. You don't have to agree with that, or even like it, but you ought to at least respect it.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  55. Programmable Programming languages. by IdeaMan · · Score: 1

    Building a self-consistent rule set as complex as a parser/compiler combination takes years and years of work to get it right. And you're saying leave that to the programmer??? That's the biggest maintenance nightmare I have EVER heard of.

    It's bad enough that a new programmer has to learn the application idiosyncrasies; throwing in the fact that every instance of the language is fundamentally different would at least double the length of the learning curve.

    I do however see the appeal of having a common syntax for several different styles of programming schema. Imagine having one punctuation set and operator set for a language that can be either script-like (no typing system), strongly typed, garbage collected, etc, and have it all inter-operate. I just don't think it should be left to the whims of some dude in the back room that would never document his intent and execution properly.

    If you do go ahead and write it, I nominate Female+- as the name (see http://www.anvari.org/fun/Gender/17_Female_Rules.html )

    --
    They ARE out to get you simply because They are in it for themselves and they don't care about you.
  56. Re:It hurts you to learn C++ is still being used. by Tenrosei · · Score: 1

    How can you blame a language for shitty programmers. They shouldn't be called programmers if they need a syntax to hold their hands and say oh you didn't set this pointer to a reference so I won't run it please fix it. People that can't handle the raw power shouldn't receive it in the first place. I say ban people from using c++ if they can't handle it.

  57. MMIC!!! by starglider29a · · Score: 1

    Great! That means in 2099, will have another "man made crisis" when C++99 is being superseded by C++100!!!

    Or will we count by Hex? C++0x0x63?

    Hopefully, we'll be up to "D" by then.

    1. Re:MMIC!!! by schwaang · · Score: 2, Funny

      Not to worry. As a result of the nuclear launches following the panic resulting from the 2038 Unix date rollover, the remaining cockroach hordes will not evolve sentience until at least 2105, thus avoiding the 2099 crisis completely. So it's all good.

  58. Some counterpoints. by warrax_666 · · Score: 3, Insightful

    1. Boost.
    2. Nonsense. Boost has facilities for this ("any", iirc) and also for something called "sum" types which can achieve what you want in a better way ("variant", iirc).
    3. shared_ptr, weak_ptr.
    4. Yup. Going to be fixed by C++0x.
    5. C++ can be written to be a lot more portable than your Ruby or Python.
    6. A matter of taste.

    --
    HAND.
    1. Re:Some counterpoints. by Free+the+Cowards · · Score: 5, Interesting

      Counter-counterpoints:

      1. Boost is an external library, and from my very limited experience none too easy to incorporate.
      2. Likewise, an external library. But putting that aside for a moment, what's the C++ equivalent to this python code?
        d = {"name":"Bob", "age":42}
        print "Name is %s and age is %d" % (d["name"], d["age"])
        Keep in mind that this is a complete python program, no further code is required.
      3. While those are handy, they don't substitute for a real garbage collector.
      4. I hope you're right, but I'm skeptical. Massive template instantiation errors seem to be a compiler problem, not a spec problem.
      5. Key words being "can be". It's tough to do, especially since the compilers out there almost never comply perfectly with the spec.
      6. Of course it's a matter of taste, I never said otherwise.
      --
      If you mod me Overrated, you are admitting that you have no penis.
    2. Re:Some counterpoints. by FooBarWidget · · Score: 2, Informative

      Now you're just being unfair.

      1. I found it pretty easy. Most Boost libraries are header-only so you only need to put the relevant header files in your project, adjust your header search path, and you're done.
      2. Your example hasn't got much to do with C++, and everything to do with static vs dynamic typed languages. The C++ version will be about the same size as the Java and C# versions.
      3. Uhm sorry, "real garbage collector" and "Python"? You do know that Python uses reference counting, right? Just like shared_ptr and weak_ptr. shared_ptr is really nice; I've been using shared_ptr for a while now and most of the time I don't even have to think about memory management.
      4. No comments.
      5. This is the only point that I disagree with the parent. Python and Ruby tend to be more portable. I've seen my share of cross-platform C++ compilation errors, some which are easier to fix than others.

      Still, if you're writing system software (e.g. a web server, daemon control software, filesystem indexer, etc) or large desktop software (Photoshop, Microsoft Word, KDE), then it would be madness to choose Ruby/Python over C++.

    3. Re:Some counterpoints. by ultrabot · · Score: 1

      5. C++ can be written to be a lot more portable than your Ruby or Python.

      Care to elaborate on that? I have hard time thinking how python code becomes unportable.

      --
      Save your wrists today - switch to Dvorak
    4. Re:Some counterpoints. by Kevin+Stevens · · Score: 5, Insightful

      Boost has in many eyes really transcended from "just an external library" to an integral part of the C++ platform. It compiles on every major platform, and it is open source.

      Boost is moving C++ forward at a rate 10x that of the standards committee. I am not sure why you felt integrating it with your project was difficult- it is header only for the most part and does not require you to use any specific pieces. Shared_ptr's, which are the most useful library of all, do tend to be viral in the sense that you have to use them everywhere, but this is a GOOD thing.

      If you are doing C++ without Boost these days, you are really missing the boat.

    5. Re:Some counterpoints. by Free+the+Cowards · · Score: 1, Interesting

      I'm not being unfair, I'm explaining why I use what I use.

      1. It's still an external library, not built in. And even ignoring that, I couldn't find any indication that Boost implements some pretty basic things like URL fetching or data compression. I could be wrong.
      2. Since C++ is not a dynamically typed language, how can you say that it has nothing to do with C++? Newsflash: I don't like C++ because it's not dynamically typed.
      3. Python uses reference counting with a cycle collector. This makes an enormous difference. Plain old refcounting is just a memory management aid, whereas adding cycle collection gives you a full-up garbage collector.

      And on for your last point, if I were writing a web server then I probably would do it in Python, since any web server I write is almost certain to be I/O bound, not CPU bound. I have no idea what a daemon control program would do that would require using C++; it sounds like a pretty simple and performance-unintensive thing to me. And large desktop software is exactly where dynamic, duck-typed, true OO languages shine. Note that Adobe wrote a significant chunk of Lightroom in Lua, just as one example.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    6. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      It's pretty simple, really. There are a lot of platforms which simply do not have a Python implementation, period. Just to pull out one random example, you can write C++ on a Lego Mindstorms brick, but good luck squeezing a Python implementation in there.

      C++ goes just about anywhere that C goes, and Python is necessarily limited to a subset of where C goes due to being implemented in C. Now, if all you're doing is Windows and UNIX-alikes, this doesn't matter so much, but C++ can be a lot more portable depending on exactly what you're writing and where you want to run.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    7. Re:Some counterpoints. by Tychon · · Score: 2, Informative

      Any modern project in C++ that does not involve embedded hardware should be using Boost, period. C++ without Boost is like a marathon without legs. Incorporating it is a piece of cake, and it adds so much functionality that you'll wonder how you managed without it. On top of that, it's so widespread that support for it is quite common. It's even to the point that the new standard is actually stealing bits and pieces from it.

    8. Re:Some counterpoints. by immcintosh · · Score: 4, Insightful

      First off, if you have a problem with using external libraries, then you just won't get anywhere with a C/C++. They are VERY general purpose, and intentionally so, and the whole idea is that implementation specific things are supposed to be provided in libraries, rather than the core language. That said:

      1. Boost is actually very easy to integrate for most of its features. A few (small handful) of its components require compilation, but the vast majority of them are template-based and header only. Meaning just include a header file and there you go, you're using boost. No extra compilation/installation required.

      2. This kind of thing is GREAT for doing small scripts, but HORRIBLE for doing large complex applications where type safety can be VERY important for avoiding bugs. If all you ever do are small, quick, limited scripts, then you're absolutely right that you should avoid C++, that's certainly not what it was meant for, and not so much the domain of a strongly typed language. For things like the software that runs large financial institutions and whatnot, there's a reason code like that should be avoided at all costs.

      3. I have trouble imagining a situation where a real garbage collector would ever be superior to an RAII model with shared smart pointers for stuff allocated on the heap, outside of plugging up a leaking legacy app. Maybe for very simple programs, but once you get non-trivial destructors (for example, with objects that lock system resources), then you start having to do manual memory management in your GC environment anyway, and end up with a horribly ugly conglomeration of "mixed metaphors" as it were. Smart pointers really give you the best of both worlds: deterministic destruction, without having to worry about manually releasing anything. It's just a matter of getting used to declaring a smart pointer wherever you would have a "type *name" instead. So yes, I'd argue they ARE a substitute for garbage collection in almost any situation.

      4. Sorry to be blunt, but you should probably RTFA on this one. The problem is solved through "concepts," which is the part of the new specification which deals with this specifically. It's essentially a C++ implementation of the "design by contract" metaphor.

      5. In this case "can be" equates to "do whatever you like and it'll be portable on all major general purpose computers, and who uses Ruby or Python on embedded platforms anyway?" If you are able to compile with GCC, which is the case for pretty much every computer/OS combination in existence, then you can count on it being pretty damn portable. If you are programming for something like an ATM or a set-top box, then you probably aren't going to be using a high level scripting language anyway.

      6. Yeah, it can get ugly. Thankfully this will be largely fixed with the "auto" keyword in C++0x.

    9. Re:Some counterpoints. by Haeleth · · Score: 2, Informative

      what's the C++ equivalent to this python code?
      d = {"name":"Bob", "age":42}
      print "Name is %s and age is %d" % (d["name"], d["age"])
      Keep in mind that this is a complete python program, no further code is required.

      Easy:

      #include <string>
      #include <iostream>
       
      struct d_type {
          std::string name;
          int age;
          d_type(const char* _name, int _age) : name(_name), age(_age) {}
      };
       
      int main() {
          d_type d("Bob", 42);
          std::cout << "Name is " << d.name << " and age is " << d.age << std::endl;
      }

      The syntax is, I will grant you, somewhat on the verbose side, but it should illustrate the point, and the difference becomes less significant as the program scales.

      (Yes, I know I'm using a different data structure. That's kind of the point: just because Python implements records as dictionaries doesn't mean that languages without heterogenous dictionaries can't do records.)

    10. Re:Some counterpoints. by gbjbaanb · · Score: 1

      re: point 1, why stop at URL fetching or data compression? I needed an interface to a DS1000 serial-port call logger today, do I complain that Python doesn't have such library routines to handle that?

      Ok, so maybe that's slightly obscure .. but why not SOAP libs, or JSON libs, or .. well I could keep going. I think you're being unfair expecting a language to provide you with domain-specific functionality. Similarly with compression - which one would you expect to be present? C++ sticks things in libraries, so you can use whichever you want if you can find one, or write your own if not.

      point 3: isn't a GC just another memory management aid?

    11. Re:Some counterpoints. by Haeleth · · Score: 1

      And large desktop software is exactly where dynamic, duck-typed, true OO languages shine.

      So why are so few of them written in such languages? In practice, the vast majority of large desktop software applications are written in, um, C++. Does that not tell you anything?

      Note that Adobe wrote a significant chunk of Lightroom in Lua, just as one example.

      Some 40%, yes, covering most of the application logic (the raw processing code is C++, the database interface C). It's an impressive achievement, and no doubt other companies are watching with interest.

      However, it's closer to "the only example" than "just one [of many]". I certainly can't think of any others, though maybe you know of some?

    12. Re:Some counterpoints. by Anonymous Coward · · Score: 5, Insightful

      It is the discussion. Judging c++ with boost excluded is like judging perl with CPAN excluded. Who cares whether it's "part of the language" or not? Everyone who uses the language seriously uses them, and they're critical to understanding how the language is used effectively.

    13. Re:Some counterpoints. by Free+the+Cowards · · Score: 3, Insightful

      Again, I don't think I'm being unfair, I'm just saying why I use what I use. Python provides more libraries for the stuff I use than C++ does. "Batteries included" makes my life easier. Maybe this isn't fair to C++. So what if it's not? Should I make my life more difficult by using C++ out of a sense of fairness?

      As for GC goes, no, it's not "just another memory management aid". Non-GC versus GC is the difference between having to think about memory management and not having to. Automatic refcounting still forces you to manually find and break reference cycles, and garbage collection does not.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    14. Re:Some counterpoints. by Free+the+Cowards · · Score: 2, Informative

      Well, something in the range of 99% of the desktop applications available on Mac OS X are written in a duck-typed true OO language.

      I hold that the main reason that C++ is used so much for large desktop applications on Other Platforms is inertia, pure and simple. Programmers hate change. I realize that this is a purely a statement of opinion and I have no way to back it up.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    15. Re:Some counterpoints. by twistedcubic · · Score: 1

      2. Likewise, an external library. But putting that aside for a moment, what's the C++ equivalent to this python code?
      d = {"name":"Bob", "age":42}
      print "Name is %s and age is %d" % (d["name"], d["age"])
      Keep in mind that this is a complete python program, no further code is required.

      #include<map>
      #include<string>
      #include<iostream>

      using namespace std;

      int main()
      {
              std::map<string,string> d;
              d["name"]="Bob"; d["age"]="42";
              cout<<"Name is "<<d["name"]<<" and age is "<<d["age"]<<endl;

              return 0;
      }

      Oh, but you might say, 42 is an integer, not a string. There are simple workarounds, but here's a better suggestion.

              struct Person {
                      Person(string n, int a): name(n),age(a) {}
                      string name;
                      int age;
              };

              Person D("Bob",42);
              cout<<"Name is "<<D.name<<" and age is "<<D.age<<endl;

      Note how the Person object can be re-used. To create another, I just write

      Person E("Alice",27);

      This is shorter than your cute example. But these comparisons are silly anyway.

    16. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      It's supposed to be an illustration, not a comparison. What I really wanted to see was how this boost::any thing gets used to give you the same capabilities. I went ahead and googled up the docs and found the examples, and it looks like a poor, verbose substitute at best.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    17. Re:Some counterpoints. by ratboy666 · · Score: 1

      A bit, um..., twisted.

      Any platform that has a C compiler can run Gambit-C (Python is in the same "class"). Of course, some platforms may be... to anemic to support Scheme. But, the proof in the pudding is TinyScheme, and LispMe (TinyScheme is a very small, VERY portable implementation of a Scheme interpreter, and LispMe is a Scheme implementation on a 68000 Palm platform).

      Python is ALSO available on the 68000 (Palm) -- Pippy is the name of the implementation.

      So, for some data points - both Scheme and Python have at least one (for reference) implementation on the 68000. I am not sure if I can pull this back to 16 bit addressable platforms (z80 et al) or 20 bit platforms (8086). But this doesn't really matter these days.

      Indeed, even SNOBOL4 from the 60's is portable -- now that we have a reference C implementation (SNOBOL-C). This implementation implements the macro base in C, making it portable to machines with a sufficient address space. All of these systems (Scheme, Python, Snobol4) run on 32 bit x86 little-endian Linux, and 64 bit Sparc big-endian Solaris. Portable enough?

      Now, C++ is "tricky" to get right. The compiler needs to be almost insanely well-done in order to optimize. It is VERY hard to be introspective on code (C++ = practically impossible, without actually implementing the compiler, Python = merely hard, SNOBOL4 = easy, but a bit weird, Scheme = easy, bordering on trivial).

      It is almost impossible to look at C++ code in isolation, and determine what it does, let alone if it is correct. It is hard to write a compiler for the language. It is very difficult to optimize.

      And, the bits that NEED optimization can be (almost) as easily expressed in C.

      The "difficult" run-time systems for the other languages are already proven on systems ranging in performance over several orders of magnitude, and are (normally) expressed in C.

      Again, why C++?

      --
      Just another "Cubible(sic) Joe" 2 17 3061
    18. Re:Some counterpoints. by drxenos · · Score: 1

      in C++0x:

      int main()
      {
      auto d = std::make_pair("Bob", 42);
      }

      ignoring the needed headers.

      --


      Anonymous Cowards suck.
    19. Re:Some counterpoints. by lgw · · Score: 1

      All of the reasons to use Python are found in its wonderful collection of freely available modules. Few of those are "part of the language". Who cares? It's what you can do with the well-tested, easily-available tools associated with a language that matter.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    20. Re:Some counterpoints. by Free+the+Cowards · · Score: 2, Interesting

      Twisted? I wasn't talking about a 68000 or a Palm. I was talking about an embedded microcontroller with a grand total of 32kB of RAM. About half of that is left to hold both program and data once the kernel gets done taking what it wants. Can you fit Python into 16kB of RAM for both program and data, and still have enough space left over to do anything useful? I'll be very interested if your answer is "yes", but I'm doubtful.

      Don't get me wrong, I'm a huge advocate for higher level languages. But there are certain places that C can go that others can't simply because C is really just a user friendly assembly language. And C++ may be difficult to compile, but the end result of its being built on top of C is that it goes nearly anywhere that C does.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    21. Re:Some counterpoints. by Free+the+Cowards · · Score: 2, Informative

      It's the difference between being able to type "import", and having to search, download, compile, and pray. As for few modules being part of the language, every example I listed is built in to Python.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    22. Re:Some counterpoints. by gbjbaanb · · Score: 1

      Fair enough about Python libraries, but my point wasn't about bundled libs, its libs that are available. If you had every python library available in a c++ package, would you still consider c++ lacking in this way? Those libs are available, you may have to use google a little to find them though :)

      ah no. GC doesn't allow you to stop thinking. Otherwise you get 'soft leaks' (ie objects still referenced when you think they're deleted), non-memory resources hanging around when you'd rather they were collected, memory buildup that does affect performance when it comes to cleanup, application hang while the GC does its work, to name the few I can think off off my head.

      You even need reference counting in some cases - see SafeHandle in .NET for one they had to put in.

      RAII is the design pattern you want.

      If you think GC provides a silver bullet for your memory management problems, you're going to be disappointed one day. Just ask the Princeton university DARPA challenge team what they think.

    23. Re:Some counterpoints. by ratboy666 · · Score: 2, Insightful

      For 32KB systems, I would recommend either absolute assembler, or program conversion - higher order to lower order (subset Scheme to assembler, and possibly TinyScheme). Even C is excessive, but possible. C++? Unless you have absolute control on template production, I would doubt it.

      Simply because using the STL and making a SINGLE type change can result in inclusion of thousands of bytes of code (as the templates instantiate). Example: modify a short vector to a long int vector on the platform. The machine code will now have to include math libraries, and all the overhead of instantiating. Easily 30KB, which then blows out your 16KB deliverable.

      And, it isn't possible to put source level checks in place to prevent this.

      Yes, C is a "high level" assembler (low level language), but is better suited for this type of development. Now, the code being targeted at this platform typically DOES NOT HAVE TO BE PORTABLE. Normally, every byte has to be accounted for anyway, making absolute assembler very practical. None of the higher order C++ constructs are useful, because abstraction is simply not a consideration on these platforms. C is useful, because it is easier than learning yet another assembler. Scheme can be useful, because it is easy to generate a subset compiler yourself to the target platform. (more people can do the Scheme, than can successfully generate a C compiler).

      Back to "portability": In this space the following code would make a lot of sense, and is considered "portable"

      #define BASE 0x7000
      #define STATUS (BASE+1)
      #define READY 0x0001
      #define NOTHING ...
      char *status = (char *)STATUS;
      while ((*status & READY) == 0)
          NOTHING; ...

      (but there is no timeout implemented, this was just an example).

      My CV in this area: biometers, micro-controllers (SCSI, other), heads-up displays, etc. And with ALL systems in the 64KB and less capacity, I have NEVER been asked to do C++. Nor have I ever recommended it. I would be curious if there have been success stories in this particular space.

      --
      Just another "Cubible(sic) Joe" 2 17 3061
    24. Re:Some counterpoints. by Anonymous Coward · · Score: 1, Interesting

      Still, if you're writing system software

      (e.g. a web server,

      I tend to agree, but the folks at Plone and Zope would probably disagree. That's easily one of the most powerful CMS packages, with the only competitor in the same league being Typo3. On the other hand, Django recommends bog-standard Apache.

      daemon control software,

      I have no idea why you think daemon control software needs the performance of C/C++.

      filesystem indexer, etc)

      I've actually written a filesystem indexer in Python as part of an image management program (think ACDSee). Obviously the hashing algorithms and performance critical parts are written in C/C++, but there is no reason not to write the rest in Python. You spend most time waiting for the disk I/O...

      or large desktop software (Photoshop, Microsoft Word, KDE),

      Again, the only one of those that shouldn't be written in Python is KDE (parts of it could be). Image-handling code should be written in C/C++, but the GUI doesn't need to be. My (currently unreleased, but fully-functional) image management program is faster than ACDSee, which has more to do with loading the GUI without blocking waiting for the image to load than it does with using C++. It also uses less memory because I only load the thumbnails that are displayed on screen into memory... Actually it blows the old-school application ACDSee out of the water for performance. Again, for image manipulation, I would use a C/C++ coded image library such as ImageMagick, which has bindings for Python.

      then it would be madness to choose Ruby/Python over C++.

      Not hardly.

    25. Re:Some counterpoints. by Free+the+Cowards · · Score: 3, Informative

      Yes, if C++ included the same libraries that Python does, this objection would go away. (Why wouldn't it?) The other objections would remain.

      And no, GC does stop you from having to think about memory management. So-called "soft leaks" aren't a memory management problem, they're just a regular old code bug. GC doesn't save you from all bugs, or even from a particularly large number of them. It mainly just saves you from programming overhead.

      GC also doesn't save you from having to manage external resources as that SafeHandle class does.

      RAII is definitely not the design pattern I want. Believe me, I know what RAII is, and I know what I want, and the two do not intersect in any way.

      I know it's hard to believe, but there are people out there who legitimately do not like C++. Not because we're stupid, or clueless, or because we've been misled, but simply because we have different constraints on our programming or even just different opinions.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    26. Re:Some counterpoints. by mr_mischief · · Score: 1

      If your mantra is "give me more libraries" then perhaps you should look into Perl and CPAN. Let the C++ folks have their language. You're not going to convince them to use Python instead of C++ any more than you're going to be convinced to use C++ or Perl instead of Python.

    27. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      Yeah, that's all well and good, but you seem to be missing my point. I'm not saying C++ is a good choice. I'm not advocating its use. I'm not saying that it will work well or that people use it routinely. All I'm saying is that there exist circumstances where C++ is more portable than these higher level languages, and here is an example of one.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    28. Re:Some counterpoints. by Viol8 · · Score: 1

      "If you are doing C++ without Boost these days, you are really missing the boat."

      Please explain a programming problem this bloated POS solves that couldn't have been solved before. I keep hearing people talking it up without any solid reason as to why other than it seems to be fanboi flavour of the month library. A bit like ACE was 6 years ago. Wheres that now?

    29. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      I don't know why I'd look into Perl and CPAN. I already have Python and Cocoa.

      I'm not trying to convince anybody. A guy asked why people find C++ so difficult. I answered him, and the discussion grew from there.

      If you like C++, fine. Good for you. But accept that some people prefer other languages.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    30. Re:Some counterpoints. by RogerWilco · · Score: 1

      I actually like a lot of C++, and catching errors compile time is in the end easier as catching them runtime. I also do a lot of Python, and I agree with the other poster that available libraries are a very important part of what makes it good.

      Coming from a Borland C++/Delphi background, which also provided a lot of libraries, bare-bones g++ on Linux needs a lot of finding libraries, and then getting them onto the machines my code needs to run on. Boost, Qt and friends bring you a long way, but if the target machine has it, then it still might be an incompatible version.

      I find Python libraries often being much nicer in up and downward compatibility than their C++ counterparts. Also because if one is compiled with a different compiler (version) you also easily end up with problems.

      --
      RogerWilco the Adventurous Janitor
    31. Re:Some counterpoints. by Viol8 · · Score: 1

      Who modded this drivel informative? Boost has its place, its place is not in every single C++ program that is ever written. You might as well say that the STL should always be used no matter what. What a stupid position.

    32. Re:Some counterpoints. by Viol8 · · Score: 1

      "Likewise, an external library. But putting that aside for a moment, what's the C++ equivalent to this python code?"

      Who cares? Show us some python code for a low level device driver? Oh , you can't? Whys that then? Horses for courses perhaps?

    33. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      I don't write low level device drivers. I am merely explaining why I use what I use. I am in no way claiming that my preferences or my tools are universal.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    34. Re:Some counterpoints. by Kevin+Stevens · · Score: 4, Interesting

      It doesn't solve anything that *couldn't* be solved before, but that's not the point, as anything can be solved given enough time and effort.

      But out of the box, without even any compilation needed(!) you can get smart pointer implementations, timers, asynchronous I/O, a multithreading toolbox, conversion libraries, containers, memory pools, and tons more (some would say so much more that its bloated) with the added peace of mind knowing that tons of people out there are using them as well and they are thoroughly debugged. Its worth it for the shared_ptr's alone- those alone dramatically reduce the biggest source of C++ bugs.

      In my previous company, I worked on a system that was about 10 years old- started before the STL came into existence, and long before it was well supported by compilers, and thus the team had spent a lot of time building STL-like functionality with dynamic strings, iterator like functionality, vector/list work-alikes, etc. This meant that now once the STL came around, a programmer familiar with "standard" C++ had to learn how to re-do mundane things like string and container manipulation. Similarly, that team had created smart pointer implementations, logger classes, multithreaded and socket libraries, etc. Boost not only provides all of this functionality, but you get it working right out of the box, and since Boost is well known, you don't have to wait for a programmer to get up to speed for a month or two while he becomes familiar with your code.

      There are some more exotic features that you don't have to use, but I recently used multi_index to implement what is more or less an in-memory database cache in about 100 lines of code. This replaced a lot of code that read records and then threw them into hash maps or vectors using the OrderId as a key, then the CustomerId as a key, etc... so we had fast lookups to our most commonly used objects.

      What are its advantages over ACE? ACE is a great networking and concurrency library, which not all applications necessarily need, and ACE's strong point is multi-platform networking and concurrency, which while I wouldn't call a small niche anymore, can't be used across all applications. At least some of Boost's libraries, most notably shared_ptr, can be used in any C++ program. In fact, until Boost::asio was released relatively recently, I would say ACE and Boost were entirely complementary. Also, boost is more or less a testing ground for the C++ standards committee, so it is more or less "blessed" and can be seen as a Beta for future versions of the standard.

    35. Re:Some counterpoints. by dwarfking · · Score: 2, Insightful

      d = {"name":"Bob", "age":42}
      print "Name is %s and age is %d" % (d["name"], d["age"])
      Keep in mind that this is a complete python program, no further code is required.

      So you don't count the Python runtime as further code?

      These types of examples are meaningless. Any programming language can implement the same functionality, they just use different syntactic sugar to do it. So great, Python allows you to define a dictionary in a single line of text. Doesn't mean you can't define a dictionary to do the same thing in C++, it is just the form looks different.

      But notice that in your language, you had to know that d["age"] is an integer and d["name"] is a string when you built your print method (%s, %d), where as in C++ you could do:

      std::cout << "Name is " << d["name"] << " and age is " << d["age"];

      So does that make C++ better than Python because I the programmer don't have to worry about a which format flag to use? No. Each language offers different types of simplifications based on what the design requirements for the language were. You like Python because you like the language simplifications it provides you. Nothing wrong with that, use what you like and what works for you. But just because another language doesn't provide the same techniques you like in yours, doesn't make it a worse language. It makes it different.

      The bigger point that was made higher up is that C++ lacks the comprehensive consistently available libraries that Java, Python and C# developers get to depend on. Those others should be more viewed as environments for a language, versus C++ which is truly just a programming language.

      Were there to be a common, consistent library for C++, available on all platforms, such as what exists in Java or Python, then C++ developers could have the level of productivity you enjoy from the tools you use and then we would have a good basis for comparison.

    36. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      The Python runtime no more counts as "further code" than does the C++ compiler or standard library.

      As for the rest of it, I just wanted to see what an actual use of boost::any looks like. So far nobody seems to care to provide an example.

      Were there to be a common, consistent library for C++, available on all platforms, such as what exists in Java or Python, then C++ developers could have the level of productivity you enjoy from the tools you use and then we would have a good basis for comparison.

      But the whole point of what I'm saying is that there is not such a common, consistent library, and this is a major reason why I don't like to use C++. It's kind of like asking somebody why they prefer to live in New York instead of Cleveland. They give you some story about how much they like the arts, and how much New York is better for the arts because it actually has a lot of artists and theaters and the like. And then a bunch of people tell him that it's not a fair comparison because Cleveland doesn't have the kind of arts scene that NYC does!

      --
      If you mod me Overrated, you are admitting that you have no penis.
    37. Re:Some counterpoints. by mr_mischief · · Score: 1

      "If you like C++, fine. Good for you. But accept that some people prefer other languages." ???

      Um, wait. Isn't that what I just said to you?

      You're judging languages based on the number of libraries readily at hand. All I suggested is that if that's your killer stat, you might want to consider a language with better numbers on that axis.

      CPAN is not a window system and development toolkit. CPAN is a module archive network, similar to (and the inspiration for) PyPi. There are over 12,200 module distributions on it. Pypi has 4583 packages.

      A quick search on Google didn't give me a strong idea of how many public Pypi mirrors there are, but CPAN has over 250. There are tools to make local bundles of module distributions, or even grab the latest version of every module distribution and keep them in sync for when you have to forgo connectivity, too.

      If you're going to cite metrics as a justification, be prepared to enumerate and defend your metrics. There are C and C++ libraries available for damn near everything. Your language might centralize access to libraries a bit better, but it doesn't do that as well as Perl.

      I'm all for you continuing to work in Python. I personally don't care for the language much as a personal preference. I like many of the projects people who enjoy coding in Python produce, though. If you can fix stuff that irks me in PySol, that's great because then I don't have to. ;-)

    38. Re:Some counterpoints. by recharged95 · · Score: 1

      "It compiles on every major platform, and it is open source."

      Yes, on every major platform's specific version and package installation. Once you start mixing libraries for incompatible hardware and ending up with non-standard releases (i.e. libc), compiling breaks and it's off to the races on fixing incompatibilities, boost included as in some cases I could never fine a working boost version when updaing the kernel or libc, or something else on the dev branches of those packages (for features)... That more common than the exception with the dynamics of OSS.

      I agree with most, that Python is a poor example to compare boost with. C# or Java are much better examples.

    39. Re:Some counterpoints. by Fulcrum+of+Evil · · Score: 1

      I hold that the main reason that C++ is used so much for large desktop applications on Other Platforms is inertia, pure and simple. Programmers hate change. I realize that this is a purely a statement of opinion and I have no way to back it up.

      It's because it works pretty well for writing apps and doesn't need a runtime environment. Why should we change something that works?

      --
      "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
    40. Re:Some counterpoints. by multi+io · · Score: 1

      just because Python implements records as dictionaries doesn't mean that languages without heterogenous dictionaries can't do records.

      The point of the parent's post wasn't doing records, it was doing what you call "heterogenous dictionaries".

    41. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      You seem to have badly misinterpreted what I said.

      I talked about the six reasons why I prefer other languages to C++.

      You somehow decided that I was talking about the one single criterion that I ever use when deciding what language to work with.

      I'd say that I understand how you could have made this mistake, but I'd be lying. I have no idea how you could possibly misunderstand me that badly.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    42. Re:Some counterpoints. by JebusIsLord · · Score: 1

      Okay, you can't program Lego with Python. But you can't program a blu-ray player with C++, only Java. If you're going to get that fine-grained with the word "portable", then nothing is really portable.

      Python runs on ~100% of what we'd call "computers", but you're right; it isn't going to work everywhere. Neither will C++.

      --
      Jeremy
    43. Re:Some counterpoints. by anomalous+cohort · · Score: 1

      I certainly don't agree with point 2. Dictionaries holding entries of different types is not my idea of a good design. When you can't get around it, then may I suggest polymorphism?

    44. Re:Some counterpoints. by smellotron · · Score: 1

      It doesn't matter what language-specific tool was used to solve the problem. What matters is that a problem was solved. Python has dict, and C++ has std::pair and struct for ad-hoc structures.

    45. Re:Some counterpoints. by i_liek_turtles · · Score: 1

      What about this?

      import soul

    46. Re:Some counterpoints. by shutdown+-p+now · · Score: 1

      Well, something in the range of 99% of the desktop applications available on Mac OS X are written in a duck-typed true OO language.

      Really? How many of the larger Mac OS X applications are actually written in Cocoa and not Carbon? I mean stuff like MS Office, Photoshop etc, not small utilities.

    47. Re:Some counterpoints. by twistedcubic · · Score: 1

      As for the rest of it, I just wanted to see what an actual use of boost::any looks like. So far nobody seems to care to provide an example.

      You should probably read that as, "nobody here finds boost::any useful". Kinda like the example you gave, where you use a hash when there are likely better ways to represent what you want. The beauty of C++ is that, even if C++ had such a built-in construct, it would be much less error-prone because of type-checking.

    48. Re:Some counterpoints. by Nova77 · · Score: 1

      1. you are partially wrong:
      here's the compression http://www.boost.org/doc/libs/1_36_0/libs/iostreams/doc/classes/gzip.html
      and URL fetching is coming with the network lib (http://cpp-netlib.blogspot.com/) which aims to be included in the next release.
      2. I had to many troubles with dynamically typed languages. I would (IMHO!) not take that as a plus.
      3. There's no silver bulled with respect to reference counting. Each techniques has pro and cons.

      And I do write web services (or services used by web app.) all the time using facebook's thrift, and CPU is critical for us. Hell, I would not even use java for it!

      But as usual it depends a lot on what you need.

      P.s. Adobe wrote also a speed critical image library which is now part of boost (http://www.boost.org/doc/libs/1_36_0/libs/gil/doc/index.html)

    49. Re:Some counterpoints. by mr_mischief · · Score: 1

      I didn't say it was the only point you made. It's one that you kept repeating, so it appeared pretty important to you. I also didn't say you had to change languages. I just said that if that's really important to you that you might want to investigate a language which is stronger in that area (and which is, other than syntax, pretty similar to Python in most other ways anyway).

      You keep talking past people in the whole thread. You keep assuming things, such as that addressing one point without a bullet list of your other points means I'm not aware that you had other points. These are the signs of an angry zealot or a sloppy reader.

      BTW, most of your points apply to Perl, Ruby, Rexx, C#, and even VB. Some of them apply more to certain other languages than to Python.

      IF you like Python, then bully for you. If you're actually following your points rather than just justifying your decision, you might want to consider other languages as well, because having one language in which to do things is pretty shitty in the long run.

      Go ahead and assume that everyone who points you to new information misunderstands you. It must feel good to your ego to be by far the smartest man on thar inturwebz. I wasn't even disagreeing with you that Python is a nice language. I was just saying there are other options you might want to check out.

      Sorry that pissed you off so much, but I'm not a shrink so I'm not here to help you with rage or insecurity.

    50. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      If you don't define "large" as "written in Carbon", then quite a lot.

      Of the 30 or so applications I'm currently running, perhaps 3 of them are Carbon. Among the large Cocoa applications I'm currently running are Mail, iPhoto, Xcode, Safari, iCal, OmniGraffle, Colloquy, Adium, and NetNewsWire. The large Carbon applications I'm running are Finder, iTunes, and Firefox.

      Pretty much universally, the large Carbon apps exist due to old codebases or a strong need for keeping as much common code as possible when porting to the platform. And I'll note that even Firefox has gone Cocoa with version 3.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    51. Re:Some counterpoints. by Free+the+Cowards · · Score: 1

      Oh look, it's hay cutting season. You can get some more straw for those straw men!

      --
      If you mod me Overrated, you are admitting that you have no penis.
  59. Re:It hurts you to learn C++ is still being used. by squarooticus · · Score: 2, Insightful

    And I can say with a straight face that you are wrong.

    If you base your experiences on pre-2000s C++, you know very little of modern C++. I have been developing in it for more than 10 years, and a few years ago I would have agreed with you, but things have changed. Really.

    Citation needed. What is post-2000's C++? Please enlighten me. All of my professional C++ experience occurred between 1999 and 2006, conforming to the 1998 ISO/IEC spec sitting on my desk, with various modifications made for broken compilers (e.g., VC++6, the lack of support for the export keyword in any C++ compiler I've used, etc.). If there's a later "version" of C++ that is supported by gcc, I have not heard of it.

    I did some C++ programming in high school and college, but didn't really dig in until 1999. From that point forward, I spent far too much time building tools---like the aforementioned refcounter, or utilities for atomic access to shared variables across threads---to make up for C++'s shortcomings. After some time, I realized that I was wasting my time and should switch to using a language that comes with these features built-in.

    My advice to my junior colleagues is simple: use Python or Ruby (not so much Perl, because of its syntactic ugliness and hacked-up object and exception models) for the control flow, and interface to C when necessary, using open source, peer-reviewed C libraries with existing Python/Ruby interfaces wherever possible. You will not only develop code more quickly, and develop more reliable code with better failure modes; you will make debugging much easier for other engineers who will inevitably have to dig into your code later.

    --
    [ home ]
  60. Re:Houses aren't made from 2x4's by Lucid+3ntr0py · · Score: 1, Informative

    You actually don't build a house out of 2x4s anymore. It's a lot more of 2x6s for exterior walls and 2x8-2x10+12s for beams and the like. 2x4's are merely for interior walls, at least according to most building codes.

  61. Faster language? by mario_grgic · · Score: 1

    I just don't like the expression, since it is quite imprecise. Languages are not fast? Is English faster than Japanese?

    Languages can be more concise or terse, i.e. you write little and say a lot.

    Now language implementation can be faster or slower (for exact same code), and almost always is (e.g. Intel's C++ compiler vs. GNU gcc).

    --
    As the island of our knowledge grows, so does the shore of our ignorance.
    1. Re:Faster language? by Free+the+Cowards · · Score: 1

      When you have a language like Python, which is defined by a single (very slow) implementation, and a language like C, which is nearly always compiled fairly directly to machine code, I think it's entirely fair to say that C is a faster language than Python. The comparison isn't perfect, but IMO it's quite meaningful.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    2. Re:Faster language? by Just+Some+Guy · · Score: 1

      When you have a language like Python, which is defined by a single (very slow) implementation

      Which of C Python, PyPy, Jython, or IronPython is the only implementation?

      --
      Dewey, what part of this looks like authorities should be involved?
    3. Re:Faster language? by gbarta · · Score: 1

      As you well know, CPython is the single implementation by which the language is defined. All the others are measured by how closely they match the behaviour of CPython. None of them get 100%.

      I love Python, but it is a perfectly reasonable thing to say that it is not as fast as C. Keep your fingers crossed that the PyPy folks can pull off a miracle!

    4. Re:Faster language? by CableModemSniper · · Score: 1

      He didn't say python had a single implementation, he said it was defined by a single implementation (I assume he was referring to C Python).

      --
      Why not fork?
  62. Re:It hurts you to learn C++ is still being used. by autophile · · Score: 1

    Well, that in itself is a point. I've been a coder for 20 years, and pre-2000 I used C++. I switched to Java and have not gone back. Perhaps the reason that "modern C++" is always forgotten is that maybe C++ didn't evolve fast enough, and Java and C# took over?

    --
    Towards the Singularity.
  63. Re:It hurts you to learn C++ is still being used. by squarooticus · · Score: 1

    Just goes to show that no matter how experienced you are, you still have things to learn.. I program in C++/Qt full time at work, and for my side business. I did some years of Java, and every time we eventually ran into performance problems. Not to mention terrible platform integration. So I use C++ with a good cross-platform class library (Qt).

    False dilemma and straw man all-in-one. I consider Java no better than C++, and worse in many respects. And where are the other choices? Was it really Java vs. C++, with no other options?

    Any scripting language is not suitable for large scale apps (and performance is a problem).

    False. You are stuck in the mindset where all aspects of an application need to be written in the same language. If that is your premise, then yes, you are doomed to use C++. I prefer the hybrid approach of using the best tool for each part of the job.

    --
    [ home ]
  64. Re:It hurts you to learn C++ is still being used. by Cyberax · · Score: 2, Informative

    Read: http://www.amazon.co.uk/Modern-Design-Applied-Generic-Patterns/dp/0201704315

    It's a good introduction to modern C++. While the book itself is not really helpful, it gives you a nice overview of "modern" development techniques.

  65. Re:It hurts you to learn C++ is still being used. by umghhh · · Score: 1

    This whole language X is better than language Y and Z is crap anyway thing makes me sick. Any discussion touching such subject tends to evolve into a flame.

    Language is just a tool. Maybe one is better for some purposes than others but my experience of a contractor coder and QA engineer is that you can create mess in any language. If you build big applications than the mess may grow correspondingly big too. That is good so for people like me that test and verify this nice fresh mess.

  66. Because 2009 is 10 years too late. by Animats · · Score: 1

    This update used to be called "C++9x", but the committee got lost in template la-la land for a decade.

    Thread-local storage is a good idea. GCC and Microsoft have had it for a decade. There's still no language guarantee that a pointer to a thread-local variable can't be exported outside the thread. But that was already true of stack variables. (Can't say "auto" any more; that keyword has been "repurposed".)

    Threading is basically POSIX threads with new paint, plus some atomic primitives that have been around in incompatible forms since the 1990s. There's no improvement in thread safety.

    Unordered maps were supposed to go into the original STL years ago, but somebody didn't get the paperwork in on time. Really.

    It's no safer than the previous revision of C++. We're doomed to another decade of crashes and buffer overflows. Amit Yoran pointed this out when he was the director of the National Cyber Security Division at Homeland Security. (He resigned under political pressure for pointing out that Microsoft's poor security was the biggest part of the problem.)

    At least they didn't put in "concepts".

  67. Re:It hurts you to learn C++ is still being used. by johannesg · · Score: 1

    Hey, nothing personal! I didn't really have time to respond to the earlier article, and I wanted to express my disgust at the C++-hatred on Slashdot in general, and your statement of "taking months longer" made for an easy enough target (months longer than what, anyway?).

    So why is it taking you so much longer to write something in C++? Is the problem with the syntax? Standard libraries? Built environments? Something else altogether?

  68. Re:And Then COBOL 2009 by niklask · · Score: 1

    Have you the slightest clue about how computing intensive cosmology simulations are? Even on our 96 node cluster, a single simple run takes on the order of several days to finish. I have yet to see any Java/C#/Python code that can compete. I have been involved in developing code for simulating cosmic-ray acceleration in expanding supernova remnants, this in Python. It is incredibly slow and we can only compute on small grid sizes. Granted, on your little home desktop or even workstation, your managed code will do just fine. But that is on a completely different level. It is like comparing oranges and coconuts.

  69. Re:It hurts you to learn C++ is still being used. by squarooticus · · Score: 4, Interesting

    I am not going to go read a book simply to settle an argument: you need to summarize here.

    In particular, explain to me why his techniques are not generally applicable to other languages (or to Python or Ruby in particular) or why using those techniques or similar ones and interfacing to C when necessary actually provide a less efficient development environment.

    I know C++ can be made "acceptable" as a high-level language through sufficient effort; I spent 7 years doing such a thing. I want to know why that's a better solution than using tools that are---out-of-the-box and without reference to a magic cookbook---ready to do the things that require months of development or dozens of third-party libraries to achieve in C++.

    --
    [ home ]
  70. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    Rather than rewrite it, I'll just direct you to another post I made. I don't claim these to be universal, but they're why I don't use the language.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  71. Re:And Then COBOL 2009 by abigor · · Score: 2, Interesting

    These are all very good points, particularly regarding RAII. I'm sure you know this already, but other languages such as Python provide deterministic resource management as well (in Python, it's the "with" statement). Java, along with C, seems to be one of the few languages that have absolutely no faculties for the RAII pattern.

  72. Re:It hurts you to learn C++ is still being used. by Yokaze · · Score: 5, Interesting

    > I'm just positively amazed that Slashdot, in theory home of programmer geeks anywhere, should have such a violent dislike of C++.

    Because C++ is not a pure language. It is a multi-paradigm language (imperative, OO and functional) with both a high and low-level language features and people seem to hate the aspect they which they don't prefer.

    The close-to-the-metal types hate the high-level aspects and rather use C. Disregarding the fact, that changing the code from C to C++ is purely syntactical and runs without any detriment in performance. Exactly the prime idea behind C++.

    The high-level people dislike C++ exactly for this approach. They don't like that the basics are so clearly visible, and are even the default. You have to hop through some loops, before you get to a higher abstraction layer. E.g. you have to use external libraries and/or special classes for memory management.

    Personally, I like C++ for exactly that reason. I can start on a fairly abstract layer with pure virtual interfaces, smart pointer, signal slots and there is not a single (raw) pointer or a manual deallocation to see (or other manual resource deallocation).
    Granted, it is more verbose than in a pure high level language, but that is what the machine has to do.

    And if there is a performance bottleneck, I can seamless go down in the abstraction level from simple inline functions, over imperative functions with pointer arithmetic, down to inline assembler and can even guarantee a certain timing, if necessary.

    --
    "Between strong and weak, between rich and poor [...], it is freedom which oppresses and the law which sets free"
  73. Re:It hurts you to learn C++ is still being used. by grumbel · · Score: 1

    For me the main reason is that C and C++ allow you access to the "real thing", while other languages just wrapper things up and these wrapper have the tendency to be unmaintained, buggy, limited or simply being non-existent. So instead of writing tons of wrapper code and hunting bugs in wrapper code, I simply write it directly in C++.

    Another advantage is that C++ is statically typed, never could see much of a real benefit of dynamic typing, since it just moves errors that your compiler would have found automatically down to runtime where you have to find them one by one, pretty annoying an time consuming.

    That of course doesn't mean that C++ is perfect, it has tons of problems, but since none of the alternatives can do what C++ can do, there often isn't really much of a choice.

  74. Re:Houses aren't made from 2x4's by Lucid+3ntr0py · · Score: 1

    That's because we're running out of good lumber (the last construction company I worked for used imported studs ,) and skilled labor. Laminates and truss systems are even easier to put together.

    Ask an average framer how big a birds mouth on a (insert example of pitched roof here with dimensions) should be, compared to how to assemble a truss package. Easy, instructions and even supervisors come with truss packages.

  75. Re:It hurts you to learn C++ is still being used. by pjt33 · · Score: 1

    Here's a newsflash: C++ also has support libraries, just like Java, Perl, Python and Ruby. They may not be part of the language specification (and I still think that's a weird idea to begin with, but I'm old-fashioned that way), but that doesn't mean they don't exist.

    I can't speak for Perl, Python or Ruby but I can say that the Java Language Specification only specifies a very small part of the standard libraries - some of the java.lang package. There's a distinction between Java the language and Java the environment.

    Anything you could want for in a modern language is there. And nobody is holding a gun to your head and making you write those scary templates if you don't want to.

    Everything I could want may be in there (although I doubt it - I want garbage collection without having to explicitly do anything) but so is a load of stuff which I don't want in a modern language. Maintaining other people's code is bad enough in Java: I dread to think what the people who wrote the project I'm currently trying to fix would have done in a language with pointers.

  76. Re:It hurts you to learn C++ is still being used. by ardor · · Score: 1

    Many of the tools you described are in the tr1 already,meaning they are a de-facto standard, and official in C++0x. Using stuff like shared_ptr makes writing custom refcounting unnecessary in ~80-90% of all cases. I suggest you look up TR1, C++0x novelties, and Boost 1.36. Oh, and Modern C++ Design by Alexei Alexandrescu.

    --
    This sig does not contain any SCO code.
  77. Re:It hurts you to learn C++ is still being used. by TomorrowPlusX · · Score: 3, Insightful

    There are vanishingly few programmer geeks left on slashdot. Most of the "programmers" here, these days, are folks who've written a few scripts or set up a movable type install.

    There are a few real programmers left here, but they're lost in the noise. You know, the roaring noise made by the python and ruby folks.

    This post brought to you by a C++ programmer who happens to love Python and Ruby ( and javascript! it's an amazing language ), but uses the different languages where appropriate.

    --

    lorem ipsum, dolor sit amet
  78. Re:Concurrency in C++ by YodaToad · · Score: 1

    Post on a real account and you won't have to worry about it.

  79. Re:It hurts you to learn C++ is still being used. by Anonymous Coward · · Score: 1, Interesting

    A library that isn't baked into the language may or may not exist, or have been tested, or work, on any given platform. And it may not coexist well with any other such libraries. E.g., your cloud computing API and your network stack don't use the same thread class, so now what?

    Modern languages don't produce "undefined behavior" if anyone that was involved with a project has ever made a single mistake in handling references, pointers, or iterators.

    And lambdas aren't a lot to ask. They were invented forty years ago.

  80. C++0x sucks but, uh, when's the gnu compiler due? by tjstork · · Score: 1

    I must be mentally ill, but, as much as I gripe about C++ and now C++0x, (even calling it C++#), I have to know, does anyone know when GNU targets the compiler to be due? I mean, I can't imagine them chasing a moving target but with the standard evolving I'm sure there's some stuff that they could work on.

    I looked at their C++0x implementation web site, and it looks like they have a way to go:

    http://gcc.gnu.org/projects/cxx0x.html

    I like C++, even though I hate it, and this next incarnation has me tremendously excited.

    --
    This is my sig.
  81. Re:It hurts you to learn C++ is still being used. by ardor · · Score: 1

    Improvements are always welcome, but this seems more like a case of a marketing exercise to try and keep C++ in the game as a serious language for general application development, which IMNSHO is something that should have been relegated to legacy systems.

    Actually, the improvements are fundamental and the biggest change C++ ever experienced. concepts, lambda, variadic templates, type deduction, these aren't just nice toys. Add into this language-level support for multithreading, garbage collection etc. and you almost get a new language.

    --
    This sig does not contain any SCO code.
  82. Re:And Then COBOL 2009 by fatmonkeyboy · · Score: 1

    Maybe I'm not fully appreciating your problem with (2), but FYI, the "using" keyword in C# is pretty nice. It looks like this:

    using(Bitmap mybitmap = new Bitmap(...args...))
    {
    // do work with bitmap
    }

    Once the program exits the "using" scope, the bitmap's Dispose method will be called (which for the sake of this argument is roughly equivalent to calling its destructor).

  83. Re:It hurts you to learn C++ is still being used. by ardor · · Score: 2, Interesting

    Yes, this sounds logical. C++ has only recently become interesting. C++0x back in, say, 1999, would have totally killed off Java.

    --
    This sig does not contain any SCO code.
  84. templates... by mario_grgic · · Score: 2, Insightful

    I used to think like that, but then all the things you talk about are just syntactic sugar. There is nothing you can do with proper generic that you can't do in Java or C#. Yes, C++ is way more expressive than almost any other language, but that is also its peril.

    And when was the last time you used meta programming to solve a concrete problem that could not be elegantly solved otherwise.

    Most people learn how to calculate a factorial using meta programming techniques and stop right there. It's more of a curiosity than useful practical technique.

    --
    As the island of our knowledge grows, so does the shore of our ignorance.
    1. Re:templates... by abigor · · Score: 1

      Template programming is widely used in game programming, and is applicable basically anywhere compile-time computation will speed things up.

    2. Re:templates... by mr_mischief · · Score: 1

      I used to think like that, but then all the things you talk about are just syntactic sugar. There is nothing you can do with a compiled language that you can't do in an assembled or directly executable one.

      Beware the Turing Tarpit. Just because all Turing-complete languages can be used to create equivalent programs does not mean they take an equivalent amount of effort.

  85. Re:It hurts you to learn C++ is still being used. by Cyberax · · Score: 2, Informative

    To summarize it, C++ now moves toward design which allows to catch more and more errors during compilation. But at the same time C++ provides tools which allow to write generic code.

  86. Re:It hurts you to learn C++ is still being used. by neapolitan · · Score: 1

    Wow, I second that. I have written moderately complex programs in C++ that port beautifully, often without any modification whatsoever. Using the curses library, you can actually have rudimentary GUI programs and good interactivity without any real platform-specific code. A couple silly programs I wrote for fun (sudoku solver, medical calculator) compile on linux and PDA with minimal modification. I can rest assured knowing that they will compile on run on just about any machine in the near future.

    I view programming languages as a clear continuum -- from Machine to Assembly to C to C++ to C# to Java / Python / Ruby / MATLAB / script-du-jour. Choose where on this line you want to program, trading convenience/portability for speed/low level optimization/customization.

    I, for one, have been always pleasantly amazed by C++. It's low as you want to go, near to C, but you get classes and their benefits (encapsulation, overloading, etc.) that makes larger projects much more easily organized. Manual garbage collection gets to be a pain, but I view this as a little bit of a necessary pain (though I admit perhaps I have just gotten used to meticulously keeping track of memory and pointers.)

    Also, I think we need a car analogy: C++ is a manual transmission car, but Python is an automatic. They just get you from place to place, but the manual is a bit more difficult, sportier, customizable for your style, and potentially more fun.

    --
    Slashdotter, ID #101. UIDs are in binary, right?
  87. Re:It hurts you to learn C++ is still being used. by jcr · · Score: 1

    Don't blame a real language because you need one of those dumbed-down tell-a-tubby languages.

    Does mastering unnecessary complexity make you smart, or does it make you an idiot?

    I'm sure you're very proud of your C++ skillz, but can you get a given task done in less time than someone using a better language?

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  88. Re:And Then COBOL 2009 by shish · · Score: 1

    hours finding memory leaks? How bad are you at debugging?

    If you think that taking hours to find a leak is excessive, the people at mozilla could do with some help -- they've been hunting them down for *years* :-P

    --
    I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
  89. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    Programming is not like building a house. You don't get halfway through, change your mind, and then have to tear things down, wasting a great deal of manpower and materials in the process.

    Building things that you later have to throw away is simply par for the course. Even if none of your Python survives into the final product, that prototype you built and then threw away is still going to make you more efficient overall. And this outcome is extremely unlikely. More likely is that you discover that all of the slow parts of your program only comprise about 10% of your code. And then you can take those parts out, replace them with C++, and leave the rest of the Python code in place.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  90. Re:Bjarne by krmt · · Score: 1

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

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

    Apparently you've not heard of Hadoop which is written in Java and, unlike Google's MapReduce, actually available to people outside of Google today.

    --

    "I may not have morals, but I have standards."

  91. Old joke by Weaselmancer · · Score: 1

    What's the difference between C and C++?

    C gives you lots of different ways to shoot yourself in the foot. C++ allows you to instantiate ten copies of ten feet and shoot them all at the same time.

    The kernel of truth in this joke is that no language is going to make a lousy programmer into a good one. Rigor is required in every program. Rigor transcends language.

    As for which language is best - learn many. Pick the best one for the given task at hand.

    --
    Weaselmancer
    rediculous.
  92. C++ is no longer a modern language by MobyDisk · · Score: 3, Interesting

    C++ was once thought to be a language that was powerful enough that it could be used to express most features that other languages had. With things like operator overloading, multiple inheritance, and templates, you could pretty much make a class behave however you want. But years later, we have seen that C++ failed at that mission. There are simple and common OO constructs that C++ is unable to represent. Rather than focusing on improving the template functionality, I want the OO syntax fixed.

    Let me cite some examples:
    1) It is impossible to make a string class that behaves "normally"

    Plenty of people have tried. QT, Boost, STL, Gnome, WxWidgets, all have their own string classes. Years ago, when VB developers touted how easy it was to use strings compared to C++, I told them it was merely because nobody had made a good string class. After 10 years of trying to write one, and using dozens of other ones people created, I realized that C++ is simply too weak and too loosely typed to do this.

    Suppose I make a string class, kinda like the STL string:
    string foo;
    1) foo = "whatever";
    2) foo = foo + "bar";
    3) foo = 7;
    4) foo = foo + 7;
    5) foo += 7;

    Take a look at these. The first one is no problem. That can call an assignment operator to copy the char * contents to the string. The second one can also be done with a + operator. The third one can also be done via assignment. But what if you forget that? Well, the compiler will see that as foo = foo(7) which will call the constructor that allocates 7 characters, and then assign that. So instead of the string "7" you get a blank string. The next example is a problem too. If the string class can be converted to a const char *, as is common, then does this mean to use the + operator on string and an integer? Or did it mean to convert foo to a const char *, then move 7 characters ahead, then assign it? That can result in a crash. This is because pointer arithmetic is intrinsic in C++, but it is inherently type unsafe.

    Then how about a function that returns a string? A simple case in most languages, but in C++ it results in redundant copies across the stack. So people revert to funny things like auto_ptr and other wrappers, or complex mechanisms for doing shallow copies to prevent that. Other languages just avoid the problem entirely by not allocating things on the callee's stack. It's just an intrinsic problem in the old everything-goes-on-the-stack-by-default mentality of C++. It just doesn't always work.

    Properties are another one. This is something that various libraries try to do, and is free in most new OO languages. But just cant be done in C++ // C#
    class Foo
    {
    private int _x;

    public int x
    {
    get { return _x; }
    set { _x = value; }
    }
    }

    So in the above class, I want to access _x via a property get/set. C# has a built-in construct for this. In C#, I could do:

    MyFoo.x = 7;
    MyFoo.x++;
    MyFoo.x = MyFoo.x + 3;
    MyFoo.x/= 7;

    etc. The compiler knows how to get/set x, and it can even be inlined! This allows me to do things like log when x changes, or see what accesses the variable. Now, let's try that in C++.

    class Foo
    {
    private:
    int _x;

    public:
    int x(); // Get X
    void x(int); // Set X
    int &x2(); // Another way to get/set X
    };

    MyFoo.x(); // Gets x, no problem
    MyFoo.x(7); // Weird syntax, but that is fine
    MyFoo.x()++; // Does not modify the value of x, hmmm...
    MyFoo.x2()++;// Modifies x, but only lets you track the get, not the set.
    MyFoo.x()/=7;// Same exact issue
    MyFoo.x(MyFoo.x()/7); //

    1. Re:C++ is no longer a modern language by TheSunborn · · Score: 1

      How exactly does an automatic generated property differ from the c++ solution, where you just have the variable public?

      In both cases, you give the user of the class the ability to read/write a specific valiable.

         

    2. Re:C++ is no longer a modern language by MobyDisk · · Score: 1

      The idea isn't just to give read/write to a specific variable.

      Wikipedia files it under Information hiding but I usually hear the terms accessors, or encapsulation.

      A public variable does not give you the ability to monitor when the variable changes, or to set a dirty flag, serialize the value, log it to disk, etc. In many cases, there is no value "x" at all - it is a derived value that is calculated from some other state. In theory, you want nothing to be public, and everything to go through an accessor. Normally, the accessor does nothing. But when the time comes that you need to modify the code to do one of the aforementioned items, you don't have to change any of the calling code.

    3. Re:C++ is no longer a modern language by Anonymous Coward · · Score: 1, Informative

      Your examples are complete bullshit. You CANNOT assign a character to a string, so your foo = 7 example is utter crap!!! You CAN do this: s(7, 'a') OR THIS: a.assign(7, 'a'). Your other examples just so your ignorance. You return a member by VALUE, and are shocked that the caller cannot modify your member? Is that really something you'd want or expect them to do? That is the whole point! It protected the innards of your objects. For the uneducated, it is called a class invariant.

    4. Re:C++ is no longer a modern language by luzr · · Score: 3, Interesting

      Properties are another one. This is something that various libraries try to do, and is free in most new OO languages. But just cant be done in C++

      I never really understood this effort. What is so good about properties? Why is writing () after getter function name so hard? And for setters, setter chain is much less verbose anyway, like

      mywidget.NoWantFocus().SetReadOnly();

      instead of

      mywidget.nowantfocus = true;

      mywidget.readonly = true;

      Why should any language look like Visual Basic?

    5. Re:C++ is no longer a modern language by The+Moof · · Score: 1

      Suppose I make a string class, kinda like the STL string:
      string foo;
      1) foo = "whatever";
      2) foo = foo + "bar";
      3) foo = 7;
      4) foo = foo + 7;
      5) foo += 7;

      The last three lines made me cringe.
      Any strongly typed language should yell about lines 3, 4, and 5.

      I also find it amusing that you complain about C++ being too loosely typed, then you want it to do something like that. Those would fail in C# as well, which you used as an example further down.

    6. Re:C++ is no longer a modern language by noidentity · · Score: 2, Informative

      Implicit conversion to const char* is not in the standard string. Neither is a constructor which allows string(n). Your string examples could be supported by a string class, but they would reduce safety by allowing accidental addition to integers. The preferred way is to use a stringstream to convert any object T to a string using its operator . C++0x will address the copying issue via the move constructor, giving user code the benefits without any changes since it mainly concerns library implementors. Really, your post comes off as an ill-informed swipe at C++. For example, "I could go on with other examples of things that the super-powerful C++ can't do". Why the petty attitude?

    7. Re:C++ is no longer a modern language by Jerry+Coffin · · Score: 2, Informative

      1) It is impossible to make a string class that behaves "normally"

      Plenty of people have tried. QT, Boost, STL, Gnome, WxWidgets, all have their own string classes. Years ago, when VB developers touted how easy it was to use strings compared to C++, I told them it was merely because nobody had made a good string class. After 10 years of trying to write one, and using dozens of other ones people created, I realized that C++ is simply too weak and too loosely typed to do this.

      The problem isn't that it can't be done. If you really knew C++ as well as you claim, you'd realize that it's pretty easy (bordering in trivial) to write a string class that does precisely what you ask. The reason most don't work that way is because after people try it, they find that it's not what they really want -- in particular, allowing assignment of an int (to use your example) to a string tends to cause problems. If you're writing a 10-line throwaway script, allowing assignment of an int to a string probably won't cause a problem, but for big, industrial-strength projects it's a whole different story.

      It's odd that you blame this on "loosely typed" -- loose typing is exactly what allows this to work, and C++ prevents it by having stronger typing than the languages to which you're apparently accustomed.

      Properties are another one. This is something that various libraries try to do, and is free in most new OO languages. But just cant be done in C++ // C#

      Properties, at least as supported by these languages are simply a lousy idea. Supporting or using them is an equally bad idea.

      A property is only "useful" when you've really used the wrong type. IOW, you have (for example) an int (by whatever name that language happens to use) private to your class, but you really want that int to be restricted to a specific range, or log every time it's read/written.

      In other words, what you want is something that works like an int in some ways, but not others. C++ already provides a way to define such a type directly though (and so should any other OO language) -- that's what classes are for. When, for example, you want an int that's restricted to a specific range, you write a class (or template) for that purpose -- and it supports assignment to and from ints by overloading operator int and operator= respectively. Of course, these can also be inlined, just like any other function in C++.

      C++ does have shortcomings -- but your understanding of it appears to be sufficiently limited that you don't know them yet.

      --
      The universe is a figment of its own imagination.
    8. Re:C++ is no longer a modern language by smellotron · · Score: 1

      1) It is impossible to make a string class that behaves "normally"

      Please define "normally".

      [std::string] foo = 7;

      Oh, you mean Variable-Typed Values? That's not a string class. That's an everything class. And yeah, you can do that with an STL-esque string, but it is a bit of a silly idea. Your normal doesn't match anything I would expect for a general-purpose string abstraction.

    9. Re:C++ is no longer a modern language by shutdown+-p+now · · Score: 1

      I never really understood this effort. What is so good about properties?

      You need them as a distinct abstraction for visual manipulation of components (UI editors etc). And once you have the abstraction so nearly universal, there's no excuse not to provide syntactic sugar for it in the language. Java guys found it the hard way when they introduced annotation, and had to figure out how to apply an annotation to the property as a whole (do you count only annotations on the getter method, on the setter, or on both? what if property has no getter or no setter? what if you want to have some annotations apply only to the getter/setter, and not to the property?). Have a look at C# attributes to see how smoothly it all works there.

    10. Re:C++ is no longer a modern language by luzr · · Score: 1

      You need them as a distinct abstraction for visual manipulation of components (UI editors etc).

      We (http://www.ultimatepp.org) use setter chains as a distinct abstraction for visual manipulation of components.

      And it works very smoothly as well...

      In fact, if anything, you need attributes, not properties. Or, in another words, some sort of reflection. Anyway, the real-life benefit of adding attribute/reflection is not significant to bother, you just need some non-C++ widget description to be used by UI editor instead.

    11. Re:C++ is no longer a modern language by MobyDisk · · Score: 1

      As a few posters replied, some of my quickly thought-out examples were wrong. Ex: foo = 7 really wouldn't work, and shouldn't. But I disagree with you about what is possible in c++. I listed about a dozen libraries all with different string classes, and none of them can do what even the most basic string class in almost any other language can do. Pick one: Javascript, Python, PERL, Visual Basic, Java, C#. If you think you can make a string class with all the functionality that those languages offer, then please post it because I've never seen one, and I've read articles on why it is just darned near impossible.

      A property is only "useful" when you've really used the wrong type.

      A property is the most popular implementation of the O-O concept of encapsulation AKA Information Hiding. It can be used for many things, such as caching values, monitoring when the variable changes, setting a dirty flag, serializing the value, logging it to disk, etc. C++ provides a way to do it, but it is just ugly.

      C++ does have shortcomings -- but your understanding of it appears to be sufficiently limited that you don't know them yet.

      STFU. I wonder if brain surgeons get into high-tech discussions of the inner workings of neurobiology, and then end their replies with "You are obviously an uneducated fool." I doubt it, I think it is just on Slashdot. I appreciate your reply, but this Slashdot nonsense of debating complex topics then ending it with insults about how the other person obviously knows nothing is just lame and makes people look childless.

    12. Re:C++ is no longer a modern language by MobyDisk · · Score: 1

      You are correct. I made-up that example off the top of my head, and the foo = 7 example is bad. My point was to show that there is no easy way to concatenate various types on to a string easily. It happens with scalar types, as well as classes. Java and C# get around this with toString(). I don't like the idea that toString() is somehow built-into the language: There's no toInt() or toFloat(), but the concept that the compiler would use such conversion operators is a good one. (I don't think an operator string would work here, would it? If so, maybe my whole point should change. No I'm gonna have to go try it...)

      A stringstream is a pain. A programmer should be able to do something like:

      call_some_fn("Error number " + errNumber + " when passed a value of " + parm1 + "," + parm2);

      Not:
      std::ostringstream foo;
      foo C++0x will address the copying issue via the move constructor

      Thanks, I will look into that.

      Really, your post comes off as an ill-informed swipe at C++. For example, "I could go on with other examples of things that the super-powerful C++ can't do". Why the petty attitude?

      Really? I've been coding C++ for 15 years, and I code in a dozen other languages. My "petty attitude" comes from the fact that C++ has all but vanished in corporate software since .NET 2.0, and for darned good reasons. It takes twice as many lines of C++ to do the same thing C# does, is more error prone, and unless you are coding something really low-level, it is just as fast. Often times it is much faster because I spent lots of time in C++ converting from one string format to another to another, when I combine code from 4 different libraries that use 4 different types of strings. (That's also why I cited the example of copying strings.)

      The "other examples" I didn't even mention really are too numerous. The next biggest one on my list is the usage of pointers. Something wants a int*: So is that a single integer, or an array? How big is the array? Does the caller deallocate it, or the callee? Boost addresses this by replacing pointers with a template class that specifies these types of things within the pointer. But it is really dumb that there is no standardized way to pass such information in C++. Maybe if everything used stl, we could just pass vector instead of pointers most of the time, but nobody wants to invoke that overhead. So we need something else in the language. This is probably the #1 source of memory corruption and deallocation errors in C++, and it is simply not an issue at all in other languages.

      I believe that it is possible to alter C++ to have somewhere between none, and immeasurable, performance overhead, while addressing all of these issues. But it will rankle a lot of people to add a construct of pointer + length. And some people really like doing:

      wchar_t buffer[50];
      wtoi(buffer, 1234, sizeof(buffer)/sizeof(*buffer));

      Because it makes them feel powerful and efficient. But it isn't - it just wasted stack, introduced potential overflows, required more lines of code, and required the programmer to explicitly pass things that the compiler already knows (length of buffer).

      This is the kind of stuff that makes C++ unapproachable, and error prone. I'm sorry if I came-off as obnoxious - I did my best to show my point within the limited scope of a Slashdot post. These are real issues, and I find that the language is vanishing, and I am becoming more and more to giving-up cross-platform development because it just isn't worth the hassle. I really liked it when the most powerful O-O language was also the most efficient and x-platform. But today, it seems like the language is being abandoned. And Bjarne doesn't care about the fact that in 5 years, nobody who writes software for Windows will be using C++. Even game studios are talking about writing their code in C# because most of the performance is handled by the graphics layer. So why even write in C++ for them? What will be

    13. Re:C++ is no longer a modern language by MobyDisk · · Score: 1

      oh, yes, about about the atoi example. I know you will say to use a stringstream, and that is somewhat better. But it is still ugly and is much slower (I've benchmarked it on MSVC and GCC - string streams were orders of magnitude slower than using sprintf, which is dumb since one of the theoretical benefits of string streams was to efficiency.)

  93. Re:Ha! Yeah right. by sergstesh · · Score: 2, Insightful

    I do not understand why the post is modded "funny". Indeed, very fast SIMD libraries are coded in assembly. I think even 'liboil' has some parts coded in assembly

  94. Re:It hurts you to learn C++ is still being used. by bberens · · Score: 1

    I would never do what you suggest. We have a hard enough time finding developers who are proficient in one language, much less two or more. I guess it depends on where your heart is. If your heart's in the technology you do whatever is the best option right now. If your heart's in the business, you do the best to maintain your sustainability moving forward.

    --
    Check out my lame java blog at www.javachopshop.com
  95. Re:It hurts you to learn C++ is still being used. by Just+Some+Guy · · Score: 1, Insightful

    I'm just positively amazed that Slashdot, in theory home of programmer geeks anywhere, should have such a violent dislike of C++.

    There are at least two ways to interpret that:

    1. "There is an overwhelmingly bad reaction to this, and everyone seems to prefer this other thing instead. Perhaps I should find out why."
    2. There is an overwhelmingly bad reaction to this, and everyone seems to prefer this other thing instead. Everyone but me seems to be clueless."

    Now, "most popular" isn't automatically the same as "best", or else McDonald's make the most delicious hamburgers. Still, if a huge crowd of people who at least hypothetically have experience with the subject matter tend to have the same opinion, perhaps there's something to it.

    Not that there is nothing to criticize about it, but it is still an amazingly powerful, versatile tool that programmers anywhere would do well to learn.

    It could be that we learned it, cringed in horror, and went back to our more expressive dynamic languages. I have no fear of programming to the metal, but I bought a computer so that I don't have to deal with all the low-level gruntwork on a daily basis. There's nothing more powerful or versatile than raw machine code, but there's a reason why most of us use something else.

    --
    Dewey, what part of this looks like authorities should be involved?
  96. Re:It hurts you to learn C++ is still being used. by sgtrock · · Score: 1

    We have a hard enough time finding developers who are proficient in one language, much less two or more.

    Then you're hiring the most junior programmers you can find and paying them peanuts. You want talented staff with a broad range of skills? You need to pay reasonably well and encourage them to continually improve their skills. Fund additional training. Encourage them to involve themselves in coding related activities outside work. Reward those who show initiative.

    Otherwise, you've got nothing but baby code monkeys who will never grow up to be gorillas.

  97. And the faster language is? by mangu · · Score: 1

    it's trivial to go in and write the speed-sensitive portions of the program in a faster language.

    Such as C++, for instance?

    1. Re:And the faster language is? by Free+the+Cowards · · Score: 1

      Yes, but you don't write the entire program in it, no more than you construct an entire house out of nails.

      --
      If you mod me Overrated, you are admitting that you have no penis.
  98. Re:It hurts you to learn C++ is still being used. by david_thornley · · Score: 1

    It's simple enough to deal with people who would abuse pointers in C++, if you're running the project.

    Tell them that if you find a single actual pointer in their code that you haven't pre-approved for good reason, you will shoot them. It should only take a few pointers before the rest get the idea.

    If you live in the sort of benighted country that lacks the casual death penalty for not following coding standards, figure out some suitable sanction yourself.

    In my experience, people who write bad code have the flexibility to do it in any language. COBOL is a pretty simple language, and I've seen some truly frightening messes in COBOL programs.

    --
    "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
  99. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    Logical fallacy: higher level languages are in use already.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  100. Re:And Then COBOL 2009 by Yokaze · · Score: 2, Interesting

    > I have been involved in developing code for simulating cosmic-ray acceleration in expanding supernova remnants, this in Python.

    Well, Python is a different game than Java or C#, which both have a much better JIT-compiler.

    I mainly program in C++ (real-time data processing), but I feel hard-pressed to believe, that Java has to be severely slower than C++ in numeric computations. The Java implementations of FFT and LinPack suggest, that comparable performance should be possible. The SciMark 2.0 should also be more up to par, when you replace the synchronized Random in the benchmark with a Java implemented Mersenne Twister.

    --
    "Between strong and weak, between rich and poor [...], it is freedom which oppresses and the law which sets free"
  101. Re:It hurts you to learn C++ is still being used. by Hal_Porter · · Score: 1

    Language is just a tool.

    Sadly that's oftem true of the programmer too.

    --
    echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
  102. Re:And Then COBOL 2009 by niklask · · Score: 1

    Well, python+numpy in a single cpu environment can be very fast, depending on what you want to calculate. But you completely miss the point; for really computing intensive work you have to go parallel, and I have yet to see anything in Java that works efficiently in a parallel environment.

  103. Re:And Then COBOL 2009 by againjj · · Score: 1

    You've never spent hours on a single bug? And you only work on code you yourself have written? Wow, I wish I were you. Then all of the memory leaks, uninitialized values, pointer screwups, etc. that I have dealt with in the past will either never exist or be easily tracked down and fixed within minutes.

  104. I like Java because... by roman_mir · · Score: 1

    Most of the development is done by the devs on their local windows machines, ant compiles everything nicely on any platform into a jar or war or ear or just classes, then you just copy the binaries to a Unix machine and it works. (of-course if you start using platform specific stuff, then you will have to do more work, but actually it's very rare for business apps. to use platform specific stuff, especially if it's all about databases and networks.)

    The memory is managed by the JVM, which of-course does not prevent memory leaking in itself, but at least buffer overruns will not allow injected code execution, at this point anyway.

    The libraries are part into the JRE and you can rely on them for being present.

    There are many people familiar with the language.

    Note that I didn't write anything bad about C++, which I also use and often link to Java. Why can't it be more about positives than about negatives? C++ has a place in the world.

    1. Re:I like Java because... by smellotron · · Score: 1

      I'm a C++ guy myself, but I like your comment. I'll add something nice about Java (yuck...). Java solves the build issue rather well. It's quite onerous to get used to, but once you realize how much effort it is to get large-scale build systems for C++ set up, it proves itself a nice time-saver. Most C or C++ shops develop their own in-house standards anyways, and Java just eliminates that mental workload.

  105. What tool is better than C++? by pinkfloydhomer · · Score: 3, Insightful

    I also have an extensive experience with C++, and I tend to agree with a lot of the criticism that it gets.

    But the problem is that no alternative exists for the type of problems where C++ is used extensively. I guess the most important area is games.

    The world really NEEDS a language (the last low-level language) with the low-level performance of C++/C and with a full, modern library, and modern language features (threading, modern module system (not based on #includes and a crude preprocessor...), optional strong typing system a la Ada with optional runtime-checking etc etc etc.

    Basically, a really nice, compiled, well-performing, modern low-level language could easily exist. But it doesn't. So we'll have to settle for C++ until someone makes something better.

    1. Re:What tool is better than C++? by phoenix.bam! · · Score: 2, Interesting

      I guess D is dead? Could have been a lot of hype but it sounded like the language you were looking for.

    2. Re:What tool is better than C++? by pinkfloydhomer · · Score: 1

      D is okay, but it it not the solution.

    3. Re:What tool is better than C++? by mikael · · Score: 1

      The world really NEEDS a language (the last low-level language) with the low-level performance of C++/C and with a full, modern library, and modern language features (threading, modern module system (not based on #includes and a crude preprocessor...), optional strong typing system a la Ada with optional runtime-checking etc etc etc.

      Modula-2 had some of those features (Definition/Implementation files) built in. Add some thread, timer and mutex class objects, and you had multi-threading support. That was back in the early 1990's. Type checking seems to break down when you want to serialize a complex class object into a single file - then you have to figure out a way to write out floats, integers, shorts, longs out as bytes. Otherwise you are back into string management classes.

      --
      Vintage computer adverts: http://www.vintageadbrowser.com/computers-and-software-ads
  106. Re:It hurts you to learn C++ is still being used. by bberens · · Score: 1

    We pay markedly above market rates for developers and have a very good corporate culture with paid training we're practically begged to take. The market I'm in is driven by a small group of very big hitters in the defense industry. Most people try to get in there, get their clearance, and bounce around between the defense contractors for the rest of their career. Taking a job outside of the defense industry means letting their clearance (and practically guaranteed job any time they want one) to expire. Any other ideas you have?

    --
    Check out my lame java blog at www.javachopshop.com
  107. Re:It hurts you to learn C++ is still being used. by gbjbaanb · · Score: 1

    then you don't bother trying. Hire specialists, preferably those who can turn their hand to something else but generally keep to one thing.

    I mean, you wouldn't expect your DBA to code middleware applications in C++, you'd want them to be the best guru sql dev ever. The same can apply to everyone else - you need Web skills, get a web dev and tell him he only needs the basics of c++, java and sql but he'd better be "teh l33t hax0r" at javascript and html.

    Often this approach makes everyone happier, there's less politics in a group, they start to work much more co-operatively and are happier in their roles.

    Unfortunately, most people who are good like this are focussed on the technology. If they have to reskill every time something new comes out, they'll never be any good, they'll be continually junior developers as soon as they start to get good, its all-change time again. A good businessman would understand that and only introduce new stuff when there's a very good reason to do so.

  108. Re:It hurts you to learn C++ is still being used. by caerwyn · · Score: 1

    Rewriting in another language, and then managing a multi-language application, is itself nontrivial.

    Consider, for instance, a research application I'm currently working on. 95% of the code is extremely performance critical- every "run" takes 2 to 4 weeks of computer time. Dealing with multi-language complexities just to write the other 5% in something other than C++ would be stupid. Most changes between runs are either adding additional algorithms that run in a performance-critical fashion, or tweaking existing portions- the framework changes rarely, if ever.

    The "premature optimization is the root of all evil" comment has a very specific limitation- it corresponds to low-level optimization. There's a lot of performance considerations that happen at the design and algorithmic level, and when you're initially contemplating the design for a project it is often obvious from the outset which pieces are going to be performance critical. Writing them in something other than a performance conscious language is just wasting your time.

    --
    The ringing of the division bell has begun... -PF
  109. Re:C++0x sucks but, uh, when's the gnu compiler du by tjstork · · Score: 1

    GCC should learn from Intel here. ic is way way ahead of them.

    I've always liked Intel's compiler but I wonder -- what does ic do that gnu doesn't? Yeah, I know that gnu's error messages make no sense but it does seem to be more standards correct and to generate working code.

    --
    This is my sig.
  110. Is Pascal grammar LR now ? by Anonymous Coward · · Score: 1, Funny

    If not, it can't do this:

        char * p, * q;
        while (*p++ = *q++);

    :-p

    1. Re:Is Pascal grammar LR now ? by dkf · · Score: 1

      If not, it can't do this:

          char * p, * q;

          while (*p++ = *q++);

      :-p

      IIRC, Pascal's got a good grammar (it's closer to Algol than C++ is) and so has an LR grammar. Also, Pascal can't do it with that syntax (well duh!) but copying strings is easy IIRC. (It's been a long time since I wrote Pascal.)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
  111. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    You seriously think, as you post to a web site that runs entirely on Perl, that there is no evidence that higher level languages are in use today? Get real!

    --
    If you mod me Overrated, you are admitting that you have no penis.
  112. Re:And Then COBOL 2009 by gbjbaanb · · Score: 1

    trouble is, once you get past 1 object you're into a nightmare world of nested 'using' statements that make 'if then elseif' look good.

  113. Re:It hurts you to learn C++ is still being used. by osu-neko · · Score: 1

    C++ is a write-only language. That's why it receives so much hate.

    All languages are write-only in the hands of incompetent programmers. No languages are in the hands of competent ones.

    --
    "Convictions are more dangerous enemies of truth than lies."
  114. Re:It hurts you to learn C++ is still being used. by johannesg · · Score: 1

    C++ is a write-only language. That's why it receives so much hate.

    Perl's getting plenty of love around here...

  115. Re:And Then COBOL 2009 by gbjbaanb · · Score: 1

    ....posting this while I wait for a whole lot of C++ code to compile.

  116. From the new list of "features":

    > nullptr: a name for the null pointer

    #define nullptr NULL

    There, that was hard.

    --
    (-1: Post disagrees with my already-settled worldview) is not a valid mod option.
    1. Re:Null by drxenos · · Score: 1

      No, that is not the same. The problem with NULL is it resolves to 0, an int expression. If you overload a function to take an int or a pointer, and use NULL, it will incorrectly choice the int form. nullptr will choice the pointer form.

      --


      Anonymous Cowards suck.
    2. Re:Null by cgaertner · · Score: 1

      The problem with NULL is it resolves to 0, an int expression. If you overload a function to take an int or a pointer, and use NULL, it will incorrectly choice the int form.

      Thats not true. The C macro NULL normally expands to ((void *)0). If you use this as an int expression, C compilers will warn. I'd consider the behaviour you described a bug.

    3. Re:Null by drxenos · · Score: 1

      Sorry, but you are confused. The C standard requires that NULL be an expression that resolved to either a null void pointer or an integer expression that resolves to 0. The C++ standard (which the article is about) requires that NULL be an integer expression that resolves to 0. Because of the stronger typing in C++, NULL cannot be a void pointer. C++ does not allow an implicit cast from a void* (only to a void*).

      --


      Anonymous Cowards suck.
    4. Re:Null by cgaertner · · Score: 1

      The C standard requires that NULL be an expression that resolved to either a null void pointer or an integer expression that resolves to 0.

      No, it doesn't. The C99 standard reads:

      7.17 3 [...] NULL which expands to an implementation-defined null pointer constant; [...]

      In my book, a pointer constant is not an integer expression. GCC agrees.

      The C++ standard (which the article is about) requires that NULL be an integer expression that resolves to 0. Because of the stronger typing in C++, NULL cannot be a void pointer.

      And that's imo a bug with the C++ standard.

    5. Re:Null by drxenos · · Score: 1

      Yes, and an integral constant expression resolving to 0 is a null pointer constant. What is your point? 0 is a null pointer constant, as is (1-1) and ((void*)0).

      Your opinion on the C++ standard is irrelevant.

      --


      Anonymous Cowards suck.
    6. Re:Null by drxenos · · Score: 1

      Also, you are confused about GCC. It does not agree with you. It warns you if you USE NULL in an expression. It does not have an issue with it BEING a integer expression. compiler this in gcc:
      int main()
      {
      void* p = 1 - 1;
      return 0;
      }

      That is a valid C program according to the standard AND GCC.

      --


      Anonymous Cowards suck.
  117. Re:It hurts you to learn C++ is still being used. by ljw1004 · · Score: 1

    95%? That's extraordinary! Inner-loops comprise 95% of your source code? I've never seen a program like that in my 25 years of programming.

  118. Re:It hurts you to learn C++ is still being used. by Kjella · · Score: 2, Interesting

    They may not be part of the language specification (and I still think that's a weird idea to begin with, but I'm old-fashioned that way),

    I work a lot with C++/Qt, but it's damn near that I want to say I program in Qt instead of C++. What's the problem with that? Well, I'm essentially lost if I have to work on a STL/WinAPI/MFC/wxWorks/boost/whatever project. Not in that I don't grok C++ which I do, but that I don't know any of the objects or functions or whatnot being in use. I do realize that there are differences between the libraries but certain basic functions should just be common, there's no reason why you'd need more than one string class. Sun got behind Java, Microsoft got behind C#, nobody got behind C++ and the result is that even the most basic of appliications can source-wise look completely different using different toolkits. It means that apart from equal syntax (and which kind of braces is the least of my problems moving to another language) there's barely something like "C++" - it's a loose family of code which happens to be compatible.

    --
    Live today, because you never know what tomorrow brings
  119. Re:It hurts you to learn C++ is still being used. by immcintosh · · Score: 1

    I'm going to have to disagree with you. For CERTAIN kinds of optimization, I'll definitely agree with you. Things like algorithmic optimization can and should absolutely wait until the whole program is finished. Certain kinds of optimization, though, need to be accounted for from the start as part of the higher level design. Or example, the choice to use a formal graph representation of your data, or a specific database representation, or (to pick an example from 3D graphics) the kind of visibility determination algorithm you use, that has implications on the design of your entire program and IS something you should optimize for in the design from the very beginning, because changing that kind of thing at the end requires MAJOR refactoring. Just my two cents, but I think it's dangerous to say you should NEVER consider optimization until the end.

  120. My crazy c++ ideas by spitzak · · Score: 1

    Stuff I would like to see, all of which is really simple:

    1. A "0" type. The typename is "0" and the only value is the constant "0". This would expose the C fact that "0" can be cast to more types than "1" or void* can. The following allows fast compile-time initialization without an if statement and without having to put these functions inline (or the typical kludge of allowing the object to be initialized with any integer, which is silly but I have seen it done):

        class Foo {
            A* p;
          public:
            Foo(0) { p = 0; }
            Foo(A* pp) { p = do_expensive_stuff(pp); }
        };

    2. Partial classes. You can already put "class Foo;" in a header file. The following syntax would allow all the same things as that statement, plus allow the getX() and setX() methods to be efficiently run:

        class Foo {
            int x;
          public:
            int getX() const {return x;}
            void setX(int v) {x = v;}
            static Foo& makeone(); ... // this ellipsis must be last
        };

    Implementation would do this to finish the Foo class:

        class Foo { ... // ellipsis must be first
            int more_stuff;
            Foo() : x(0), more_stuff(1) {}
        };
        Foo& Foo::makeone() {return new Foo;}

    Yes I know you can do something like this with a derived class but I think that is stupid to have to make two names for what is really one type of object.

    3. Even without the ellipsis shown above, you can define private inline functions outside the class definition. This allows implementation details to be hidden from the header file. Again I know it can be done with a derived class but the need for an extra dummy classname is really annoying.

        class Foo {
          public:
            int f();
            int g();
        };

    The following would be in an implementation file. It would act exactly as though the method implementation_detail() was declared in the private part of Foo:


        int Foo::implementation_detail(int) { return stuff_used_by_both_f_and_g();}
        int Foo::f() { return implementation_detail(1); }
        int Foo::g() { return implementation_detail(2)*5; }

  121. Re:It hurts you to learn C++ is still being used. by Haeleth · · Score: 1

    I think Alan Kay put it best:
    "Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind."

    Sorry to hear it. Unfortunately, the English language belongs to the people who use it, and it is popular usage that defines terms, not the opinions of the people who merely happened to coin those terms. Forty years have passed since Kay coined the term, and guess what? The meaning has shifted.

    By any sensible real-world definition, C++ supports object-oriented programming, whatever Kay might wish.

  122. Re:It hurts you to learn C++ is still being used. by caerwyn · · Score: 1

    Yes, actually.

    Structure is something like this:

    There's a core dataset. A piece of that dataset is loaded, and then a set of about 30 individual algorithms are run on that dataset; they in turn produce additional data.

    Once those algorithms are done, another set of algorithms runs on pieces of the data that the first set produced, and produces new data

    Once *those* are done, another tier of the same happens, producing final results.

    The only code that cannot be considered "tight loop" is the outer framework code that sets up the data structures and then calls the various algorithmic bits, and the code that interacts with the database. That together isn't more than a couple thousand lines of code.

    The project basically entails calling a set of algorithms repeatedly on many, many, many different sets of data, and then aggregating and analyzing the results.

    --
    The ringing of the division bell has begun... -PF
  123. Re:It hurts you to learn C++ is still being used. by ratboy666 · · Score: 1

    Please expand: C++ is a functional language? Can you actually code without (imperative) assignment?

    C++ is an OOP language? Can objects be completely isolated?

    And WHY would "smart pointers" be needed in a functional language anyway? Or even in an OOP language. Isn't the point of EITHER of these paradigms to eliminate that need?

    --
    Just another "Cubible(sic) Joe" 2 17 3061
  124. Re:It hurts you to learn C++ is still being used. by mr_mischief · · Score: 1

    There's the rub. If it's not written in both, how do you know C++ is faster? By intuition? I think the one best lesson a code profiler can teach you is that intuition is often wrong.

  125. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    I am my own customer for my primary piece of number-crunching Python. I gladly accept the fact that it takes a few hours to run instead of a few minutes like it probably would in super-efficient C++, as a tradeoff for having been able to write it so much faster.

    The customer can do their own tradeoff. If the high level language is faster, then the product should be cheaper. If the customer values speed enough to pay the extra premium for a C++ version, they can do so.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  126. Re:It hurts you to learn C++ is still being used. by ratboy666 · · Score: 1

    Sorry for replying to myself.

    I guess that C++ could (in a demented way) be viewed as a functional language. I imagine that template expansion could be viewed as functional programming (assuming your compiler doesn't blow up) to implement this at compile time.

    --
    Just another "Cubible(sic) Joe" 2 17 3061
  127. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    I entirely concede your point, while noting that this sort of higher level design optimization is completely orthogonal to choosing an implementation language.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  128. Re:It hurts you to learn C++ is still being used. by Jerry+Coffin · · Score: 1

    Write the control flow in a high-level, easy-to-debug language, and later optimize the pieces running unacceptably slow by rewriting them in C.

    If you need to rewrite something for speed, advocating C over C++ makes no sense -- for any given piece of C code, there is equivalent C++ that is just as fast, and with only a few minor exceptions (no pun intended) the exact same code will compile as either one and with an average compiler will run the same speed either way. On the rare occasion that you need to change the code at all (e.g. you've used 'class' as an identifier) the change is purely syntactic, and still has no effect on speed.

    In the other direction, it's often fairly easy to produce code in C++ that's substantially faster than any reasonable equivalent in C. An obvious case in point is std::sort compared to C's qsort. For many cases, especially primitive types like int, std::sort will typically be three to five times as fast as qsort when operating on exactly the same data.

    Most of these could theoretically be handled in C by a combination of writing specialized code everywhere needed and (perhaps) some unbelievably gross macros. I've been programming just about as long as anybody (going back as far as writing FORTRAN 66 on Control Data mainframes) and based on my experience, I'd say 1) this doesn't happen often enough to matter, and 2) thank God for that.

    --
    The universe is a figment of its own imagination.
  129. Re:It hurts you to learn C++ is still being used. by Jerry+Coffin · · Score: 1

    I'm sure you're very proud of your C++ skillz, but can you get a given task done in less time than someone using a better language?

    I don't know. Someday, when there IS a better language, maybe we'll find out.

    Don't get me wrong: IMO, C++ sucks. But the alternatives suck even more!

    --
    The universe is a figment of its own imagination.
  130. Re:It hurts you to learn C++ is still being used. by Rene+S.+Hollan · · Score: 1
    I for one, love C++. I can express sufficiently abstract generic concepts with the turing-complete template system (though the stench of the resulting syntax is duely noted), as well as deal with low-level implementation details within a single programmig language.

    As for libraries, they're there, and, IMNSHO, do not belong in the language definition.

    I like that C++0x concepts will add some type-checking to the template system, though I'm not sure I follow all the examples in the referenced article.

    I'm not sure I like the native iterator support that is proposed -- it looks too much like C# to me: where the acceptable syntax depends on the object's type to such a degree that the orthogonality of the language over the type system is broken -- and implicit conversion of explicit arrays (over objects of a base type in contiguous memory locations) to iterable objects strikes me as a hack.

    I would much rahter have the array syntax [] extended to represent enumerable (and thus iteratable) collections of objects.

    But, my biggest lamemt is no means to turn off language features in an enforcable way, much like the C# notion of "unsafe", but in a more generic fashion: nothing stops one from taking a bald pointer or reference to an object, and that busts any reference-counting memory management system right there. Either the scope of such things must be strictly controlled, or they should be selectively not permitted. That addresses the concerns of those who dislike exposure of low-level capabailities at the wrong level of abstraction, while permitting the coding of custom memory managers where necessary.

    --
    In Liberty, Rene
  131. Re:And Then COBOL 2009 by Yokaze · · Score: 1

    > Well, python+numpy in a single cpu environment can be very fast, depending on what you want to calculate.

    So can be MATLAB, as long as it matrix-multiplication, which is practically reduced to a single call to an external C++ library. Java, in contrast, has native implementations of numeric algorithms, which are on par with C(++) ones.

    > But you completely miss the point; for really computing intensive work you have to go parallel,

    I am well aware of that. I assume you've seen, that the Java version of FFT is, like the C version, running multi-threaded on a single computer. So, I guess you are talking about computer cluster.
    In that case, I/O latency and bandwidth should be the limiting factor, which should be fairly language independent. Also, communication should be only a small part of the computation time, which makes the impact even smaller.

    > and I have yet to see anything in Java that works efficiently in a parallel environment.

    Not so long ago, people argued the same way in favour for Fortran over C++, but
    as someone put it so eloquently: The absence of proof is not the proof of absence.

    From what I gather from a quick search: The results of Java MPI bindings didn't look too favourable.
    MPJava, however, suggests that comparable performance is possible (within 10% of the Fortran/MPI results in NAS PB Conjugate Gradient benchmark).

    --
    "Between strong and weak, between rich and poor [...], it is freedom which oppresses and the law which sets free"
  132. Wait a minute... by Yunzil · · Score: 2, Informative

    The C syntax is horrendous, the conversion rules chaotic

    Bjarne Stroustrup, creator of C++, is saying that C has a horrendous syntax and chaotic conversion rules...

    ...

    Hahahahahahahahaha.

  133. Re:It hurts you to learn C++ is still being used. by jcr · · Score: 1

    Someday, when there IS a better language, maybe we'll find out.

    I can name half a dozen. Maybe you should get out more.

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  134. Re:It hurts you to learn C++ is still being used. by serviscope_minor · · Score: 1

    Someday, when there IS a better language, maybe we'll find out.

    I can name half a dozen. Maybe you should get out more.

    No, you can't. At least not knowing the parent's application domain, you can't. If you think you can for me, then try suggesting a better language, so I can have a good laugh.

    --
    SJW n. One who posts facts.
  135. Re:And Then COBOL 2009 by Viol8 · · Score: 2, Interesting

    "Java, along with C, seems to be one of the few languages that have absolutely no faculties for the RAII pattern."

    Really?

    What about:
    COBOL
    FORTRAN
    VB
    Prolog
    Lisp
    ML

    In fact any non-OO languages , given that RAII is an OO concept.

  136. Re:It hurts you to learn C++ is still being used. by Champion3 · · Score: 1
    I think that the ideas behind the "Premature Optimization is the Root of All Evil" quote are best expressed in this article. The original quote was, "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." In the context of the quote, "optimization" was referring more to micro-optimizing your code by writing it in a lower level language. Notice two things:
    1. The quote mentions that we should forget about small efficiencies about 97% of the time; not 100%. There are cases (say with SIMD or something like that) where it does make sense to do it in assembly the first time.
    2. The quote doesn't mean that you should choose naive or shitty algorithms to implement your product.
    --
    I'm going to the casino. Don't gamble.
  137. Re:It hurts you to learn C++ is still being used. by Jerry+Coffin · · Score: 1

    I can name half a dozen. Maybe you should get out more.

    You claim you can without even knowing the application? Maybe you should think more.

    --
    The universe is a figment of its own imagination.
  138. Re:It hurts you to learn C++ is still being used. by Free+the+Cowards · · Score: 1

    Lots of heavy number crunching applications don't really care how long they run.

    In my case, I run my app about six times a year. Each event involves running it a few times to refine things. To me it is well worth the tradeoff to save a lot of programmer time for a few hours of CPU time, which is essentially free for me anyway.

    As for Azureus, I'm pretty sure that the Azureus programmers would be capable of making it bloated and slow in any language. Its bloat goes far deeper than just using Java. Just look at its GUI! In any case, people who use Azureus must think that it's a good tradeoff.

    --
    If you mod me Overrated, you are admitting that you have no penis.
  139. Re:It hurts you to learn C++ is still being used. by smallfries · · Score: 1

    C++ is not a multi-paradigm language. You are confusing the meaning of procedural and imperative. All OO languages are imperative (based on state mutations). The organisation of those state mutations is OO rather than procedural like C. This is quite a weak difference, they are both within the same imperative paradigm : the difference is merely how code is organised on the medium scale, and how namespaces are split.

    It is often argued that the templates in C++ form a functional language. This is partially true. Template programming can only be performed at compile-time, not at run-time so there are many programs that cannot be written this way. So it is not possible to write C++ programs in a functional style - it is only true that the type system can be abused to write some programs in a style that looks a bit functional.

    --
    Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
  140. Re:It hurts you to learn C++ is still being used. by jcr · · Score: 1

    Maybe you should think more.

    I do, and that's why I abandoned C++ around fifteen years ago.

    Look, I'm sorry that you have your ego wrapped up in defending the indefensible, but that's your own cross to bear.

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  141. Python de-compilation a problem? by Futurepower(R) · · Score: 1

    MOD PARENT UP. Calling it a "Troll" is disgusting.

    How much does it matter to you that Python is only bytecode compiled, allowing easy de-compilation?

    It seems to me that the fundamental problem with C++ is that the development of the language that will happen in 2009 or 2010 should have happened 10 years ago. It amazes me that big corporations use C++, but aren't willing to support the language.

    1. Re:Python de-compilation a problem? by Free+the+Cowards · · Score: 1

      Decompilation doesn't bother me excessively. After all, it's only mildly more difficult to reverse engineer a C or C++ program. (Assembly language gets a lot less opaque and confusing after you have some practice with it.) I will admit that it's one of the reasons keeping me from using Python for commercial desktop apps (I use it mainly for open source work, web/CGI, and personal scripts), but it's a relatively insignificant reason for me compared to things like the relative difficulty of calling platform-specific C APIs from Python.

      --
      If you mod me Overrated, you are admitting that you have no penis.
  142. Re:It hurts you to learn C++ is still being used. by serviscope_minor · · Score: 1

    So, why don't you put us out of our collective misery and tell us what language is better, then?

    --
    SJW n. One who posts facts.
  143. Re:It hurts you to learn C++ is still being used. by DamnStupidElf · · Score: 1

    If 95% of your code is in the critical path for optimization, why use C++ instead of dedicated hardware or assembly language? Perhaps if it's all numeric you can get autovectorization to pick up the slack without resorting to other languages. How much memory management do you have to worry about?

  144. Re:It hurts you to learn C++ is still being used. by caerwyn · · Score: 1

    Autovectorization does a pretty good job of boosting performance, though it's not all actually vectorizable (too many cases and branches). It is pretty much all numeric- a mixture of integer and floating point.

    Dedicated hardware is definitely not workable; the algorithms are in pretty much constant flux - it's a research application, so a lot of what's going on is testing new algorithms, or tweaking existing ones.

    Memory management is extremely minimal, by design (malloc and free aren't cheap). A chunk of data is read from the DB, a block of memory is allocated for results to be written into, and then various algorithms look at various parts of the big chunk and produce output; the DB is only hit for new data about once every hour per process (the whole thing is massively parallelizable on an extremely coarse-grained level, so we usually have well over a dozen independent processes running to split up the work- throwing more hardware at the problem is definitely something that's slowly happening, but that doesn't change the need for optimal code to reduce the amount of hardware that needs to be used).

    Assembly language is possible, of course, but the portions of the algorithms that don't change all that often and are therefore good candidates for assembly language tuning are also the portions that we get very good results from with just the compiler; the effort to move them to assembly language wouldn't get us sufficient benefit to be worth it. Oh- we're using LLVM as our compiler, which gave us a pretty decent speed boost.

    We're constantly profiling the app, tweaking algorithms for performance. New algorithms are surely written to *work* first and to be optimized second- but given that we know it's going to need that optimization, there's really no point to starting the write in anything other than c++.

    --
    The ringing of the division bell has begun... -PF
  145. Re:And Then COBOL 2009 by abigor · · Score: 1

    VB.Net does, actually. Anyway, I was referring to object-oriented languages, which I should have made clear. I included C on purpose, as various people out there will tell you how "easy" it is to write object-oriented C code, so I guess that was a bit of a dig at them.

  146. Re:It hurts you to learn C++ is still being used. by Fulcrum+of+Evil · · Score: 1

    write the intensive kernel in both and measure the performance. It should be a tiny part of the overall code, and if that's too expensive, you probably shouldn't care about the difference anyway.

    --
    "We returned the General to El Salvador, or maybe Guatemala, it's difficult to tell from 10,000 feet"
  147. Re:It hurts you to learn C++ is still being used. by Jerry+Coffin · · Score: 1
    I have no ego wrapped up in any such thing -- and I notice that even though you claim you could easily name a half dozen, you've yet to name even one.

    The fact is, given the complete lack of information you have available right now, suggestion you might make would do nothing more than open you to public ridicule.

    --
    The universe is a figment of its own imagination.
  148. Re:And Then COBOL 2009 by iznogud · · Score: 1

    You obviously never wrote a single line of (C++) server code. When you have your code running in production, and it suddenly starts to leaks after two weeks of running, there's very little you can do except to hope that your logging is good enough to help you figure out the problem. Tools to assist with memory leaks? In my experience, vast number of such tools are unusable when you go to big league (when your code uses 1+ GB of memory) - when you run your program with such tools, it usually slows down so much that you don't have a chance to see actual leak (except if it's really trivial one)

  149. Re:And Then COBOL 2009 by curmudgeon99 · · Score: 1

    I thought my reference to COBOL would be enough to imply that I meant in the corporation where I think most of us work.

  150. C++ Is for Dinosaurs by curmudgeon99 · · Score: 1

    Do you use COBOL at home? No, of course not. Some industries (insurance, finance) still do run that. C++ is gone from industry except for a few places, such as you mentioned. And companies these days don't want to spend endless time while you perfect your microscopic bit of code to do some tiny thing. Face it: developers are more productive in the newer languages: Java & C#. Those languages were invented precisely to overcome the obvious weaknesses of C++. If you are a C++ guru then you are a master of the Edsel. What I've noticed is the great number of Prima Donnas you meet in a C++ shop. Developers who have spent years perfecting some tiny app. Well, there is not time. These people cannot survive in any typical modern corporation where you get single digit days to get a large application or feature set done. If you're a dinosaur, you should just lie down and take your extinction with a smile.

    1. Re:C++ Is for Dinosaurs by smellotron · · Score: 1

      The world is bigger than you think, and there are still many places where C or C++ will smash a Java or C# solution. Calling those developers dinosaurs just makes you look ignorant.

  151. Re:And Then COBOL 2009 by curmudgeon99 · · Score: 1

    Well, full disclosure: I'm not up on the latest band aids you guys are using to overcome the inherant weaknesses in C++. I agree that C++ is a fast, powerful language. I full-well know that both Java and C# are written in C++. The fastest language of all is Assembler. Having been exposed to a tiny bit of that, I know why it's so fast in execution: it's bare metal. I do not doubt the power of C++ in the hands of the specialist. My question pertains to its suitability for the wild corporate environment. I think C++ is like Assembler. Though its raw power is always available, the difficulty of executing code in Assembler and C++ should discourage it from being used as a standard. If you want to become the expert at Assembler or C++, be my guest. I just would NEVER recommend to any company I work for that we choose C++ for a project. I have seen quite a few projects that were rewritten from C++ to Java and we ended up after the refactoring with a better executing app. The old version was so brittle and ill understood that no one was ever willing to tinker with it. The old version was opaque because it was written in C++ and of course had no notes in the code. One guy wrote it and the manual was in his neocortex. You are free to label me a troll. Anyone who pushes you from your comfort zone would qualify, I suppose.

  152. C++ = C + Simula 67 by Rick+BigNail · · Score: 1

    Nothing more, nothing less. C++0x does not change that fact.

    Having a memory model is a good thing though :)

    As the document shows from page 3 to 7, C++ values efficiency a lot. If that's a requirement C++ is great. Criticism that C++ is not Python/Java totally missed the point!

    http://www.research.att.com/~bs/abstraction-and-machine.pdf

  153. Re:It hurts you to learn C++ is still being used. by SpazmodeusG · · Score: 1

    You must not do much bit twiddling or memory alignment in C# and Java then.
    They most certainly don't do any of this on their own.
    Microsoft has entire articles dedicated to converting endianess in C# on MSDN. Java is just as bad. Which is a problem because endian conversion is often required in network communication (kind of a big deal).
    God forbid you ever have to write to a specifically aligned memory address in C# or Java.

  154. Re:Ah, the Ol' Bjarne ... by $0.02 · · Score: 1

    Just the sight of his picture makes you shudder? Oh, don't wary. It is just Pavlov's reflex, Mr Guinea Pig.

    --
    If enithin kan gow rong it whil. (Murfey)
  155. they do ... iff there's a VM for you environment by curri · · Score: 1

    For many, there isn't.

  156. Re:And Then COBOL 2009 by tknd · · Score: 1

    Java: operator overloading

    No, never. Operator overloading is one of the worst features to be added to a typed language. I don't want to have to account for a billion different cases for the + operator because someone thinks a+b looks better than a.add(b) or that the shift operator should somehow be used for streams in addition to bits. Operators belong in the realm of reserved words that should never be redefined from their original purpose. If you are defining your own operation on your own types I expect an identifier with a well chosen name rather than yet another function tacked on to the meaning of '+' that is sorta like addition but not really.

  157. Re:And Then COBOL 2009 by aurelianito · · Score: 1

    In Lisp there is something functionally equivalent to RAII. It is a macro that opens the resource, lets you pass the code to process it and closes it. Very neat, and it does not need special language support.

  158. Re:It hurts you to learn C++ is still being used. by johanatan · · Score: 1

    Very insightful point. C++ is like a Swiss army knife and those folks who tend to be negative by nature can always find something they don't like about it (much like life and everything else really).

  159. Re:And Then COBOL 2009 by johanatan · · Score: 1

    Don't forget C#, but then it's basically an enhanced form of Java.

  160. Why not D instead of Modernized C++? by weston · · Score: 1

    If you think "modern" languages are more expressive, then give "modern" C++ a try (insert comment about recent compilers here).

    If I were going to ditch my preferred more expressive language, why wouldn't I just go to something like D?

    1. Re:Why not D instead of Modernized C++? by serviscope_minor · · Score: 1

      If you think "modern" languages are more expressive, then give "modern" C++ a try

      If I were going to ditch my preferred more expressive language,why wouldn't I just go to something like D?

      Presumably because you lack reading comprehension.

      --
      SJW n. One who posts facts.
    2. Re:Why not D instead of Modernized C++? by weston · · Score: 1

      Presumably because you lack reading comprehension.

      Smart. Advocacy by insult. That'll bolster your case and show just how brilliant you are.

      I think the question's perfectly understandable and probably answerable. C++0x appears to have more or less been done (and given a more sensible name) by a guy who clearly knows C++. There's a compiler *now*. Why shouldn't I move in that direction if I want a modernized C++?

  161. Nothing to see here, move along by alexmin · · Score: 1

    Stick to your modern languages kidz, don't spoil the party B-)

  162. Re:People "hate" C++ because they aren't good enou by alexmin · · Score: 1

    Maybe you should hate C++. We really do not need that kind of expertiCe around :-)

  163. Re:And Then COBOL 2009 by smellotron · · Score: 1

    I wouldn't want to work with whoever's servers you are maintaining. None of the C++ servers I've worked on have had the same issues.

  164. Re:And Then COBOL 2009 by smellotron · · Score: 1

    What happens when you have to use 5 different objects with Dispose methods? Do you need 5 levels of indentation? I'm genuinely curious, because I've been spoiled by RAII (C++, PHP, Python), and I get frustrated in any language that doesn't have deterministic destruction by default.

  165. Re:And Then COBOL 2009 by smellotron · · Score: 1

    The proper solution is to smack the idiot developers, not hamstring the intelligent ones.

  166. Re:It hurts you to learn C++ is still being used. by iplayfast · · Score: 1

    I love that UID.
    I also like the way you explained the continuum. It is exactly right.
    You are now my friend :)

  167. Re:C++0x sucks but, uh, when's the gnu compiler du by smellotron · · Score: 1

    GCC has done a pretty good job of keeping up with ICC on Intel... even though GCC supports a multitude of other platforms. Pretty much the only place where ICC is ahead of the game (based on aggressive in-house benchmarking) is interprocedural optimization and hardcore floating-point math. Everything else is a wash, and GCC is free software. The biggest hurdle with GCC is that it takes a fair amount of compiler flags in order to get reasonable output out of it - in comparison, ICC works well (for an Intel chipset) without any extra flags. On the other hand, ICC isn't going to do well for anyone on any other chipsets...

  168. The cultural and technical problems with C++ by tjstork · · Score: 1

    Um, I'm sorry, but... what the hell are you talking about? Restricting pointers?

    Yes, restricting pointers.

    You know how you tell that C++0x disappoints? It's that arrays are still not first class objects in the language. It's that you can't do cool stuff like attach extra junk to the prologue and epilogue of a function and then walk up the call graph and put things in there. I don't see any keywords for specifying the endianness of an integer - how useful would that be.. to be able to say "bigend int foo" or "littleend int foo". I'd like to be able to specify a structure or a class which could have a single value be composed of a few bits in utterly random places in it. In other words, you could say something like:

    struct foo {
    int a bits 1-2 this+1.2, bits 4-5 this+3.3
    };

    which you would read as int a bits 1-2 are at a byte and bit offset from the structure.

    And, while we were at it, how about packed pointers. AMD64 has 64 bit pointers and we can easily stuff some extra crap at the high end of them if the compiler knew to strip it out before we dereferenced them. You could implement that as a mov and an and.

    If you do want to "guard" your pointers, it would be interesting to perhaps tag different pointers as having different selectors for those hardware architectures that support it, like Intel. I mean, you could make programs a lot safer under Intel and AMD if you didn't use a flat memory model. Put all of input data onto their own segments and lock it down with the hardware mmu. If it blows up, or overruns, oh well. No need to check arrays in that case because the hardware will do it. And of course, having some explicit language support for memory mapping seems useful.

    To me, a language like C or C++ is that you can evolve your own exact brick of memory and carve it up in some way... really, the idea of C is almost to be just to be a very fancy macro assembler and C++ was to throw a bit of object orientedness around it, if you want.

    But, instead, we have iterators and containers and ever more powerful templates and, gross, garbage collection support... that's all nice and all, but, its all indicative of a movement towards this idea that C++ is -only- an OOP language and libraries are written on building OOP programs and not necessarily smaller systems ones. C was short and sweet and simple and fast and C++ was a couple of useful things on it at first but now its just getting out of hand with this C++0x.

    The great irony, of course, is that C++ templates and, wow, look at generics in C++0x, are so incredibly powerful that, what we have is a extremely high level language that still doesn't do comma delimited output of numbers. It's schizophrenic, is what it is.

    --
    This is my sig.
    1. Re:The cultural and technical problems with C++ by Ed+Avis · · Score: 1

      Are you sure that the features you are asking for need to be implemented in the core language? Can they not be provided by libraries?

      --
      -- Ed Avis ed@membled.com
    2. Re:The cultural and technical problems with C++ by immcintosh · · Score: 1

      It's that arrays are still not first class objects in the language.

      Well, this is arguable. Arrays are essentially pointers in C++. Semantically you can define sized arrays at compile time, but a dynamically sized array (what you seem to be referring to) is just a pointer with a size counter. That sort of thing is NOT the sort of thing C++ fundamentally treats as deserving to be a "POD" type, and is perfectly find residing in the STL (std::vector). I, personally, see absolutely no problem with this.

      I don't see any keywords for specifying the endianness of an integer - how useful would that be.. to be able to say "bigend int foo" or "littleend int foo".

      Not very? I dunno, for cross-platform work maybe? I've honestly never had a particular urge to switch the endianness of an integer, or come across a situation where it would be terribly important. Do you have an example? I honestly can't think of much.

      I'd like to be able to specify a structure or a class which could have a single value be composed of a few bits in utterly random places in it. In other words, you could say something like:

      struct foo {
      int a bits 1-2 this+1.2, bits 4-5 this+3.3
      };

      which you would read as int a bits 1-2 are at a byte and bit offset from the structure.

      This looks like something you could accomplish with bit fields. But maybe I'm not reading your meaning correctly? Is there something here that couldn't be accomplished with a well laid out bit field?

      And, while we were at it, how about packed pointers. AMD64 has 64 bit pointers and we can easily stuff some extra crap at the high end of them if the compiler knew to strip it out before we dereferenced them. You could implement that as a mov and an and.

      This is really a feature I would classify as "arguably" useful. As in, maybe something that would come into play for embedded development, or driver development? Honestly, again, not something I've ever really wanted, but maybe you could provide another example why? Definitely not something I'd consider important for inclusion into the core language, that's for sure.

      To me, a language like C or C++ is that you can evolve your own exact brick of memory and carve it up in some way... really, the idea of C is almost to be just to be a very fancy macro assembler and C++ was to throw a bit of object orientedness around it, if you want.

      But, instead, we have iterators and containers and ever more powerful templates and, gross, garbage collection support...

      C and C++ are for getting things done. Having a fancy, user-readable assembly language may be great for people who are doing embedded and driver development, but for the vast majority of us, we WANT high level features which make the language as expressive as possible. There's nothing stopping you from just confining yourself to the lowest level corners of the languages, popping inline assembly in where you want it, but that's not really the POINT of the language.

      The great irony, of course, is that C++ templates and, wow, look at generics in C++0x, are so incredibly powerful that, what we have is a extremely high level language that still doesn't do comma delimited output of numbers.

      What? Again, this doesn't make sense to me. I can name have a dozen methods of varying complexity to accomplish comma delimited output. This another one of those things that doesn't belong in the CORE language. This is something that SOME people need to do, and SOME don't, depending on the vagaries of their projects. As such, it absolutely belongs in an external library, and again not as a core language feature.

      To be honest, what seems the most schizophrenic here is your claiming in one paragraph that you want C++ to be some sort of glorified assembly language, and then going on to complain that it doesn't do comma delimited output. I'm sorry, I just don't get it.

    3. Re:The cultural and technical problems with C++ by tjstork · · Score: 1

      Well, this is arguable. Arrays are essentially pointers in C++. Semantically you can define sized arrays at compile time

      I'll give you this. What frustrates me is the lack of multidimensional arrays of various types, but I'm looking at Boost and I think tuple is a better solution for what I'm trying to do. Actually, I might have to take back everything bad I said as I'm sitting here reading through boost and the C++0x standard and I'm like, this is really, really cool.

      --
      This is my sig.
  169. Re:It hurts you to learn C++ is still being used. by SomeKDEUser · · Score: 1

    This is wrong on many levels. You claim you like your dynamic languages. Fine, but this also means you only use them for tasks where the cost is acceptable.

    The run-time cost, and also the hidden errors, because you obviously do not understand why there are types in the first place.

    Which in turns means there is something profound about maths and formal logic that you have not yet understood.

    So you are in essence claiming that your ignorance is not only a valid opinion, but also the valid opinion.

    You also claim that raw machine code is ultimately powerful or versatile. This assumes you are capable of producing better assembly than your compiler. All the time. Which is no small feat nowadays.

  170. Re:It hurts you to learn C++ is still being used. by shutdown+-p+now · · Score: 1

    I have forgotten more C++ than most people know, having written everything from a reference-counting garbage collector to an entire content management system in it

    A "reference-counting garbage collector" - assuming it means what it should - is a trivial C++ exercise, a hundred lines of code at most. A CMS is nothing big either.

  171. Re:It hurts you to learn C++ is still being used. by shutdown+-p+now · · Score: 1

    In fact, the philosophy of Qt is closer to Java or C# - and C++ language features used by Qt itself are mostly restricted to the same subset, too.

  172. Re:It hurts you to learn C++ is still being used. by shutdown+-p+now · · Score: 2, Insightful

    I think Alan Kay put it best: "Actually I made up the term "object-oriented", and I can tell you I did not have C++ in mind."

    Kay goes on further to categorically state that C++ does not support object oriented programming because of the static type system.

    Kay can say anything he likes, but he did not invent the first OO language - it was Simula 67, also a statically typed language, and OOP in C++ has very visible roots in Simula (dot-notation to access members, "virtual" and "protected" originate there, for example; but in general, the very concepts of classes with methods and fields, combined interface/implementation class inheritance, object instances, special syntax for message receiver in a method call, object identity, object references and null, upcasting and downcasting, explicit polymorphism via virtual declarations and overrides, controlled encapsulation by means of visibility levels, etc).

  173. Re:And Then COBOL 2009 by shutdown+-p+now · · Score: 1

    Proper RAII, which many programmers mistakenly believe to be useful for memory management ONLY (scoped locks come to mind) (Java/C# finalizers are no replacement)

    Well, C# is halfway there with Dispose and "using" blocks - using them to perform some actions on exit from a block are fairly common. Though "finally" is really a better replacement for scoped guards that are specific to a single piece of code.

  174. A Deeply Skeptical Look at C++0x by libcrypto · · Score: 1

    Came across this link at reddit just yesterday: http://importantshock.wordpress.com/2008/08/20/a-skeptics-look/

  175. Ada? by pinkfloydhomer · · Score: 1

    Ada + a modern library meets most of the requirements. To ease learning, an "ugly" version of Ada using C/C++/Java/C#-like syntax could easily be made.

  176. You forgot one major problem... by master_p · · Score: 1

    ...header files. Having to manually synchronize header and implementation files each time the design changes is a major pain the butt. It takes away valuable time and greatly distracts from the mental process that is design of a program.

    1. Re:You forgot one major problem... by Free+the+Cowards · · Score: 1

      No, I didn't forget anything. They don't bother me. Please don't try to put your words into my mouth.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    2. Re:You forgot one major problem... by master_p · · Score: 1

      It was not personal...header files is a big headache for any serious program.

  177. The situation is not as rosy as you think by master_p · · Score: 1

    Boost is actually very easy to integrate for most of its features. A few (small handful) of its components require compilation, but the vast majority of them are template-based and header only. Meaning just include a header file and there you go, you're using boost. No extra compilation/installation required.

    That is, until you try to combine it with other libraries, like Qt, for example. Boost has a namespace signals, Qt has a #define signals. Yes, you can solve the problem using the preprocessor, but boost was supposed to be 'plug-n-play'...

    I have trouble imagining a situation where a real garbage collector would ever be superior to an RAII model with shared smart pointers for stuff allocated on the heap, outside of plugging up a leaking legacy app.

    Smart pointers are difficult to manage in the context of complex object relationships. See my other post for more info.

    Maybe for very simple programs, but once you get non-trivial destructors (for example, with objects that lock system resources), then you start having to do manual memory management in your GC environment anyway, and end up with a horribly ugly conglomeration of "mixed metaphors" as it were.

    The idea that destructors don't play well with GC is largely a myth. Non-trivial jobs should not be done in destructors. But even if they are done in destructors, they should be invoked using RAII style. The destructor is only a function, so it can be called normally just like any other C++ function.

    Smart pointers really give you the best of both worlds: deterministic destruction, without having to worry about manually releasing anything. It's just a matter of getting used to declaring a smart pointer wherever you would have a "type *name" instead. So yes, I'd argue they ARE a substitute for garbage collection in almost any situation.

    As I explain in my other post, the problems of cyclic references introduced indirectly, the situation where you only have 'this' and you should use shared_ptrs, etc are great problems and you should not underestimate them.

    1. Re:The situation is not as rosy as you think by immcintosh · · Score: 1

      That is, until you try to combine it with other libraries, like Qt, for example. Boost has a namespace signals, Qt has a #define signals. Yes, you can solve the problem using the preprocessor, but boost was supposed to be 'plug-n-play'...

      That's really the case with any situation where you have two libraries which implement the same functionality though. It's hardly a problem that's confined to Boost, or even C++. The nice thing about boost signals though is you can pass ANY functor (functions, member functions, function objects) through them.

      Smart pointers are difficult to manage in the context of complex object relationships. See my other post for more info.

      Regarding your other post, while I'm not 100% sure what you're getting at, if it is what I think it is, then you are actually incorrect. See here. I can certainly understand being averse to Boost's smart pointer implementation if you weren't aware of this functionality.

      The idea that destructors don't play well with GC is largely a myth. Non-trivial jobs should not be done in destructors. But even if they are done in destructors, they should be invoked using RAII style. The destructor is only a function, so it can be called normally just like any other C++ function.

      But then you're more or less defeating the entire point of garbage collection, which is not having to worry about manually releasing any resources when they go out of scope. Once you start requiring that resources be manually deallocated before being let out of scope, you've just lost any real benefit of using a GC model in the first place. Sure GC *can* work with non-trivial destructors, but in doing so you lose the real benefits you've gotten from GC in the first place, which is why I claim that smart pointers are actually much more suited to such a situation because they retain that same benefit.

      As I explain in my other post, the problems of cyclic references introduced indirectly, the situation where you only have 'this' and you should use shared_ptrs, etc are great problems and you should not underestimate them.

      I do concede that cyclic references are the weakest aspect of smart pointers, and do require a little more work in the design of your software to avoid them. I will admit though, if you have a situation where cyclic references are legion, then GC might be a superior choice. With limited cyclic references, however, weak smart pointers are a perfectly elegant solution. It's usually obvious from a design perspective which pointers should be made weak.

    2. Re:The situation is not as rosy as you think by master_p · · Score: 1

      The nice thing about boost signals though is you can pass ANY functor (functions, member functions, function objects) through them

      It goes without saying that function binding and lambda functions is THE most important feature of any programming language. I like boost for this, and I think it should be in the STL, but my comment was about how integrating boost with other libs may not be as easy as it sounds. Or any other two c++ libs, for that matter. You see, in C++, every toolkit/library/framework is its own universe.

      Regarding your other post, while I'm not 100% sure what you're getting at, if it is what I think it is, then you are actually incorrect. See here. I can certainly understand being averse to Boost's smart pointer implementation if you weren't aware of this functionality.

      Indeed, I was not aware of it. But the docs don't have it. Where I was supposed to find it? I went on and did my own implementation, complete with a SharedObject base class that does just this.

      But then you're more or less defeating the entire point of garbage collection, which is not having to worry about manually releasing any resources when they go out of scope.

      That's not the point of GC. The point of GC is to have complex object relationships, i.e. to manage memory, without worrying too much about how the memory is freed.

      Once you start requiring that resources be manually deallocated before being let out of scope, you've just lost any real benefit of using a GC model in the first place.

      Nope, you use RAII for that. You use RAII to manage resources deterministically, except for memory.

      Sure GC *can* work with non-trivial destructors, but in doing so you lose the real benefits you've gotten from GC in the first place, which is why I claim that smart pointers are actually much more suited to such a situation because they retain that same benefit.

      No, you don't lose anything. With GC, you can do things like circular references and stuff without having to think about them. And a whole bunch of other stuff smart pointers can't do. And then there is the problem of performance: all those increments and decrements that are also atomic put a serious constraint in performance.

      I do concede that cyclic references are the weakest aspect of smart pointers, and do require a little more work in the design of your software to avoid them. I will admit though, if you have a situation where cyclic references are legion, then GC might be a superior choice. With limited cyclic references, however, weak smart pointers are a perfectly elegant solution. It's usually obvious from a design perspective which pointers should be made weak.

      Ok, smart pointers are not that bad. In my current project, around 50,000 lines of code, I don't have any deletes. But I had to be really careful not to introduce any cyclic references. And the performance is not what it could have been. There are lost CPU cycles in atomic increments and decrements. And the code is on the ugly side...

    3. Re:The situation is not as rosy as you think by immcintosh · · Score: 1

      Indeed, I was not aware of it. But the docs don't have it.

      Yeah, it's definitely buried in the documentation, but it is there. The link I gave you was direct to the boost docs. Unfortunately a lot of the stuff is like that, and I'd really recommend going through the documentation for any boost lib thoroughly before using it. It helps a LOT.

      ...various comments regarding garbage collection...

      I guess we simply have conflicting views on the ultimate goal of various resource management schemes. My take is that whatever memory management scheme you use, the real point, and the primary consideration, is essentially twofold: how easy it makes the task of managing memory, and how many potential errors it can eliminate.

      My point regarding garbage collection is that one of its primary design goal (if not the primary design goal) is to eliminate to need to manually track allocations and deallocations (essentially everything should be "fire and forget" in an ideal GC environment). This eliminates the burden of having to do it manually, and the potential errors of forgetting to do so. I say this with respect to the assumption that raw pointer handling (new/delete or malloc/free) is essentially our "memory management baseline." For complex resources, however, my complaint against GC is that it introduces the overhead of having a collection process running in the background (or at various intervals or whatever), but without any usability benefits over just using new/delete. I still have the burden of having to release them manually, and the potential errors of forgetting to do so. If I have to remember to release my resources when I'm done with them anyway, why would I use GC in the first place and not just stick with new/delete? In practice it's effectively the same--I'll be manually allocating and manually releasing resources either way.

      This is why I personally prefer to use smart pointers most of the time, particularly in that most of the programming I do these days makes extensive use of limited resources that must be released promptly when they are no longer absolutely needed. I prefer just being able to simply drop the pointer and let it fall out of scope, no further intervention needed, and its various resources are all immediately freed. This allows me to share pointers among various components without having to worry about tracking when they are all done with it--when they are, it's all taken care of behind the scenes as it were. This is as opposed to a garbage collection scheme, where I would still have to track and manually release those resources if I want them to be returned to the system without having to wait on the collection cycle, which can be very important.

      Cyclic pointers are a problem, but one that can be designed around, particularly once you get used to doing so. Probably this is the real significant drawback of smart pointers vs. garbage collection, and the one consideration that might make me prefer GC under certain circumstances where there are a large number of them.

      As for efficiency, that goes both ways. Garbage collection introduces its own overhead. Generally the overhead just manifests differently between smart pointers and GC though. With smart pointers the added overhead tends to be more spread out, as pointers are individually allocated and drop out of scope. With GC, it tends to come in big "lumps," when the collector decides to scan for dependencies. As for atomic increments/decrements, those tend to be fairly fast, as (correct me if I'm wrong) most modern processors provide machine level commands for those sorts of atomic operations without having to resort to locks/mutexes. Not as fast as a non-atomic operation of the same sort, but fast enough not to be a problem in this context.

    4. Re:The situation is not as rosy as you think by master_p · · Score: 1

      Yeah, it's definitely buried in the documentation, but it is there. The link I gave you was direct to the boost docs. Unfortunately a lot of the stuff is like that, and I'd really recommend going through the documentation for any boost lib thoroughly before using it. It helps a LOT.

      It's not possible to search for something when you don't know it exists.

      For complex resources, however, my complaint against GC is that it introduces the overhead of having a collection process running in the background (or at various intervals or whatever)

      The overhead from GC is negligible. I am also a Java programmer, and Java is way faster than C++ in the same algorithm (with C++ using smart pointers). I've done a little research regarding the use of Boehm's gc, and in that context, I measured various things using Boehm's benchmark (if you search the relevant newsgroup, you'll find it).

      but without any usability benefits over just using new/delete. I still have the burden of having to release them manually, and the potential errors of forgetting to do so.

      But you don't have to release them manually! I've said it twice before: you use RAII for files, sockets etc, and GC for anything else. It's simple, it works, and it covers most cases.

      As for atomic increments/decrements, those tend to be fairly fast, as (correct me if I'm wrong) most modern processors provide machine level commands for those sorts of atomic operations without having to resort to locks/mutexes

      At the lowest level, caches are locked and synchronized and the other cores enter a spin loop. It's an overhead that, if you don't use many smart pointers, it's negligible, but when you use thousands of them in arrays or collections, it starts to show, especially when measured against GC. In modern collectors, the overhead is way way way less than smart pointers, especially for those collectors that use the underlying hardware (the page mechanism) to tell when something has changed. Modern collectors are also multithreaded: they split the workload into equal parts, thus getting an almost linear scaling with the number of cores. Whereas with smart pointers, if two cores look at the same memory location, an atomic operation will lock the caches and stall both CPUs.

    5. Re:The situation is not as rosy as you think by immcintosh · · Score: 1

      It's not possible to search for something when you don't know it exists.

      You're right; I think I didn't phrase that properly. I was trying to say that the Boost documentation is such that you are best served by thoroughly reading the entire documentation on a library before using it. There are too many hidden/non-obvious things in there that end up being very important to just pick it up and use it and only refer to the documentation as needed, sadly.

      But you don't have to release them manually! I've said it twice before: you use RAII for files, sockets etc, and GC for anything else. It's simple, it works, and it covers most cases.

      Yes, which is great when everything of this sort can reside on the equivalent of the C++ stack (assuming the GC system/language you're using has such a distinction and EVERYTHING isn't like a heap allocation). Am I missing something here? All RAII means is that the resource is allocated when the object encapsulating it is created, and deallocated when that object is destroyed. You can have RAII in a GC environment too, but the problem is it's non-deterministic (you don't generally know when it will actually happen).

      I guess my question is, how do you go about achieving determinstic object destruction in a GC environment, which is what's required for RAII to be effective with non-trivial destructors? As far as I'm aware, you don't, and that's one of the drawbacks.

      It's an overhead that, if you don't use many smart pointers, it's negligible, but when you use thousands of them in arrays or collections, it starts to show, especially when measured against GC.

      It's an overhead that adds up if you are passing around thousands of smart pointers, not just leaving them in collections. Keep in mind that C++ collections usually to pass/return their elements by reference, so there are no copy semantics in accessing a smart pointer in a collection and thus no additional overhead outside of whatever is required for dereferencing. I honestly can't think of a reason you would ever be passing thousands of smart pointers around on a regular basis. I'm sure there may well be, but not in designs I've ever had to deal with.

      Additionally, many of your arguments assume that the pointer is being used in a multi-threaded environment, AND that there is no guarantee of any kind of thread locality. Otherwise atomic operations would simply be unnecessary.

      I will say, this debate has been productive for me. While I'm not convinced that any use cases I'm concerned with would benefit from GC, you do make the case for there BEING use cases where it is potentially advantageous. It does make sense that if you find yourself in the situation of passing a large number of pointers among threads on a regular basis, GC would be more efficient. Passing within a single thread, though, I'd like to see some sort of benchmark between the two. My intuition tells me that GC would only pull ahead in that case after what I would describe as an "unreasonable" number of pointer copies. Could be wrong though.

    6. Re:The situation is not as rosy as you think by master_p · · Score: 1

      I was trying to say that the Boost documentation is such that you are best served by thoroughly reading the entire documentation on a library before using it.

      Theoretically, you are correct. But there is no time to read everything, especially when under pressure to finish a project on time.

      assuming the GC system/language you're using has such a distinction and EVERYTHING isn't like a heap allocation

      I am talking specifically about C++, which has most values allocated in the stack. That's the reason C++ produces the fastest code anyway.

      All RAII means is that the resource is allocated when the object encapsulating it is created, and deallocated when that object is destroyed. You can have RAII in a GC environment too, but the problem is it's non-deterministic (you don't generally know when it will actually happen).

      Your definition of RAII is wider than mine. I was talking specifically about stack-based RAII. The one great thing in C++, and the reason I don't give up on it, it's that destructors are called at procedure exit. That's so great! it helps with a lot of problems. I solely miss this in Java, where I usually have to declare the same code inside finally clauses and outside of finally clauses.

      I guess my question is, how do you go about achieving determinstic object destruction in a GC environment, which is what's required for RAII to be effective with non-trivial destructors? As far as I'm aware, you don't, and that's one of the drawbacks.

      Of course, you're right. But the question is moot with stack-based RAII.

      It's an overhead that adds up if you are passing around thousands of smart pointers, not just leaving them in collections.

      Smart pointers are not for collections only. I am surprised that almost everyone has such a narrow scope, as if no one has ever made a complex program.

      For example, in my current project, I have to create hundreds of objects per second (radar plots). Each plot is not a simple POD object: there is a hierarchy of classes, each plot having its own attributes, and some plots are associated with other plots. The associations are done via pointers. The plots are fed to a series of complex processes, different threads, that do different things on the objects (for example, checking for collisions, providing alarms after specific events, interfacing with external systems (Link 11, Link 16, AWACS etc).

      It goes without saying that:

      1. it was not possible to treat these objects as values. Some objects are huge, in the range of kilobytes (you can't believe how much data a radar can produce).
      2. All associations are done with smart pointers. The object model is very complex, and I not that sure that there are not cyclic references in there.
      3. The overhead of managing reference counts atomically is measurable. A single frame of data is captured and processed at almost half the time when using raw pointers (and no deletes!) compared to using smart pointers. The overhead also includes the cost of allocation/deallocation. If I had a good threaded garbage collector, allocation would be almost for free (because GC allocators usually increment a pointer), and deallocation would be almost free if the CPU has more than one core (because the garbage data can be processed by a separate thread running on a different CPU). No such lack with smart pointers.

      Additionally, many of your arguments assume that the pointer is being used in a multi-threaded environment, AND that there is no guarantee of any kind of thread locality. Otherwise atomic operations would simply be unnecessary.

      I have never coded an application with less than two threads. Even for my personal projects, I put long jobs in different threads, so as that the GUI is not blocked. My current application may have up to 30

    7. Re:The situation is not as rosy as you think by immcintosh · · Score: 1

      Theoretically, you are correct. But there is no time to read everything, especially when under pressure to finish a project on time.

      Yeah, I'm just crazy that I read the boost docs for fun ;)

      I am talking specifically about C++, which has most values allocated in the stack. That's the reason C++ produces the fastest code anyway.

      The use of the stack in C++ is fairly limited. It's really only for small objects that can be passed around by value, and not for long-lived objects. Like I was saying, anything complex enough to have a non-trivial destructor is probably going to be too complex to be useful allocated on the stack.

      The one great thing in C++, and the reason I don't give up on it, it's that destructors are called at procedure exit. That's so great! it helps with a lot of problems.

      Well, that's the whole point of smart pointers. You get the EXACT same kind of determinism with your destruction, without having to use only local variables.

      Your definition of RAII is wider than mine.

      That's Bjarne Stroustrup's definition. He coined it as a general design pattern that should be used whenever possible.

      Smart pointers are not for collections only. I am surprised that almost everyone has such a narrow scope, as if no one has ever made a complex program.

      For example, in my current project...

      Memory pools? Now clearly you know the project better than I do, but for situations like you describe, I don't think standard smart pointers OR garbage collection are really appropriate. Large scale allocation/deallocation of homogenous data types, that really sounds like something where you want all those resources in a pre-allocated memory pool that you can just draw from and release to at a whim with virtually no overhead compared to memory allocation in either system. Then again, maybe there are factors preventing the system being designed around memory pools? Anyway, that's certainly the solution I would choose given those criteria.

      Well, I hope that after reading this last post of mine, you understand what kind of situation I am into. C++ is considered a systems language, and so our customers demand it. But their problems are big and complex, and if C++ had GC, the solutions would be better from all perspectives (faster coding, less debugging, less expensive, etc).

      Is there a reason you can't use the very excellent Boehm garbage collector library for C++? Obviously if there's a reason your particular project will benefit from it, it might be worth considering. My argument is really only against how appropriate that functionality would be as a core feature of C++.

    8. Re:The situation is not as rosy as you think by master_p · · Score: 1

      Yeah, I'm just crazy that I read the boost docs for fun ;)

      Or you may have too much free time on your hands :-).

      The use of the stack in C++ is fairly limited.

      On the contrary...C++ is the one language which uses the stack most.

      It's really only for small objects that can be passed around by value, and not for long-lived objects.

      True. But the majority of objects are small...around 90% for a project. That's why generational GC was born. C++ does not need that, it has the stack!

      Like I was saying, anything complex enough to have a non-trivial destructor is probably going to be too complex to be useful allocated on the stack.

      I don't think so...on the contrary: anything complex enough to have a non-trivial destructor is usually a job to be executed at the end of a procedure, so it's natural to declare it in the stack and let the destructor be executed upon procedure exit.

      Well, that's the whole point of smart pointers. You get the EXACT same kind of determinism with your destruction, without having to use only local variables.

      You don't get any real determinism. In a complex program, you don't know when the last reference will be destroyed. It's the same as in GC. You may think you know, but it's unprovable (halting problem etc). You only get a bunch of problems as I mentioned in a previous post.

      That's Bjarne Stroustrup's definition. He coined it as a general design pattern that should be used whenever possible.

      I thought Stroustrup meant it for stack allocation only. Anyway, it's much better to put RAII on the stack, because for better performance and guarranteed cleanup. There is no point in using smart pointers, even if a resource is passed around as a pointer.

      Large scale allocation/deallocation of homogenous data types

      You said homogeneous...I said heterogeneous...nevertheless, using memory pools, the only problem solved is that of allocation/deallocation. I solved the problem using the allocator of Doug Lea, which is roughly equal to memory pools. Still, the computer does redundant work when compared to GC.

      Is there a reason you can't use the very excellent Boehm garbage collector library for C++?

      Yes it is. It's not excellent, by a long shot. Usually it does not compile for Windows. When it does, it has all shorts of strange behaviors. Support is non existent; I have tried to use it a lot but I stumbled on problems and while I repeatedly asked for help, I was not given any. It does not play well with DLLs. It does not play well with things initialized before main. I am using Qt in this project for the UI, and Qt has its own memory management system, so I can't bind the two (Boehm + Qt) unless I am really careful and know what Qt does like I wrote it.

    9. Re:The situation is not as rosy as you think by immcintosh · · Score: 1

      I guess at this point is just comes down to us having very different experiences with the use of C++.

    10. Re:The situation is not as rosy as you think by master_p · · Score: 1

      Actually, the problem of nobody having a reference to a stack object is very easily solvable, using reference counting.

    11. Re:The situation is not as rosy as you think by master_p · · Score: 1

      From within the destructor of the class that encapsulates the reference count, you throw an exception if the object is still referenced.

    12. Re:The situation is not as rosy as you think by master_p · · Score: 1

      Indeed, but at least you know that a stack object was prematurely destroyed and you can adjust your algorithm accordingly.

    13. Re:The situation is not as rosy as you think by master_p · · Score: 1

      All programming languages cause that, don't let anyone fool you. Due to the halting problem, there is no general algorithm to prove the correctness of any program, thus all the programs have bugs in them.

  178. Let me clarify by salec · · Score: 1

    And you're saying leave that to the programmer??? That's the biggest maintenance nightmare I have EVER heard of.

    I just don't think it should be left to the whims of some dude in the back room that would never document his intent and execution properly.

    If you do go ahead and write it, ...

    I can see you are very tempted with the idea of unlimited power but you struggle to keep your sanity (*my preciouss*)...

    Yes, it IS a lot like putting all the eggs in one basket ... it requires WATCHING OVER THAT BASKET LIKE A HAWK! Hopefully, it should be easier then watching all over wide area of baskets (whole project). With it, you could actually *take away* freedom to do many stupid things from your underling code monkeys.

    The dangerous "freedom" is just theoretical. Flexibility may mean more freedom, but also less freedom, of for that matter, same amount of it as it is presently. First of all, the language would have to carry "standard set of rules definition" with it, but including them in your project would be optional and RECOMMENDED. Rule sets would not be designed by any programmer (like probably someone you regret to know, or whose code you regret to had to read), but by an expert (e.g. a CS PhD) who is capable of properly detecting problems and devising solutions.

    It is near equivalent situation to C/C++ system API being moved from language definition into accompanying standard library: you *could* write your own library replacement, or even not use any at all (in small embedded systems development), but hardly ever anyone does anything like that. However, should it become absolutely necessary, it could be done. Of course, anyone could write their own rule sets, if they dared, but it will be considered dangerous and not recommended, just like messing with standard library. Someone more foolish, toying with programming for fun, or knowing very well what they do, could also do some stunts without safety gear, hopefully in some very thoroughly isolated and well documented performance-critical part of code.

    Imagine integrating language contemporary best practices and recommendations, your own organization coding standards, your project specific safety (or style) rules, thus (by means of having each coworker #include-ing header file with their definition in each source file) instantly enforcing them project-wide, all in modular and layered manner? Over time accumulated experience will be possible to transfer onto new projects. I think it could be great collaboration (hmm, an one-way collaboration) tool.

    Admittedly, saying about a project that it was written in such a language would not mean any hint of measure of its quality any more. Instead, one would say that certain well known and respectable set of rules was applied to the project, and then we would know that it was enforced by compiler, not left to whim of developers to "respect" and prone to bugs wiggling through the loopholes of manual code inspections.

  179. Re:It hurts you to learn C++ is still being used. by cheekyboy · · Score: 1

    Most of any app doesnt need the speed, but sometimes there are small components that need the speed, that if written in java/c# would be 10-50x slower due to less reductions in memory movement.

    Given that, it still possible to make slow C code, just look at windows and how sometimes icons take forever to refresh from empty blobs to images on the desktop. (poor design).

    For enterprise style apps, that need to scale and handle billions of objects, only C or C++ or ObjC will cut it.

    Then again... I am supprised intel wont push java/c# more, because that will increase demand for faster CPUs.

    --
    Liberty freedom are no1, not dicks in suits.
  180. Re:And Then COBOL 2009 by bar-agent · · Score: 1

    The proper solution is to smack the idiot developers, not hamstring the intelligent ones.

    Intelligent developers can deal with not having operator overloading. Idiot developers can't deal with having it.

    --
    i'd hit it so hard, if you pulled me out you'd be the king of britain [bash.org]
  181. Re:It hurts you to learn C++ is still being used. by Just+Some+Guy · · Score: 1

    The run-time cost, and also the hidden errors, because you obviously do not understand why there are types in the first place.

    Nice try, son, but I've probably been hacking long than you've been alive. Trust me, I know what types are and why they're good, and also why strongly typed, dynamic languages are so popular right now.

    If a program is running too slow, I see if there are algorithmic improvements I can make. Failing that, I replace critical parts with C (or C++). Failing that, we buy more hardware. I am far more expensive than any of the servers we own, and my boss is much more interested in paying me to add new features for our customers than to wring another 2% out of optimized, correct code.

    Which in turns means there is something profound about maths and formal logic that you have not yet understood.

    Lisp is also dynamically typed, and much beloved by computer scientists everywhere. Apparently there is more to math and formal logic than you've learned so far.

    You also claim that raw machine code is ultimately powerful or versatile. This assumes you are capable of producing better assembly than your compiler.

    No. It assumes that I am capable of producing more versatile assembly than my compiler. Of that, my friend, I am certain.

    --
    Dewey, what part of this looks like authorities should be involved?
  182. Re:It hurts you to learn C++ is still being used. by pherthyl · · Score: 1

    And where are the other choices? Was it really Java vs. C++, with no other options?

    If you had bothered to read the next sentence.... Other languages have other problems as I mentioned. But feel free to suggest an alternative

    You are stuck in the mindset where all aspects of an application need to be written in the same language.

    No, but that only makes sense when there is some huge compelling advantage for using another language. Sure, for a web frontend use PHP/Java/C#/Whatever, or if some critical lib is only available to a specific language, then it is justified, but for the most part, additional languages only bring more hassle.

    Your problem is that you've worked on some crappy C++ code using crappy class libraries and therefore are stuck in preconceptions like someone would be "doomed to use C++". Sure I could write some parts of the code in Python or whatever, but there wouldn't be any point. C++ is just as easy (again, with the right class libraries) and runs faster.

  183. Re:It hurts you to learn C++ is still being used. by dkf · · Score: 1

    And I can say with a straight face that you are wrong.

    I'm glad I'm not playing you at poker.

    --
    "Little does he know, but there is no 'I' in 'Idiot'!"
  184. Re:It hurts you to learn C++ is still being used. by Hognoxious · · Score: 1

    Nah, it's not funny and certainly not original the second time. Your reply really boils down to "I know you are, but what am I?".

    And for a really good "fixed that for you" you need to be a little more subtle. So replying to a post about Iran being an evil theocracy, just s/Iran/USA/. Got that, pottymouth?

    Lame.

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  185. Re:It hurts you to learn C++ is still being used. by Hognoxious · · Score: 1

    A) I never said we rewrote the app.

    Let' backtrack a little, shall we?

    mangu: Try writing a large program that needs to do heavy number-crunching in Java/Ruby/Perl/Python, or whatever is your preferred language.

    you: I have on numerous occasions...and you know what? It was just as fast in Java.

    So we've established that you're a liar, the question is then or now?

    --
    Confucius say, "Find worm in apple - bad. Find half a worm - worse."
  186. Re:It hurts you to learn C++ is still being used. by ardor · · Score: 1

    Well, you might want to tell Adobe that. Hint: they do use this modern C++ you abhor. You did use Photoshop, right?

    Also, your conclusion is flawed. Since when does the best solution automatically win? The one which gets strongly pushed, hyped, marketed etc. is the one that wins, NOT the best one.

    Instead of that they have been built using "toyish" (hey, they don't have things such as multiple inheritance etc what the C++ nerds always whine about) languages that actually lack most of the "nice" things of C++.

    Yes, because 20 mediocre programmer code monkeys are cheaper than 4 top-class developers. Java is primitive, thus easy to grasp. C++ is not, even without the hideous syntax that artificially increases the difficulty. Its simple: if one language has more features and expressiveness than another, the latter is better suited for the average code monkey. Also, code monkeys are expendable, top-class developers are not. A manager's dream.

    except that it takes 10 times more time to develop in C++

    Now we have to be precise here. Remove enough bits of the Java standard library to equal C++'s in size, THEN judge again. People keep comparing plain C++ with a JDK-doped, Eclipse/IDEAI-enhanced Java. This brings us to Java's REAL advantage: its toolchain and SDK. Both are very good. Without them, the language is worthless.

    --
    This sig does not contain any SCO code.
  187. Re:It hurts you to learn C++ is still being used. by jcr · · Score: 1

    I have no ego wrapped up in any such thing

    Sure you do. There's no other reason to advocate C++.

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
  188. Re:It hurts you to learn C++ is still being used. by cnettel · · Score: 1

    Lots of heavy number crunching applications don't really care how long they run.

    I would say that is true for number crunching, but not for heavy number crunching, with any reasonable definition for heavy. 10 or 20 twenty times faster would generally mean that you can go down from running it on a cluster overnight to running it on a local machine, which tends to be more convenient -- or run it over a coffee break on that cluster.

    If you ever cared about multithreading to be efficient on modern systems, you should seriously consider what language you use as well.

  189. Re:Ha! Yeah right. by cnettel · · Score: 1

    Well, one reason to find it funny is that function calls are expensive these days. Small operations encapsulated in libraries that are only available through linking can degrade performance, even if the implementation is superior. That's one reason to prefer inline assembly in C++. To top it off, introduce the specific implementations as template specializations, for example hand-unrolled loops for a few specific small sizes. That is simply not possible to do in C, or macro assembler, without introducing a maintenance mess.

  190. Intel on AMD by tjstork · · Score: 1

    I've always liked the Intel compilers... and I even once plinked down some bucks for the Intel compiler and vTune when I was writing commodity server back in the day... but the thing that keeps me away from Intel now is that I don't know how much I can trust that compiler to produce good code for AMD chips. Even though they have nearly the same instruction sets, they are very different internally and it follows that the timings and sequences of the instructions might well be different. I just don't know... and the other thing too is that I don't know how well deploying an Intel compiled solution would even fly on a Linux platform. Doing a source / make solution almost seems like it would be out of the question. Are these perceptions unfounded, or are they accurate. I defer to your experience and await your answer literally with baited breath.

    --
    This is my sig.
    1. Re:Intel on AMD by smellotron · · Score: 1
      1. I've never experimented with ICC on AMD hardware, but I would expect the same problem—suboptimal code bcause the underlying hardware is different.
      2. Deploying an intel-built solution shouldn't be any harder. If you're pushing binaries, the only dependencies would be Intel's fancy math libraries, if you use them. If you're pushing source, you either provide two Makefiles (one for GCC, one for ICC), or you might even be able to get away with one, since ICC attempts to be as compatible as possible with GCC's command-line options.

      In my opinion, Intel builds are only useful for in-house software or professional scientific software. Use both compilers while you're testing. Use all of the profiling tools available to you (gcov, vtune, valgrind/cachegrind, etc). Use all of the style guidelines for both compilers (particularly anything they say about strict aliasing).

  191. correction by speedtux · · Score: 1

    C++ is to C as Lung Cancer is to Cancer.

    Seriously, the problem with C++ is its C heritage.

    C is a language whose design was driven by having to fit the compiler into the 64kbyte instruction space of the PDP-11.

  192. Re:It hurts you to learn C++ is still being used. by HuguesT · · Score: 1

    Was it before ISO C++ or (significantly) after? I wouldn't have touched pre-ISO C++ with a 10-foot pole but now it's a good, consistent language, especially with boost.

  193. Re:It hurts you to learn C++ is still being used. by HuguesT · · Score: 1

    If your problem can be nearly completely solved in Python or Ruby you don't need C++, I agree. If you are doing compute or memory-intensive stuff neither Python or Ruby are likely to be suitable. Python must be one of the slowest language on earth with no production compiler available.

    Modern C++ includes all sorts of goodies in the template metaprogramming area. The Alexandrescu book explain what is possible with these techniques, and some of them have been put into use in Boost. It is possible to produce very high-level programs that are extremely efficient.

    People write in C++ now very differently now, especially since Microsoft has finally produced a standard-compliant compiler since 2003 or so, and dev shops are finally phasing out VC6.

    However the 'export' keyword for templates is a bug in the spec. One compiler company (I think it was Comeau) has implemented it and found that it serves zero purpose.

  194. Re:It hurts you to learn C++ is still being used. by HuguesT · · Score: 1

    Fifteen years ago, in 1993 or so, C++ sucked big time. Now it doesn't. ISO-C++ is a tough language to master, but understanding its design will make you a much better programmer.

  195. Re:It hurts you to learn C++ is still being used. by HuguesT · · Score: 1

    So, language list? we are awaiting with bated breath...