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)."

118 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. 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 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.

    4. 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
    5. 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.

    6. 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...

    7. 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.

    8. 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.

    9. 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.
    10. 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.

  3. 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.

  4. 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.
  5. I can. by bigtallmofo · · Score: 4, Funny

    Yes.

    --
    I'm a big tall mofo.
  6. 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

  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).

  9. 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.
  10. 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 JoCat · · Score: 3, Funny

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

  11. 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 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
    3. 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.
    4. 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

    5. 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
    6. 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?

    7. 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.

    8. Re:C#++? by RHSC · · Score: 2, Funny

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

    9. 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
    10. 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
    11. 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.

    12. 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
    13. 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
    14. 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.

  12. 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.

  13. 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.

  14. 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.
  15. 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}
  16. 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 Eli+Gottlieb · · Score: 4, Insightful
  17. 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 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.

  18. 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.
  19. 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 ]
  20. 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 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.

    2. 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.

  21. 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.

  22. 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.

  23. 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.

  24. 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.
  25. 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.
  26. 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 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.
    2. 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.

  27. 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."
  28. 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."
  29. 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 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?

  30. 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.
  31. 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 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 ;)

  32. 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 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.

    4. 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.

    5. 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.

    6. 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.)

    7. 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.

    8. 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.
    9. 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.
    10. 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.
    11. 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.
    12. 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
    13. 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.
    14. 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.

    15. 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.

  33. 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 ]
  34. 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.

  35. 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.

  36. 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 ]
  37. 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.

  38. 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"
  39. 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
  40. 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.
  41. 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.
  42. 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.

  43. 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 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?

    2. 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?

    3. 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.
  44. Re:To all the C++ haters by jejones · · Score: 3, Funny

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

  45. 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

  46. 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"
  47. 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.

  48. 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
  49. 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.

  50. 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.

  51. 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).