Slashdot Mirror


Stroustrup Reveals What's New In C++ 11

snydeq writes "Bjarne Stroustrup discusses the latest version of C++, which, although not a major overhaul, offers many small upgrades to appeal to different areas of development. From the interview: 'I like the way move semantics will simplify the way we return large data structures from functions and improve the performance of standard-library types, such as string and vector. People in high-performance areas will appreciate the massive increase in the power of constant expressions (constexpr). Users of the standard library (and some GUI libraries) will probably find lambda expressions the most prominent feature. Everybody will use smaller new features, such as auto (deduce a variable's type from its initializer) and the range-for loop, to simplify code.'"

305 comments

  1. "Not a major overhaul"? by Godai · · Score: 5, Insightful

    I mean, it's not, but it makes it sound like C++11 is a minor update. Lambdas, auto, concurrency, are these minor updates? There's a lot of interesting stuff in C++11!

    --
    Wood Shavings!
    - Godai
    1. Re:"Not a major overhaul"? by interval1066 · · Score: 1

      The biggest addition for me is a fix finally for the smart pointer class. Seems like unique_ptr was a long time in coming.

      --
      Python: 'And then suddenly you have a language which says "we're all stuck with whatever the whiniest coder wants".'
    2. Re:"Not a major overhaul"? by genjix · · Score: 5, Interesting

      I've been using the C++11 for 6 months now in my own project (libbitcoin) and the new features and syntax really make your code sharper, clearer and better. C++ is no longer that unsafe language if you know how to code in it properly - you never really have to do any manual memory management if you use shared pointers.

      constexpr allowed me to create compile time constants that are the function of a bunch of complicated expressions. Sure, I could just put the result in the code, but by using constexpr (a far more expressive metaprogramming utility than templates) I can document where those constants came from by using code. Neat huh!

      Using variadic templates, I was able to write decorators that can be applied to any function. I simply wrap my functions with this class and then its operator() will be called before calling the passed in function object (which I can define using lambdas or std::bind now :)

      auto means I no longer have to type std::vector>::iterator in every for loop. Likewise for (const transaction& tx: block.transactions) is much more terse and clearer.

      The new features to the standard library are brilliant. Threading has never been easier: std::thread t(foo, x, y); will call foo(x, y) in a new thread. When I decide to finish the threads and then join them I call: t.join(); ... Simple.

      As libbitcoin is highly asynchronous, I don't like to use exceptions (which thread does it originate in? where does it get caught? .etc). C++11 now provides the header which defines std::error_code(). An error_code object can be tested as a boolean (to see whether the error is set or not) or compared against an enum value (which you define). They also have an error message (which if you defined the enum value it is set to, you can also set the message), and also you can group different error code values into broader categories! Really useful for asynchronous programming.

      std::atomic for a thread-safe counter (useful when you have multiple thread paths executing and want to see when they all finished - increment your counter by one after each path completes) and std::atomic for a thread-safe flag. ... That's off the top of my head. There are dozens of many small things like this. C++ was always my 'native' language, but now it's truly my home.

    3. Re:"Not a major overhaul"? by 19thNervousBreakdown · · Score: 5, Informative

      Don't forget initializer lists, variadic templates, non-static data member initializers, finally fixing that Template> (note the >>) thing, rvalues, nullptr, strongly-typed enums, constructor improvements (holy god we don't have to rewrite every fucking thing every fucking time or split off into an ::init()), user-defined literals which is crazy cool combined with templates and initializer lists, and lots of stuff I'm sure I'm forgetting about.

      Since starting on C#, I've kind of felt like I'm back in the dark ages in C++, even as it remains my favorite language. I've already started using a lot of these improvements, and while C++ still has it's rough edges, the improvement in "fun" while coding is massive. No more for (some_container_type<vector<map<int, string> > >::reverse_iterator aargh = instance.begin(); aargh != instance.end(); ++aargh) for me!

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    4. Re:"Not a major overhaul"? by genjix · · Score: 1

      damn my angle brackets got blanked out.

      [system_error] for std::error_code

      std::atomic[size_t] for thread-safe counter
      std::atomic[bool] for thread-safe flag

    5. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      auto means I no longer have to type std vector iterator in every for loop

      You didn't anyway. You type in "int" to loop over a vector.

    6. Re:"Not a major overhaul"? by Bill_the_Engineer · · Score: 1

      What C++ compiler are you using?

      --
      These comments are my own and do not necessarily reflect the views or opinions of my employer or colleagues...
    7. Re:"Not a major overhaul"? by swillden · · Score: 5, Informative

      auto means I no longer have to type std vector iterator in every for loop

      You didn't anyway. You type in "int" to loop over a vector.

      Only if you want to tie yourself to using a vector. Using a proper iterator costs you nothing in code space or execution time (because for a vector it optimizes down to just pointer arithmetic anyway), but means that at some future time you can replace that vector with a different data structure without having to modify the code that operates on it.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    8. Re:"Not a major overhaul"? by ThatsMyNick · · Score: 1

      For a vector both are equivalent, but for structures like "list", iterator is faster.

    9. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 2, Informative

      for (auto i : v) {

      }

      Even in terms of typing time it's a nice addition, ignoring the structure-independence benefits of this sort of thing.

    10. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 2, Informative

      It pretty simple why you would use iterators.
      While the data you store might not change much over time, the amount of data stored for successful apps tends to grow alarmingly over time. Allowing the vector to change to some other more elegant solution when the need arises without having to rewrite large swaths of code.

    11. Re:"Not a major overhaul"? by Tyler+Durden · · Score: 2, Informative

      The new features to the standard library are brilliant. Threading has never been easier: std::thread t(foo, x, y); will call foo(x, y) in a new thread. When I decide to finish the threads and then join them I call: t.join(); ... Simple.

      Sure. But it should be noted that this feature (along with many others brought to the new stand, I'm sure) were introduced in the Boost set of libraries first.

      --
      Happy people make bad consumers.
    12. Re:"Not a major overhaul"? by genjix · · Score: 4, Informative

      > What C++ compiler are you using?

      g++ 4.6 - standard in Ubuntu

      Two of the features I'm waiting on are class level non-static initialisers and templated typedefs. I've heard Microsof's C++ compiler has better C++11 support but I've never tried it.

      Beware that MingW has a bug so std::thread is disabled. I've heard mingw-w64 works better. You might want to also try boost::thread (same library essentially, except std::thread has move semantics).

    13. Re:"Not a major overhaul"? by Godai · · Score: 1

      Heh, thanks for filling in the rest. I knew there were more, but I was just throwing down what I could remember off the top of my head. I was watching Bjarne talk about C++11 at Going Native and now I'm anxiously awaiting our (long overdue) transition to VS2010 (from 2005). I know it doesn't cover all the good stuff, but it has a lot of the goodness in there. Though, I'm writing cross platform code with a Mac team that refuses to use Clang, so God knows when I'll be allowed to use anything from C++11 :(

      --
      Wood Shavings!
      - Godai
    14. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 1

      Bullshit.

    15. Re:"Not a major overhaul"? by DeathFromSomewhere · · Score: 1

      Sometimes I get the feeling that my company is the only one left using VC++ 6. Our attempts at migrating get 10% completed and then abandoned when the next ultra critical super important demo/contract shows up.

      --
      -1 overrated isn't the same thing as "I disagree".
    16. Re:"Not a major overhaul"? by loufoque · · Score: 1

      constexpr (a far more expressive metaprogramming utility than templates)

      That is incorrect.

    17. Re:"Not a major overhaul"? by bipbop · · Score: 1

      std::to_string() is also disabled on MinGW. Minor, but something to be aware of.

    18. Re:"Not a major overhaul"? by shutdown+-p+now · · Score: 2

      VC++ 2010 used to have better C++11 support than g++ for some time, but the latter has overtaken it now, and it looks like it'll keep ahead for the next release also - VC still doesn't do variadic templates, for example. It doesn't have instance field initializers, either, nor templated typedefs.

      That said, C++11 support is being implemented pretty rapidly in general - I mean, we've only just got the final spec out, what, a couple months ago? and more than half of it is already supported in all major compilers.

    19. Re:"Not a major overhaul"? by MurukeshM · · Score: 0

      But then, plenty of things were introduced in Boost and other such libraries before getting on the standard. At least, that's the impression I got from the wiki article on TR1 and the features introduced in the last standard.

    20. Re:"Not a major overhaul"? by gbjbaanb · · Score: 2

      firstly, I wish I was using VC6 still - the IDE was the best there ever was, fast, simple, didn't flicker or use up all your RAM.

      However, you can use a different IDE if you must keep the old compiler for backwards compatibility.

      Alternatively, you can replace the compiler in the IDE.

    21. Re:"Not a major overhaul"? by afaik_ianal · · Score: 2

      Microsoft's C++11 support in VS2010 was pretty good at the time: lambdas, auto, new function decl syntax, and that's about it.
      They've really dropped the ball in VS11 though: They've basically added strongly types enums, and that's about it.

      Still no word on variadic templates, template aliases or initializer lists.

    22. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0, Informative

      tl;dr: "I refuse to keep my skills current, so I will dismiss every development in the field of computer programming that post-dates my pet language(s)".

    23. Re:"Not a major overhaul"? by 91degrees · · Score: 1

      It pretty simple why you would use iterators.

      Well, we're using iterators all over the place in the rest of the code. If you're in an iterator mindset, It's nice to keep using the same idiom.

    24. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      Not bullshit. Hyperbole. Hyperbole doesn't invalidate his point either. Learn the difference.

    25. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      "the new features and syntax really make your code sharper, clearer and better."

      Please define 'better'. Better for whom?
      Most of these just seem better for the coder.
      Aren't programs supposed to be for the user?
      The most elegant code many times is not the fastest or most efficient.

    26. Re:"Not a major overhaul"? by Pino+Grigio · · Score: 0

      Yes. There's no atomic in VC and variadic templates are absent too. These are things that I could really use in my project right now.

    27. Re:"Not a major overhaul"? by martin-boundary · · Score: 4, Insightful
      C++ has always been about performance and low level control. However, having higher level constructs in addition is a good thing.

      Take goto, which is all that's really needed for modern programming. Using goto, you can implement subroutines (gosub like functions), while and for loops, etc. But each time you implement one of the higher constructs, your implementation will be slightly different. And if you force yourself to use the optimal implementation all the time, you'll just be writing a lot of boiler plate code. So having functions and while loops implemented as language constructs is a good thing. Similarly, std::thread + lambdas is a great addition.

    28. Re:"Not a major overhaul"? by shutdown+-p+now · · Score: 1

      Atomic is in VC11 dev preview (changelog).

      Sadly, still no variadic templates.

    29. Re:"Not a major overhaul"? by martin-boundary · · Score: 1

      One thing I think I don't like is return types after the function definition. It seems too artificial, when they could have just changed the scoping rules slightly and kept the return type before the function prototype.

    30. Re:"Not a major overhaul"? by cheekyboy · · Score: 1

      So, just the same as

      foreach(i in v)

      in other 4GL langs for how many years ?.

      --
      Liberty freedom are no1, not dicks in suits.
    31. Re:"Not a major overhaul"? by superwiz · · Score: 1

      No more for (some_container_type > >::reverse_iterator aargh = instance.begin(); aargh != instance.end(); ++aargh) for me!

      What's worse is one of the intermediate containing types changes. You then have to go and hunt through the rest of the code to see where it changed. Yeah, until containers knew their contained type (and could declare an iterator over their contained type), they really should have been called pseudo-containers. The problems, however, is that the language has been so slow to get fully implemented, that it's driving people away from the adaption. I think half of the C++ projects out there are delayed in starting up just because there is no full C++11 compiler to use.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    32. Re:"Not a major overhaul"? by QuasiEvil · · Score: 1

      Holy shit - we finally get strongly-typed enums? Finally. No, I'm not the type to RTFA. :)

    33. Re:"Not a major overhaul"? by RCL · · Score: 1

      Bullshit is what we have now: when "managed code" ends up being run as JIT-compiled chunks that lie scattered throughout the whole memory and make CPU instruction cache the bottleneck, when memory is accessed through chain of pointers, when people don't even know the memory layout of data they are using... let alone care about temporal and spatial locality when accessing it...

      But "the free lunch is over" and single-threaded CPU performance hit a glass ceiling in like 2004, so we are slowly going "back to the roots" for single-threaded code - not every algorithm has, or will ever have, a nice/easy parallel version, so new processors won't help much.

    34. Re:"Not a major overhaul"? by jgrahn · · Score: 1

      For a vector both are equivalent, but for structures like "list", iterator is faster.

      Faster than what? There is no indexing of std::list. (You could write one, I suppose, but that would make iterating a list O(N^2).

    35. Re:"Not a major overhaul"? by jgrahn · · Score: 1

      auto means I no longer have to type std vector iterator in every for loop

      You didn't anyway. You type in "int" to loop over a vector.

      Only if you want to tie yourself to using a vector. Using a proper iterator costs you nothing in code space or execution time (because for a vector it optimizes down to just pointer arithmetic anyway), but means that at some future time you can replace that vector with a different data structure without having to modify the code that operates on it.

      That is *one* reason, I suppose. A more important one is that you use iterators everywhere else in C++. When you're used to that, throwing in a loop for(int i=0; iN; i++) looks odd.

    36. Re:"Not a major overhaul"? by jgrahn · · Score: 1

      I've been using the C++11 for 6 months now in my own project (libbitcoin) and the new features and syntax really make your code sharper, clearer and better. C++ is no longer that unsafe language if you know how to code in it properly - you never really have to do any manual memory management if you use shared pointers.

      Fine, but (a) you don't need C++11 to have shared pointers -- it just standardizes them; (b) shared pointers are *not* the primary way to avoid manual memory management -- that would be the standard containers.

    37. Re:"Not a major overhaul"? by jgrahn · · Score: 1

      I think half of the C++ projects out there are delayed in starting up just because there is no full C++11 compiler to use.

      That would be stupid if it was true, because C++11 is not really a world-changing thing (unless you're deep into template meta-programming, which most people shouldn't be).

      The compiler situation is much better today than when C++ was first standardized in the late 1990s: the GCC crowd has their shit together, and Microsoft are on the bus again.

    38. Re:"Not a major overhaul"? by CapOblivious2010 · · Score: 1

      Sometimes I get the feeling that my company is the only one left using VC++ 6.

      Is your company hiring? I'd love to use VC6 again - it was faster, more stable, and much easier to use than the recent crap MS has been extruding. VC2008 and 2010 have so many god-awful misfeatures that make simple things needlessly complicated, it's amazing anything useful can ever get done with them.

    39. Re:"Not a major overhaul"? by VertigoAce · · Score: 2

      Slide 5 of the deck here says that initializer lists, template aliases, variadic templates, and other features are coming in a series of out of band releases after VC11 RTM (but sooner than the next major release of VC). That slide also lists the stdlib and language features that are included in VC11 Beta/RTM.

    40. Re:"Not a major overhaul"? by swillden · · Score: 1

      Except in the real world you'll need to modify some of the code that operates on the data structure when you change it anyway

      Sometimes yes, sometimes no. You can't know that up front. Maybe you later find that some other piece of code that operates on the structure needs to insert elements near the beginning, and it's big enough and happens enough that the cost matters. So you swap it out for a list, or a deque. Or maybe it becomes more convenient to manage the data on disk, and you replace the vector with a custom disk-based vector class, or maybe an mmap'd flat array with a trivial wrapper (about all you have to implement is begin() and end() and have them return raw pointers).

      it's better to just hammer out a quick "for int i = 0; i thing.size(); i++" than dick around with iterator and const_iterator vs. const iterator and so forth

      Being able to use const iterators is another advantage, not a cost. It helps you -- and more importantly whoever comes after you -- to know at a glance that the loop doesn't modify the contents. It's compiler-enforced documentation. Even when I'm using raw arrays (rare, but it happens), I still use constant pointers and iterator notation just for that purpose. E.g.: for (const int* iter = array; iter

      I mean who says you'll even be changing the structure anyway? Why are you spending time now on something that probably won't even happen?

      Why would you think it takes any more time to do it right than to hack it with an int index? As another poster commented, with the new loop syntax and auto, it's actually less typing to use the iterator, but even if it's not, clarity of expression, future-proofing and defense against inadvertent errors are far more important than the time it takes to type a few extra characters. If your typing speed is limiting your coding output, it's not because you type too slowly, it's because your code is poorly written.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    41. Re:"Not a major overhaul"? by swillden · · Score: 1

      Doh!

      The code snippet should have been:

      for (const int* iter = array; iter < array + array_size; ++iter) { /* ... */ }

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    42. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      *hypnotises genjix* :P

    43. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      But would it even work that way? Can you even parse a C++ type name properly without knowing what the names refer to in advance?

    44. Re:"Not a major overhaul"? by ThatsMyNick · · Score: 1

      My bad, I was expecting some of equivalent of get() in Java's LinkedList. I suppose C++ does not have one.

    45. Re:"Not a major overhaul"? by superwiz · · Score: 1

      It's not stupid. Most estimates show that the average code size of a C++11 coded program is half the size of a C++ program. And they are much more readable. It is patently silly to commit resources to long-term projects which can be written in half the time if they are started 2-3 years down the line.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    46. Re:"Not a major overhaul"? by martin-boundary · · Score: 1
      That's not a new problem, is it? For example, the template qualifier is already necessary in template code when an expression like T.x(3) occurs. Does that refer to a template method x of class T invoked with the value 3, or is it a member variable T.x compared with the value of variable y, which is then compared with the integer 3?

      Although come to think of it, that's pretty damn ugly too :(

    47. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      No more for (some_container_type > >::reverse_iterator aargh = instance.begin(); aargh != instance.end(); ++aargh) for me!

      You do that? It's so much easier to typedef everything at the class or function scope.
      typedef complex_template_expression container;
      typedef container::iterator container_iter;

      for(container_iter it=C.begin(); it != c.end(); it++) { /* ... */ }

      This method is much cleaner and easier to understand compared to introducing ugly template expressions everywhere, and you can change around the container types at once place in your code.

    48. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      No more for (some_container_type<vector<map<int, string> > >::reverse_iterator aargh = instance.begin(); aargh != instance.end(); ++aargh) for me!

      Good thing, too, since that's undefined behaviour :-)

      Pedantry aside, that is another benefit of a cleaner syntax. Easier to get it right.

    49. Re:"Not a major overhaul"? by Tyler+Durden · · Score: 1

      Umm. Why the fuck was I modded "Overrated"? Just giving credit where credit is due for a feature that has been available from before it became part of the standard.

      --
      Happy people make bad consumers.
    50. Re:"Not a major overhaul"? by Chrisq · · Score: 1

      C++ is no longer that unsafe language if you know how to code in it properly

      That was also true. I haven't used c++ 11 in anger, but I think what you mean is that the rules about how to write a safe c++ program are greatly simplified. Have I got it right?

    51. Re:"Not a major overhaul"? by sonamchauhan · · Score: 1

      And that is ironic

    52. Re:"Not a major overhaul"? by loufoque · · Score: 1

      That's not what irony is.

    53. Re:"Not a major overhaul"? by msclrhd · · Score: 1

      Except you are starting on container C and ending on container c -- boom!

          for (auto value : c) { /* ... */ }

      is a lot cleaner and more reliable (auto& if you want to modify the value).

      Also, you can now do:

            int a[] = {6, 4, 9, 2, 5, 8, 3};
            sort(begin(a), end(a));

      Even things like:

            std::string lookup_value(const std::map<std::string, std::string> &items, std::string value) {
                  auto match = items.find(value);
                  return (match != items.end()) ? match->first : std::string();
            }

      No ugly template expressions to be found.

    54. Re:"Not a major overhaul"? by TheRaven64 · · Score: 1

      Most estimates show that the average code size of a C++11 coded program is half the size of a C++ program

      Who is making these estimates? I've been playing with C++11 for a bit (and implemented some parts) and I'd be very surprised to see more than a 10% reduction in size. Unless we're talking about very small projects and counting Boost towards their total code count...

      --
      I am TheRaven on Soylent News
    55. Re:"Not a major overhaul"? by TarMil · · Score: 2

      If your point is that C++11 arrives late, well, I think everyone knows that. But it's still much better than the previous standard.

    56. Re:"Not a major overhaul"? by superwiz · · Score: 1

      There is no compiler which implements all the new syntax just yet -- not even all the syntactic sugar. So I'd be curious to know how you've been playing with C++11.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    57. Re:"Not a major overhaul"? by swamp+boy · · Score: 1

      Like operator[]?

      std::vector<int> myNumbers;
      myNumbers.push_back(1);
      myNumbers.push_back(2);
      myNumbers.push_back(3);

      int theValueTwo = myNumbers[1];

    58. Re:"Not a major overhaul"? by TheRaven64 · · Score: 1

      I work on a C++ compiler, and I've been playing with the features as they're implemented. Which doesn't answer my question: who is making these '50% code reduction' claims. Nothing I've seen in C++11 makes me think them at all credible.

      --
      I am TheRaven on Soylent News
    59. Re:"Not a major overhaul"? by anonymov · · Score: 1

      You don't need "all the new syntax" to start using C++11, many of most useful additions are already in all major compilers and have been there since the times when C++11 was known as C++0x and C++ TR1. Current GCC is missing only a few features.

    60. Re:"Not a major overhaul"? by Imagix · · Score: 1

      Hmm.. replacing all of those extra functor objects that you had to pass to algorithms with lambdas will drastically reduce those pieces of code. Not sure about 50% overall...

    61. Re:"Not a major overhaul"? by superwiz · · Score: 1

      TR1 was removed from C++11.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    62. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      Or a size_t or ptrdiff_t if you want your code to be 64-bit compatible.

    63. Re:"Not a major overhaul"? by superwiz · · Score: 1

      That's only part of the "prepare to jump to hyperspeed" before jumping to hyperspeed. Without the new use of the 'auto' keyword, every for loop requires either multiple lines loop header or a typedef right before the loop. The auto keyword reduces it to 1 short line. The copy semantics actually reduce the code necessary to return containers. Oh, and the new tuples make all the gymnastics surrounding returning of lists of heterogeneous values from functions a syntactic no-brainer. But I don't think any compiler implements the initializer lists yet. That would be another step in reducing the code foot print.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    64. Re:"Not a major overhaul"? by 19thNervousBreakdown · · Score: 1

      *facepalm* .rbegin()/.rend()

      And yeah, strange as it might be, not having to write redundant stuff actually makes it easier to read/write code. It's less that you have to keep in working memory.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    65. Re:"Not a major overhaul"? by SerpentMage · · Score: 1

      So I am following this thread and can't stop but think, "this is why I think C++ is a POS!"

      I used to be a C++ programmer. However, with Java, C#, Python, Ruby, or Javascript I don't get into long winded debates on how to allocated a fucken string! It is a fucken string for god's sake! Not the Taj Mahal.

      And talking about performance? With very well tuned C# I have gotten to about 90% of C++ as coded with std, etc. Granted C++ without all of the extras like std smokes C#, but then again you are back to the bad old problems of memory dumps.

      --

      "You can't make a race horse of a pig"
      "No," said Samuel, "but you can make very fast pig"
    66. Re:"Not a major overhaul"? by aiht · · Score: 1

      They meant no operator[] in std::list<>

    67. Re:"Not a major overhaul"? by Anonymous Coward · · Score: 0

      He's right though. Your advice doesn't apply to the real world. You'll want to optimize to the new collection anyway, because some calls could be different (erase for instance). For vectors, might as well typedef int.

    68. Re:"Not a major overhaul"? by benhattman · · Score: 1

      I sure hope you meant size_t.

    69. Re:"Not a major overhaul"? by afaik_ianal · · Score: 1

      Thanks for the links! I was really concerned MS were going to drop the ball.

  2. I want auto! by boaworm · · Score: 1

    Unfortunately I code in java these days.. chances that oracle will see the light? :-)

    --
    Probable impossibilities are to be preferred to improbable possibilities.
    Aristotele
    1. Re:I want auto! by Anonymous Coward · · Score: 1, Interesting

      Unfortunately I code in java these days.. chances that oracle will see the light? :-)

      Really? When I implemented our code guidelines, one of the rules is prohibiting the use of 'var', c#'s version of auto.

      I don't ever want to look at code and wonder, "what type is this variable?" You're trading off the convenience of coding it without having to look up the data type name for making it more difficult to maintain. Anytime I have a choice between maintainability and ease of coding it the first time, maintainability wins.

    2. Re:I want auto! by DeathFromSomewhere · · Score: 3, Insightful

      Don't wonder, hover your mouse cursor over the variable and behold the glory of tooltips.

      Now what happens when you change the name of a return type from a commonly used function? Have fun with your maintenance nightmare. If you are lucky the compiler will complain, if you are unlucky you break existing code without knowing it.

      --
      -1 overrated isn't the same thing as "I disagree".
    3. Re:I want auto! by SpryGuy · · Score: 4, Insightful

      Prohibiting use of "var" is gross over-kill.

      There are times where it's use is not recommended, certainly. But even in those cases, it can lead you to the point that there's a "bad code smell" where methods aren't named well, variables aren't named well, classes aren't named well.

      var x = foo(); is definitely less readable.

      But var x = new ComplexObject(); is every bit as readable, if not more so, because you don't have a redundant "ComplexObject" in the declaration. You always know exactly what type "x" is. It's also very useful in cases where the return type is a complicated generic. it saves a lot of typing, and is definitely more readable.

      Here is a very good discussion on the benefits and uses of "var":

      http://resharper.blogspot.com/2008/03/varification-using-implicitly-typed.html

      --

      - Spryguy
      There are three kinds of people in this world: those that can count and those that can't
    4. Re:I want auto! by Anonymous Coward · · Score: 1

      Try that in the Entity Framework without writing inefficient code (i.e. selecting all columns). Sometimes you need anonymous types and those require var if you need an object reference. Language features are implemented for a reason.

    5. Re:I want auto! by Anonymous Coward · · Score: 1

      I agree, and always trend towards making code as explicit as possible. If you know the type, declare the type. I still prefer hungarian notation, while we're at it, especially in math-heavy routines. It makes casting and truncation errors just pop out at you.

      var is necessary for anonymous types and LINQ, which IMHO, are a godsend in the viewmodel/presentation/controller layer. It's often a waste of effort to construct concrete classes to hold a bunch of display strings, just to wrap then in JSON and shove them off to a world of javascript that doesn't appreciate all those hand-written getters and setters.

    6. Re:I want auto! by Anonymous Coward · · Score: 1, Funny

      Don't wonder, hover your mouse cursor over the variable and behold the glory of tooltips.

      I also don't ever want to use my mouse.

    7. Re:I want auto! by smelch · · Score: 1

      Uh, you put the cursor on the type name, press ctrl+r+r and type the new name. Or you click the tickle and choose the rename option after you change the name. Are you just assuming that everybody uses var everywhere?

      --
      If I can just reach out with my words and touch a butthole, just one, it will all be worth it.
    8. Re:I want auto! by smelch · · Score: 0

      Why would you be using an anonymous type if you needed a reference to it that couldn't be handled with the [object] type? That sounds down-right wonky.

      --
      If I can just reach out with my words and touch a butthole, just one, it will all be worth it.
    9. Re:I want auto! by Anrego · · Score: 2

      In general I agree.. but for some stuff (iterating through a collection for instance) I think it is acceptable. When you start dealing with collections of collections, iterator types become a nightmare!

      in Java of course you can just use the foreach syntax (Kitten kitten : kittens).

    10. Re:I want auto! by godrik · · Score: 5, Funny

      chances that oracle will see the light? :-)

      Last time they saw the Sun, it did not end well...

    11. Re:I want auto! by WARM3CH · · Score: 3, Interesting

      I don't agree. auto (or var) very rarely hide any information which is not immediately visible. For example there are trivial cases where auto (or var) just save extra typing:

      var my_object = new my_class();
      v.s.
      my_class my_object = new my_class();

      Here using var just saves a few key struck (or a lot, in case my_class happens to be a type with a particularly long name). In any case the type of my_object is perfectly known and quite visible so I think using auto is just fine.
      There are however cases that a complex type is used while we actually DO NOT care for the type per se. For example in C++ consider the case for a lambda function:

      auto my_fun = [](int i) { return i * i; };

      Here I actually don't care about the exact type of my_fun. All I care is that it take an int and returns an int which I can see clearly. Finally, another case could be situations in template programming where insanely complex types are used/generated and we don't want to (or even cannot) type them again and again. Also I guess in Java or C# you might get away by cheating and using an object (I hate it when people do that!) but we don't have that luxury in C++.

    12. Re:I want auto! by DeathFromSomewhere · · Score: 2

      This is a C++ thread. We don't have the fancy refactoring tools that C# has.

      --
      -1 overrated isn't the same thing as "I disagree".
    13. Re:I want auto! by TheSkepticalOptimist · · Score: 1

      Seriously get a better IDE if you think using var is confusing.

      var saves me from having to do this:

      Dictionary, AnotherClass myCollection = new Dictionary, AnotherClass();

      instead I can go:

      var myCollection = new Dictionary, AnotherClass();

      which is significantly more readable and removes redundant overhead of typing a type twice. And if you can't figure out what type it is, you should change your profession.

      or even better:

      var collection = someclass.ACollection;

      without having to explicitly know what type ACollection is (i.e. having to hunt through code to copy and paste the type ACollection is defined as).

      this is particularly helpful using Linq such as:

      var results =
      results.ForEach( r => do something );

      Which in the Linq world is good because often the generated results is some complex generics collection that would be very difficult to know what exact explicit type the results generate.

      Lastly, what if the type changes and you don't have a decent IDE that refactors for you, now suddenly ALL your explicit types with throw compile errors and there is a measurable amount of time required for a developer to "maintain" the code.

      Sorry, but var is not difficult to understand how to use properly and if I worked for you I would shove your "guidelines" somewhere unpleasant because generally guidelines are written by people who do not know better.

      BTW, generally these days language features are not added if there is a question of poor code maintainability. Generally speaking, people more knowledgeable then you have figure out that "var" saves time, improves efficiency, and results in more maintainable code the those that do not understand how to use var realize.

      --
      I haven't thought of anything clever to put here, but then again most of you haven't either.
    14. Re:I want auto! by 91degrees · · Score: 2
      Do I take it then, that you don't use stl that much?

      Here's a construct that I used today:

      map<string, vector<string> >

      If I want to iterate through this, I need to create a variable of type

      map<string, vector<string> >::const_iterator

      . Since I'm not totally sure of the exact type of my map, I need to find out where it's declared and copy that. If I then change that vector to a list, I need to change every iterator that uses that. Okay, I should probably use a typedef, but since I'm going to be using it in a statement along the lines of

      for(auto it = my_map.begin(); it != my_map.end(); ++it)
      {
      print(it->key());
      }

      It should be pretty obvious from context what the type is. We know begin() returns an iterator.

      Can see this being useful inside templates as well, and for splitting up complex calculations.

    15. Re:I want auto! by Daniel+Phillips · · Score: 1

      chances that oracle will see the light?

      Roughly the same as the chance that Larry Ellison will fly his MiG 25 straight into the side of a mountain.

      --
      Have you got your LWN subscription yet?
    16. Re:I want auto! by Anonymous Coward · · Score: 0

      var saves me from having to do this:

      Dictionary, AnotherClass myCollection = new Dictionary, AnotherClass();

      instead I can go:

      var myCollection = new Dictionary, AnotherClass();

      which is significantly more readable and removes redundant overhead of typing a type twice. And if you can't figure out what type it is, you should change your profession.

      I agree on the usage of var here - but I disagree with using var as a replacement for superclass/interface assignment:

          MyCollectionSuperclass myCollection = new CollectionSubclass();

      or even better:

      var collection = someclass.ACollection;

      without having to explicitly know what type ACollection is (i.e. having to hunt through code to copy and paste the type ACollection is defined as).

      Stupid. You should know which superclass/generic someclass.ACollection is. (Your IDE should show you, and as long as you're making that argument to begin with, stop being lazy and mouse over the RHS expression.)

      this is particularly helpful using Linq such as:

      var results =
      results.ForEach( r => do something );

      Maybe, but as it seems that Linq is just abridged JDBC code anyway that doesn't strike me as particularly useful to begin with. There are better ways to manipulate database information.

    17. Re:I want auto! by 19thNervousBreakdown · · Score: 4, Insightful

      Because var still works within the type system and gives you compile-time errors, and casting to object is a massive sledgehammer that delays errors until runtime (with all of runtime error checking's glory, like only failing some of the time, which you can basically read as "never on a developer's machine, sometimes on TQA's machine, and always on a customer's machine (unless support is on the phone with them)"), and a stupid idea in general (I'm looking at you, Objective-C!).

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    18. Re:I want auto! by 19thNervousBreakdown · · Score: 2

      (object) ~= (void*)

      I mean that in spirit, not in actual details. Yes, I know there's about a billion, trillion ways they're different.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    19. Re:I want auto! by smelch · · Score: 1

      Well, in my defense the GP to my comment was referring to var in C#, so I responded with how I would handle a situation of renaming the type in C#.

      --
      If I can just reach out with my words and touch a butthole, just one, it will all be worth it.
    20. Re:I want auto! by Anonymous Coward · · Score: 0, Interesting

      Interestingly, K&R shows that "auto" is a reserved keyword, but it's only just been implemented. So it seems it was a good idea that just never happened for 30 years...

    21. Re:I want auto! by smelch · · Score: 0

      My point is that it seems to me that if you are doing something with it that you couldn't do to any type, you shouldn't be using an anonymous type. I would genuinely like to know what a valid case is for using an anonymous type where later you will be accessing one of its properties by name. If you pass that anonymous type to another function it will have to be an [object] anyway, and if its just the same function, build the properties for the anonymous type before initializing the anonymous type. You can't pass an anonymous type to another function as its type (and it would be stupid if you could), and you can't cast from an object to the anonymous type (which would lead to the errors you mentioned above). So, within the same function, your anonymous type may as well be an object instead of a var.

      --
      If I can just reach out with my words and touch a butthole, just one, it will all be worth it.
    22. Re:I want auto! by busyqth · · Score: 1

      Masterful comment!
      I can't tell if it's serious or just trolling.

    23. Re:I want auto! by Xrikcus · · Score: 2

      Auto in K&R was a storage class, not a request for compiler type inference.

    24. Re:I want auto! by aztracker1 · · Score: 1

      Let's just hope he doesn't have to deal with simple LINQ expressions using an anonymous object... oh yeah, no anonymous object types... too unpredictable, even when closer to the UI layer.

      --
      Michael J. Ryan - tracker1.info
    25. Re:I want auto! by gbjbaanb · · Score: 1

      Then simply prepend the type identifier to the variable name, simples!

      Or, if you don't do this, you can use the IDE's ability to tell you the type by hovering over the variable. In which case, it really doesn't matter if you declare it using var or not.,

    26. Re:I want auto! by 19thNervousBreakdown · · Score: 1

      It gives you some of the benefits of duck typing with very few of its drawbacks, and the reduced noise makes your code clearer. I know that seems counter-intuitive to you right now, but if you try it, you'll see the benefits, and realize that the type names appearing next to the declarations is, in most cases, redundant or irrelevant when it comes to actually understanding what the code does.

      It's more of a fuzzy thing, but I started using it at my job, everybody hated it for two weeks, I gave no fucks and kept using it, now everybody uses it.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    27. Re:I want auto! by c++0xFF · · Score: 1

      However, take a look at clang. One day, this and much more will be possible.

    28. Re:I want auto! by c++0xFF · · Score: 2

      in Java of course you can just use the foreach syntax (Kitten kitten : kittens).

      Which is also a C++11 feature, now. Except they call it a "range-based for loop."

      for ( Kitten& kitten : kittens )

      Using a reference is optional, I think, but is probably the better way to go in the general case (so you can modify the object instead of a copy).

    29. Re:I want auto! by shutdown+-p+now · · Score: 1

      if its just the same function, build the properties for the anonymous type before initializing the anonymous type.

      Can you explain what you mean by this?

      You can't pass an anonymous type to another function as its type

      Actually, you can, if that function is generic. It's why you can pass an IEnumerable of anon type objects to something like .Where(), and access properties on that object without any casting within the lambda that you also pass.

    30. Re:I want auto! by c++0xFF · · Score: 1

      And also completely redundant (every local variable is an auto variable unless declared differently), and thus completely useless and never used.

      I think it's wonderful they managed to re-purpose a dead keyword into something wonderfully useful, and the name even fits so well.

    31. Re:I want auto! by shutdown+-p+now · · Score: 4, Informative

      "auto" was always implemented, since the very first version of C, it just had a different meaning - it means that variable has an "automatic storage class" (as opposed to "static storage class" etc). Because automatic was the default, it was almost always redundant, but it did have a meaning.

      It actually goes way back to B, which only had a single data type - machine word. Variable declarations looked somewhat like C, but, for the lack of type, they started with the storage class instead, i.e.:

      main() {
        extern x;
        static y = 1;
        auto z = 2;
      ...
      }

      In C, we've got types, so you'd normally write "static int y" for a static local, and just "int z" for an automatic one - "auto" being implied. However, C inherited some of B's semantics as "default int" - i.e. if the declaration is clearly a variable, but it omits the type, assume that type to be "int" (i.e. machine word). So in C the above code snippet from B is actually valid, and declares x, y and z to all be ints.

      Then "auto" got inherited by C++, which dropped the "default int", making auto completely redundant - you couldn't write "auto x" in C++ anymore, and in all other cases where you could use "auto", like "auto int x = 123", it was always redundant. So when they appropriated it for type inference in C++11, it was technically a breaking change - it just wasn't ever used by anyone in production code in the old way, so nobody noticed.

    32. Re:I want auto! by RightSaidFred99 · · Score: 2

      Exactly. I even use it in the var x = foo() case, but that's because much like the honey badger I just don't give a shit. ctrl-space and hover over tells me everything I need to know.

    33. Re:I want auto! by JonySuede · · Score: 1

      Have a look at that :Netbeans, the platform that is the base for the renamed Sun Studio, now know as Oracle Solaris Studio, is a such a tool.

      --
      Jehovah be praised, Oracle was not selected
    34. Re:I want auto! by Anonymous Coward · · Score: 1

      There are some things using linq where the only option is to use a var.

      List list = new List();
      var q = from n in list where n.Length > 0 && n.StartsWith("bob") select new { Content = n, Length = n.Length };

      foreach (var n in q)
              Console.WriteLine("Content: " + n.Content + ", Length:" + n.Length);

      So the Q type above is of type: System.Linq.Enumerable.WhereSelectListIteratorf__AnonymousType0>.

      Also like others pointed out var is completely type safe just like it is in c++

      I personally find the first example below to just as readable as the other two and less to type. If I end up changing out for a reverse iterator or something like that I don't have to change type type.

      for(auto it = col.begin(); col.end(); ++it){};
      for(StringCollection::iterator it = col.begin(); col.end(); ++it){};
      for(std::vector::iterator it = col.begin(); col.end(); ++it){};

    35. Re:I want auto! by superwiz · · Score: 2

      For anything but the highest performance computing, Java gives the same performance. In fact, for service code, Java gives better performance. I've benchmarked a prime sieve with the same algorithm in Java, and C++ (with and without the -g flag). It's a good test of integer arithmetic+basic language performance because the compiler cannot optimize away loops. Java is only 5% slower than stripped C++. Java is significantly faster than C++ with the -g flag. But Java actually retains all the symbol and frame information. So, in case of a crash, you often have even more to go on than you would in C++ with -g.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    36. Re:I want auto! by petermgreen · · Score: 1

      Afaict you can write fast efficient code in java but to do so you have to fight the language due to it's lack of parameter pass by reference and the implicit pointer in all it's compound types.

      Suppose you have a function that returns a complex number, in a sane language you'd just have a complex type which could live on the stack and return it or pass it by reference/pointer. In java to avoid a heap allocation with every call you have to make arrangements to have a relatively long lived object that stores the complex number maintained by code in the parent.

      Suppose you want an array of complex numbers, in a sane language you'd just declare an array of the aforementioned complex number type which could live in a single block of memory. In Java you would have to either use two paralell arrays or have a pointer to an object for every entry in the array.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    37. Re:I want auto! by Imagix · · Score: 1

      That should be spelled: for (auto & kitten : kittens)

    38. Re:I want auto! by DuckDodgers · · Score: 1

      Java is painfully verbose, and I think a lot of the use of auto would save typing without losing readability.
      auto x = new Customer(); // versus Customer x = new Customer();
      List<Customer> customers = // initialize it somehow
      for (auto x : customers) { ... } // versus (for Customer x : customers) { ... }

      Reading the declaration should be child's play.

    39. Re:I want auto! by Anonymous Coward · · Score: 0

      Stripping a binary doesn't change the code, just the dwarf data.

    40. Re:I want auto! by cerberusss · · Score: 1

      in Java of course you can just use the foreach syntax (Kitten kitten : kittens).

      Also, Java has Garbage Collection, which gets rid of those kittens everywhere.

      --
      8 of 13 people found this answer helpful. Did you?
    41. Re:I want auto! by msclrhd · · Score: 1

      Kitten& is fine if you have non-virtual kittens :D. The use of auto (or auto&) is independent of using the range-based for.

    42. Re:I want auto! by The+Askylist · · Score: 1

      So you only have to use auto for Schrodinger's kittens?

    43. Re:I want auto! by TheRaven64 · · Score: 1

      The poor craftsman blames the tools.

      The good craftsman picked decent tools before he started.

      --
      I am TheRaven on Soylent News
    44. Re:I want auto! by TheRaven64 · · Score: 1

      Java is only 5% slower than stripped C++. Java is significantly faster than C++ with the -g flag.

      Umm, what? -g / stripping just determines whether the DWARF metadata is in the binary. If you are not running the code in a debugger, then this data just sits on disk and is never touched. If you're on OS X, it's not even in the same file as the executable code by default. If you're finding that it's making a noticeable difference to performance, then you should consider that your benchmarks are being done poorly.

      If, on the other hand, you are talking about -O0 (which is usually added with -g), then this can make a huge difference to C++ performance. C++ optimisations are usually pretty destructive towards debugging info, and the difference between unoptimised and optimised C++ is usually at least 50%. Again, if you're not seeing a big difference between a debug and an optimised build, then you're doing it wrong.

      --
      I am TheRaven on Soylent News
    45. Re:I want auto! by smellotron · · Score: 1

      You are mistaking debugging information with optimization levels. It's unlikely that you had a legitimate comparison. For starters, what compiler/version did you use? What other options besides -g were used? What hardware was used?

    46. Re:I want auto! by spongman · · Score: 1

      huh? how do you access the derived members of object?


              object foo = new { x = 1 };
              use(foo.x); // error
              var bar = new { x = 1 };
              use(bar.x);

    47. Re:I want auto! by superwiz · · Score: 1

      It doesn't matter. You can't unroll the loops on this one. So even the basic optimization cannot be done. The whole thing was done in 1 function, so no inlining would help either. I was using gcc 4.5.1. The hardware should be irrelevant. I ran both the java version and the g++ version on the same box under the same operating system. The Java version was 6_26. Both gcc and Java were 64-bit versions.

      --
      Any guest worker system is indistinguishable from indentured servitude.
    48. Re:I want auto! by smellotron · · Score: 1

      It doesn't matter.

      Speaking as someone who regularly looks at the assembler output of gcc, it sure as heck does.

      You can't unroll the loops on this one. So even the basic optimization cannot be done.

      Loop unrolling doesn't happen until -O3, and even then it's not a clear-cut optimization because it bloats the instruction stream and potentially confuses the hardware branch predictors (which are—as one might expect—optimized for loops). There are plenty of other optimization passes that the compiler can go through. To name a few:

      • tail recursion to eliminate stack growth
      • better register allocation to reduce (or eliminate) stack usage
      • static branch prediction to reduce the likelihood stalls from conditionals
      • instruction reordering to reduce the impact of stalls from conditionals or execution-unit bandwidth

      The hardware should be irrelevant. I ran both the java version and the g++ version on the same box under the same operating system.

      GCC by default targets the generic architecture (there's a way to tell if the version you're using targets something else, but sorry, I forget at the moment). This means it won't use any of the newer x86 or x86_64 instructions. It also limits the compiler's knowledge about instruction latencies, and branch penalties, and the cache hierarchy. It is likely that you penalized the C++ version simply because Java is designed to abstract these details into the jvm itself.

      If you're kind (and organized) enough to be able to provide me with the original code and command-line arguments, I can take a crack at some basic compiler-flag tweaking and get back to you about experimental difference.

    49. Re:I want auto! by superwiz · · Score: 1

      // findPrimes6 gets called N number of times with some large parameter (say 20 million)

      #define CONSIDER_NUMBER(last,ringSize,position) \
              isPrime = true; \
              for (int i=0;i<=position;++i) \
              { \
                  divisers_considered++;\
                  if (primesSquaredArr[i] > last) \
                      break; \
                  if (last % primesArr[i] == 0) \
                  { \
                      isPrime = false; \
                      break; \
                  } \
              } \
              if (isPrime){ \
                  primesSquaredArr[position]=last*last;\
                  primesArr[position++]=last;\
              } \
              last += ringSize; \
              numbers_considered++;

      template<typename prime_type>
      void findPrimes6(const int count)
      {
          std::cout<<"findPrimes6"<<std::endl;
          std::vector<prime_type> primesVec(count+1);
          prime_type * primesArr = primesVec.data();
          primesArr[0]=prime_type(2);
          primesArr[1]=prime_type(3);
          std::vector<prime_type> primesSquaredVec(count+1);
          prime_type * primesSquaredArr = primesSquaredVec.data();
          primesSquaredArr[0]=prime_type(4);
          primesSquaredArr[1]=prime_type(9);
          register prime_type last1=7;
          register prime_type last5=5;

          register int numbers_considered=0;
          register int divisers_considered=0;
          register int pos=2;
          while(pos <count)
          {
              bool isPrime;
              CONSIDER_NUMBER(last5,6,pos)
              CONSIDER_NUMBER(last1,6,pos)
          }
          /*for (int i=0;i<primesArr.size();++i)
          {
              std::cout<<"prime # "<<i<<" is "<<primesArr[i]<<std::endl;
          }*/
          std::cout<<"last prime is "<<primesArr[count-1]<<std::endl;
          std::cout<<"numbers considered: "<<numbers_considered<<std::endl;
          std::cout<<"divisers considered: "<<divisers_considered<<std::endl;
      }

      --
      Any guest worker system is indistinguishable from indentured servitude.
    50. Re:I want auto! by smellotron · · Score: 1

      I compiled two versions using gcc-4.4 on an Intel i7 chipset (this version actually targets core2 instruction latencies, but it's close enough for my purpose). Compile/link lines:

      g++ findprimes.cxx -o findprimes0 -m64 -march=native -mtune=generic -O0
      g++ findprimes.cxx -o findprimes3 -m64 -march=native -mtune=native -O3

      There are only a few salient differences in the optimized build: the first is a smaller stack size (0x8 bytes instead of 0x88). This probably doesn't have much impact on caching (there aren't many function calls, and none in the critical path), but it does mean that more variables are going through unnecessary load/store cycles. The second is that the optimized build issued roughly half of the function calls. Any functions in the computation kernel count as trimmable fat. The final difference is that the native-tuned build frequently used conditional-move operations. This reduces pressure on branch prediction hardware.

      I benchmarked both using a single series of calls in the sequence 1, 2, 5, 10, 20, 50, 100, 200, 500, ..., 5000000. Due to impatience I did not go all the way out to 20M as you suggest, but the results to 5M already show a smooth geometric scale that I expect would continue until I run out of main memory. I used getrusage() to track various runtime statistics and saw the following:

      common: physical memory (maxrss) 77K, page faults (minflt) 35K

      findprimes0: cpu time (utime) ~72 seconds, involuntary context switches (nivcsw) ~80.

      findprimes3: utime ~50 seconds, nivcsv ~60.

      Overall, I hope that this convinces you that compiler optimization flags matter across the board for C++. I believe this is one of the downsides of C and C++ as a mainstream application language: optimization for the target runtime environment is required by application developers. That being said, this problem is very light on the CPU and very heavy on memory bandwidth, so I suspect that any implementation could be optimized substantially by parallelizing the sieve checks. Consider that for any given value N above some small absolute value, it should be guaranteed that N-1, N-2, ..., N-K are all relatively prime. Thus, the algorithm should be able to batch-process chunks of N values against the list of existing primes in parallel. This is essentially a manual loop-unrolling, but it relies on information that we only know from mathematical proof (i.e. no modern compiler or runtime could be expected to perform this optimization automatically).

    51. Re:I want auto! by benhattman · · Score: 2

      Prohibiting use of "var" is gross over-kill.

      Gross overkill is, of course, the main point of most coding standards.

  3. News? by PatDev · · Score: 0

    Seriously? This is months old! You know how old this is?

    It's a collection of new C++ features, and prominent compilers have already added support for it. Getting C++ compiler vendors off their butts to implement new features takes freakin' forever, but I can already play with lambdas, auto, and variadic templates - at least.

    That said, as a professional C++ developer working in HPC, this is exciting.

    1. Re:News? by busyqth · · Score: 5, Funny

      That said, as a professional C++ developer working in HPC, this is exciting.

      Stop pretending and get back to your FORTRAN!

    2. Re:News? by rubycodez · · Score: 1

      prominent compilers support it? the one supporting the most platforms, gcc, doesn't have it all yet

    3. Re:News? by Pino+Grigio · · Score: 0

      And neither does the one supporting the most developers, VC.

    4. Re:News? by rubycodez · · Score: 1

      looks like the same situation as gcc, some C++ 11 things to be supported in Visual Studio 11 but other not:

  4. Nothing to see by Jorl17 · · Score: 1

    Small interview, not anything new is added. Trolls will enjoy the old Java versus C++ thing again.

    Seriously, a big disappointment.

    --
    Have you heard about SoylentNews?
    1. Re:Nothing to see by Anonymous Coward · · Score: 0

      Why? Once the Android vs Oracle suit is over, Java will be deep into COBOL land.
      Microsoft is dropping C# and adapting all the C# libraries and features to C++ for Windows 8.

      No need to flame, C++ won, and it managed(pun intended) to get even more bloated and inconsistent in the process.

  5. and in the next revision... by busyqth · · Score: 5, Funny

    S-expressions, continuations, hygenic macros...

    1. Re:and in the next revision... by Anonymous Coward · · Score: 0

      And monads. But since this is C++, the language for real men, and not some pansy other language they are called gonads.

  6. In practice it's like a different language. by Anonymous Coward · · Score: 1

    Many developers are still using C++ as "C with classes".

    1. Re:In practice it's like a different language. by Roachie · · Score: 2

      Wait, there is an object oriented version of C?

      Theses are days of miracle and wonder.

      --
      This sig is not paradoxical or ironic.
    2. Re:In practice it's like a different language. by DeathFromSomewhere · · Score: 4, Insightful

      C with classes is a derogatory term used to describe programmers and code which wraps C-style code and various bad practices with classes. You end up with things like custom string and array classes, using memcpy instead of std::copy, printf instead of std::cout, FILE* instead of std::fstream, copy paste instead of inheritance and void* everywhere.

      --
      -1 overrated isn't the same thing as "I disagree".
    3. Re:In practice it's like a different language. by tibit · · Score: 5, Interesting

      Now be careful, because inheritance was not really intended for code reuse. If it does help with code reuse, that's a positive consequence, but it's not what inheritance is for, first and foremost. See Liskov substitution principle and all that jazz.

      --
      A successful API design takes a mixture of software design and pedagogy.
    4. Re:In practice it's like a different language. by Alex+Belits · · Score: 1

      The practices you have listed are actually good C++ programming (except "custom string and array classes", whatever that means). Just because there is a bad library bundled with the language, it does not mean that everyone must prefer it over the native libc, it is useful only when it fits the purpose of the program.

      --
      Contrary to the popular belief, there indeed is no God.
    5. Re:In practice it's like a different language. by tibman · · Score: 1

      I still prefer printf to cout. Though php's echo is better than both, which is sad.

      --
      http://soylentnews.org/~tibman
    6. Re:In practice it's like a different language. by Anonymous Coward · · Score: 0, Troll

      Time to join the 21st century grandpa. FILE* leaks. memcpy doesn't call overloaded assignment operators. printf is not typesafe. void* is an abomination that should need no explanation. Custom string and array classes are unoptimized at best and buggy half finished crap at worst.

    7. Re:In practice it's like a different language. by DeathFromSomewhere · · Score: 1

      Let me be a bit more descriptive. The code that I was referring to is a switch statement that branches on a hacky enum in order to cast a pointer down an inheritance hierarchy and perform the same calculation on a series of different types. The difference between the branches is literally what pointer type the base pointer gets casted to.

      class A
      {
      public:
      enum Type
      {
      TYPE_A, TYPE_B, TYPE_C
      } mType;
      void Foo ();
      };

      class B : public A
      {
      void Foo ();
      };

      class C : public A
      {
      void Foo ();
      };

      A * pA = GetA ();
      switch (pA->mType)
      {
      case A::TYPE_A:
      pA->Foo ();
      break;

      case A::TYPE_B:
      ((B*)pA)->Foo ();
      break;

      case A::TYPE_C:
      ((C*)pA)->Foo ();
      break;
      }


      Maybe I'm projecting my frustration and this type of horrible hack is nowhere near as common as I think it is.

      --
      -1 overrated isn't the same thing as "I disagree".
    8. Re:In practice it's like a different language. by jythie · · Score: 1

      I would go further and say it has become a derogatory term of using C++ in anyway way other then the most current stylistic fad... not just doing things the OPP way but doing it the current C++ OOP way.

    9. Re:In practice it's like a different language. by jythie · · Score: 1

      You just listed one of memcpy's best features ^_^

      Many still feel that operator overloading should never have been included in the language in the first place.

    10. Re:In practice it's like a different language. by cheekyboy · · Score: 3

      Maybe because pure C++ with all its advances looks worse than random perl code or assembly.

      Im not asking for cobol like scheme, but come on, enough of the !@#$%^&*(){}|} magic

      --
      Liberty freedom are no1, not dicks in suits.
    11. Re:In practice it's like a different language. by RCL · · Score: 5, Insightful

      So what? STL isn't suited for all possible uses, sometimes you need your own string and container classes.

      Don't be a zealot, pragmatic programmer should find the right trade-off between reusing code and writing an optimal one for a specific problem/area. Nothing can be optimal in all cases - sometimes you need to be as close to hardware as possible at the expense of unreadable/inflexible code (for me, those are the most interesting and challenging areas), and sometimes you only care about maintainability of your code by a disposable programming drone.

    12. Re:In practice it's like a different language. by RCL · · Score: 1

      As if those were the worst problems. And allocating memory dynamically fragments it. Ever tried writing custom allocators for STL to avoid dynamic memory allocations (or do them thru your own memory manager)? Good luck and hope you are tolerant to rectal pain.

    13. Re:In practice it's like a different language. by QuasiEvil · · Score: 5, Insightful

      >Time to join the 21st century grandpa. FILE* leaks.

      Hell no. And get off my lawn.

      printf() isn't typesafe, but it's a fuckton more readable than all that cout formatting stuff. Also, the fact that it's not typesafe isn't really an issue if you don't suck - trivial unit testing will pretty much show any problems immediately. Besides, gcc/g++ is nice enough to warn you about egregious ones now.

      FILE* leaks? I assume by this you mean when sloppy programmers fail to close their files and you start burning through file descriptors. Sounds like a bug to me, and again, stop sucking. Or do what we do - throw an object with a destructor containing fclose() around it. Then you get all the awesomeness of of FILE* (including those awesome formatting commands like fprintf and fscanf) without the danger of your file staying open when something goes nuts.

      Why on earth would you want memcpy() to call anything? It's a low level byte move. Anybody with five minutes of familiarity with it should know that. If you wanted something different, use the assignment operator.

      void* have all sorts of applications, most recently to me in writing architecture neutral VMs where really all the native machine knows is that it's moving around some sort of pointer.

      Now the custom string and array classes? That I'll agree on. Troll on.

    14. Re:In practice it's like a different language. by jgrahn · · Score: 2

      So what?

      I think he simply claimed that you have to deal with C++ written by C programmers all too often. That's my experience, too.

      STL isn't suited for all possible uses, sometimes you need your own string and container classes.

      I don't see what that has to do with the above. I suppose there are some rare cases where the standard library isn't appropriate, but are you arguing this is an excuse *never* to use it?

      By the way, your reference seems severely dated. Some of its complaints are still valid, but seem based on the state of STL support ten years ago.

    15. Re:In practice it's like a different language. by RCL · · Score: 3, Informative

      I think he simply claimed that you have to deal with C++ written by C programmers all too often. That's my experience, too.

      I'm probably one of those C programmers. I use C++ features when I feel they are appropriate, but my definition of "the right thing" changed over years. I started to value custom-tailored solutions, often hardware- and problem-specific. No longer I'm trying to find (or create) code that would fit all (or even the most) cases, and micro-managed security is of lesser concern to me.

      I don't see what that has to do with the above. I suppose there are some rare cases where the standard library isn't appropriate, but are you arguing this is an excuse *never* to use it?

      There are always multiple tradeoffs involved, that's why I am very wary of saying "never". STL is no silver bullet, this is what I'm saying.

      E.g. STL is bad at managing memory, it's hard to make it NOT allocate it dynamically - yes, you can write a custom allocator for it, but STL allocators are inflexible and also - for some poorly thought reason - manage object construction, not just memory allocation, making this unnecessarily hard. STL is a template library, and templates produce separate implementation for every type used - whereas you can have a single void *-based container for all your POD types, with templates providing just minimal wrapper. Also, STL makes it hard for you to control how often memory (object instances) is copied - there's no way to influence its behavior if memory copying tops your profiler results.

      If you are developing primarily for desktop computers which are quite beefy (and also vague in terms of hardware), this may matter less (although it will never cease to matter - just think of all that slow code running on our desktops which eats the performance improvements we still (marginally) get, making desktop performance appear flat since 2004), but if your target is well-defined hardware-wise and if you know/set "upper bounds" for all the practical problem sizes your program is designed to handle, you can think of more optimal solutions for your case. This is one of reasons why you can still play the newest games on 2005 hardware (XBox 360) which hasn't even got an out-of-order CPU, while running the newest desktop software (not games!) on PC of the same era is problematic.

      To sum up, I'm not saying "never use STL", but I would not say "always use STL" either. People claim that using "standard" code helps you create more secure, robust, performant programs - but in my experience, you will end up running a lot of custom tools (all kinds of profilers and validators) anyway before shipping your binary, that makes the point of "performant/secure code by design" moot. When profiler tells you that some code in an STL container underperforms, reimplementing it - or even understanding why that happens - is harder than fixing/improving your own implementation, yet you'll probably have to do that anyway. And no one starts "from scratch" these days, each "low-level" programmer I know has their own set of STL-alike classes.

      By the way, your reference seems severely dated. Some of its complaints are still valid, but seem based on the state of STL support ten years ago.

      Well, it is perhaps improving with new "move" constructors and whatnot, but that's actually a problem: it's better to have cross-platform code with predictable behavior than code that is supposedly optimal everywhere, but which depends on highly varied implementations. What good is it for me to know that some compilers (e.g. gcc), on some platforms (e.g. x86), handle new, C++11-ready STL well - gcc isn't particularly good at optimizing code even for x86, and another compiler that is a good optimizer may not support the newest features and make my STL-heavy code suck.

      P.S. Also, STL (in implementations I saw) is written in quite unreadable, convoluted style - I always wondered why. This is of course less rele

    16. Re:In practice it's like a different language. by Anonymous Coward · · Score: 0, Insightful

      Time to actually go out and build a real system, D-bag. See, throughout the process of building real products that need to work properly, it becomes apparent that while some "features" of new languages are nice and helpful at times (and they really are), most of the hoo-ha around new languages and such is just BS. If your chewing up memory because your cannot fclose() your FILE ptr.... well then you suck. If you think memcpy() should do Deep Copies... well then you, again suck. And for that matter, wtf is wrong with 'void'?

      All these modern niceties won't save your miserable ass if you suck. You have been brainwashed. It's like people who walked around saying "goto is evil, there is always a better way". Those people have no clue. Chances are, if you can't write good C code, you wont write good C# code either. It's just that C# (and everything else these days) gives you a false sense of security.

    17. Re:In practice it's like a different language. by Anonymous Coward · · Score: 1

      Or put the FILE* in a std::unique_ptr and watch the head of those guys explode. You know, the guys who insist that whenever you get a new feature that is in some contexts in some sense an improvement over an old feature, the old feature has suddenly become an abomination and must be got rid of at once.

    18. Re:In practice it's like a different language. by jelle · · Score: 2, Insightful

      #warning rant coming

      "printf instead of std::cout"

      I love c++, but it definitely has some dark spots, even still the long overdue c++0x update (c++11 whatever). Thank deity we finally have standard smart pointers, better templates in various ways, move semantics, etc. It was really necessary to finally have that, even if it was a decade late (I'm sure we lost quite a bunch of good c++ programmers and projects to more newfangled languages in the delay). Even though we often won't be able to use it until all compilers (and developers) in use for a certain codebase are updated, it is a start.

      c++ streams... After exceptions the second worst mistake in c++... c++ needs something good for that functionality, but streams and exceptions don't help.

      Beware of std::cout, it is not thread-safe and is a gigantic pain in the expletive for outputting formatted text. The utility of overloading the shift operator for interfacing with streams is overrated. std::endl is a curse word. streambuf is an ugly hack.

      while std::string is usually an improvement over the plain 'char *', it also is as often overkill as it often is underpowered. Why else would so many people have their own string class? Why would Qt have QString? It's because std::string and fstreams are severely lacking... standard c++ needs more syntactic strength in tokenizing, parsing, formatting, transforming, combining, and type-converting of string content. What is there, in the standard, is, well, imho kludgy. I'm not saying that I have the answer to what exactly it needs, it just needs something better.

      c++ still has a lot of catching up to do. Libraries like boost should really only have their sandbox and legacy code left, and libraries like qt shouldn't need to redo/replace basic functionality. It should be possible to get a proof of concept implementation (aka badly optimized but mostly functional and not too many bugs for a demo or trial) working quickly as easy in c++ as it does in certain other languages. Until then, it should work hard to catch up before we lose most programmers to other languages.

      --
      --- Hindsight is 20/20, but walking backwards is not the answer.
    19. Re:In practice it's like a different language. by Anonymous Coward · · Score: 0

      Urr.... Hello...?
      And how is that std::unique_ptr going to automatically call fclose()?
      Sounds like an exceptionally bad plan. Are you sure you have ever programmed C++?

    20. Re:In practice it's like a different language. by TheRaven64 · · Score: 4, Insightful

      printf() isn't typesafe, but it's a fuckton more readable than all that cout formatting stuff

      Readable? Meh. Localisable? Now that is an important attribute. Consider this trivial bit of code:

      printf("The %s %s\n", colour, object);

      You want to localise this, so you wrap each string in a function that returns the localised version (by the way, gcc and clang have an attribute that you can put on functions that says if the output is safe to use as a format string in any case where the input is). So now you have something that looks like this:

      printf(localise("The %s %s\n"), localise(colour), localise(object));

      Okay, no problem. Now let's consider the C++ equivalent:

      cout << "The " << colour << ' ' << object << '\n';

      Harder to read? Maybe, but the tokens are all in the order that they'll appear in the output, so I'll give C++ that one. Now let's localise it. How about something like:

      cout << "The ".localise() << colour.localise() << ' ' << object.localise() << '\n';

      That's fine, right? No more complex than the C version. Well, almost. Let's make French the target language. We want to turn 'the black cat' into French. Now we have a problem. In French, the word order is different. The result we want has the colour after the noun. No problem in the C version, the format string is just translated as "Le %2$s %1$s". The arguments are reversed (well, it's a little more complex because you also need agreement between the noun and the article, but I'll skip over that for now - it can be solved in the same way). What about the C++ version? Well, because the word order is in the code, not the data, you need different code paths for English and French. And that's just with a three-word sentence. Now consider the kind of sentence that actually appears in a typical UI. Consider German word-order rules. Your simple C / Objective-C strings file has to be replaced by a huge tangle of C++ code.

      --
      I am TheRaven on Soylent News
    21. Re:In practice it's like a different language. by Anonymous Coward · · Score: 0

      I think your example only shows that attempting to localise by 1:1-mapping single words is naive.

    22. Re:In practice it's like a different language. by TheRaven64 · · Score: 3, Informative

      My example is a trivial example. Go and look at some real code. In big applications, we use this pattern in Objective-C all the time. It's a trivial way of constructing localised strings. Now go and look at the mess of template metaprogramming that people use to do the same thing in C++...

      --
      I am TheRaven on Soylent News
    23. Re:In practice it's like a different language. by obsess5 · · Score: 2

      In real code, you localize based on entire messages, not individual words. How do you localize an English word that, with one spelling, may be a noun or verb and, in the latter case, may be of different tenses? You would need the context of the entire message and a natural language processor to translate the word. (Localizing the common word "The" in isolation as you do is fraught with errors.) Consequently, it's better (and quicker and easier) to translate entire messages rather than individual words.

    24. Re:In practice it's like a different language. by sco08y · · Score: 3, Funny

      That's fine, right? No more complex than the C version. Well, almost. Let's make French the target language. We want to turn 'the black cat' into French. Now we have a problem. In French, the word order is different. The result we want has the colour after the noun.

      It seems like it would be a lot easier to just change the word order of the offending languages than to screw up perfectly good C++.

    25. Re:In practice it's like a different language. by jadrian · · Score: 1

      Could you expand on this? I don't work that much with OO languages. So I looked for 'Liskov substitution principle' and I understand it concerns semantic requirements of types in a hierarchy. But aren't these semantic requirements valuable precisely so that your code behaves uniformly across types, and is therefore reusable?

    26. Re:In practice it's like a different language. by Paul+Dubuc · · Score: 2

      C with classes is a derogatory term used to describe programmers and code which wraps C-style code and various bad practices with classes. ...

      "C with classes" was the name given to the language before it was named C++.

    27. Re:In practice it's like a different language. by Anonymous Coward · · Score: 0

      So what? C has function pointers, so you can do it that way too, just like C++ virtual methods.

      I've had the C++ brainwashing and used it for 5 years commercially. The more I learn about it, and the more language "improves" the more I laugh at it and the more I respect and admire C. Linus was right.

      And don't get me started on exceptions, templates, iostream, references...

      This is a good point of reference for C++ issues.

    28. Re:In practice it's like a different language. by tibit · · Score: 1

      It's not about reusability, it's not quite about uniformity, it's about expectations. If you have an instance of Foo (or a derived class), things go horribly wrong if you cannot consistently assume anymore that it acts like Foo. By horribly wrong I mean you have bugs galore. There's no problem deriving Bar from Foo and documenting that it acts weird -- you can still "reuse" Bar -- but it will, almost always, lead to bugs. Reusability is a nice side effect.

      --
      A successful API design takes a mixture of software design and pedagogy.
    29. Re:In practice it's like a different language. by Anonymous Coward · · Score: 0

      Yes, that is his entire fucking point.

      C's printf makes it trivial to localize an entire message, because the template is a single string into which parameters are slotted.

      C++'s overloaded << makes it extremely difficult, because you are expected to break up the string and mix the parameters in with it.

      Of course, C++ has solutions (boost::format) but that is not part of the standard and, even in 2012, is not always available to C++ developers. Many of whom, quite sensibly, resort to falling back on cstdio and good old printf, instead of putting up with the inexcusable shithole that is iostream.

    30. Re:In practice it's like a different language. by MadKeithV · · Score: 1

      Now be careful, because inheritance was not really intended for code reuse. If it does help with code reuse, that's a positive consequence, but it's not what inheritance is for, first and foremost. See Liskov substitution principle and all that jazz.

      Be even more careful, because public inheritance is definitely not intended for code reuse, but protect and private inheritance are!

    31. Re:In practice it's like a different language. by Anonymous Coward · · Score: 0

      No, it's ugly as hell and bad programming. It seems to prove your point because both versions are completely awful pieces of terrible code.

      Plus, the g-g-g-g-g-g-g-g-parent is right anyway, FILE is bad, printf is awful, void* can usually be avoided if you have a brain, and if you didn't understand his memcpy point you definitely shouldn't be coding in a language that is too complex for your tiny C brain.

  7. Comment removed by account_deleted · · Score: 2

    Comment removed based on user account deletion

  8. Fascinating Software Engineering Challenge by Bookwyrm · · Score: 5, Insightful

    In some ways, a lot of what is being added to C++ makes me think of Scala, just less readable.

    While the additions and extensions certainly make things more interesting and potentially more powerful/easier for the *individual* programmer, I look forward to seeing what sort of interesting train wrecks happen when larger teams try to make use of these features. I certainly hope the debuggers are being updated to be useful when someone's written a template that uses a #define'd macro to specify a closure that is passed through an anonymous function, etc.

    This strikes me as the next generation's 'multi-threading' -- where almost every programmer claims they can handle multi-threaded programming, but very few actually do it well. Particularly in teams when interactions require coordination. Going to take a whole new round of winnowing the wheat from the chaff when it comes to finding developers who can actually use these features well without driving their coworkers insane.

    1. Re:Fascinating Software Engineering Challenge by MurukeshM · · Score: 2

      Time to overhaul the academics. Nearly every engineering course here (I'm in India) has a couple of programming courses. A lot of students do coding some time or the other. Yet not even a sentence is uttered about threads or parallelism, even though practically every computer they code in has multiple cores. They should probably introduce a course on parallel processing as an elective for freshmen.

    2. Re:Fascinating Software Engineering Challenge by khipu · · Score: 2

      Both C++ and Scala are attempts to modernize limited, poorly designed languages (C, Java) by adding things like type parameters and functional features. There are a bunch more of those attempts and I think they have mostly been failures. It's roughly like: "Never try to teach a pig to sing. It wastes time and annoys the pig"

    3. Re:Fascinating Software Engineering Challenge by jgrahn · · Score: 1

      Time to overhaul the academics. Nearly every engineering course here (I'm in India) has a couple of programming courses. A lot of students do coding some time or the other. Yet not even a sentence is uttered about threads or parallelism, even though practically every computer they code in has multiple cores. They should probably introduce a course on parallel processing as an elective for freshmen.

      I took such a course back in the early 1990s. Can't say it did me any good, except to teach me that parallelism is damned hard, and that you can stare on a piece of threaded code for a while and convince yourself it's correct ... and yet it isn't.

      20 years later, I have seen little production code with threads that didn't suck, and little code without concurrency bugs.

  9. Optional GC = Bad by bky1701 · · Score: 0

    Optional Garbage Collection, which is in the new standard, is a horrible idea. You cannot depend on it, as it is not guaranteed, and it will slow programs which do not need it, as well as potentially break low-level operations on memory. I have no idea what they were thinking when they allowed that in, but it is a very dangerous "feature."

    1. Re:Optional GC = Bad by DeathFromSomewhere · · Score: 2

      which is in the new standard

      No it's not. Vendors have always been allowed to tack on GC. None of the big ones do.

      --
      -1 overrated isn't the same thing as "I disagree".
    2. Re:Optional GC = Bad by Anonymous Coward · · Score: 0

      Optional means the memory model has been defined enough for *you* to be able to plug-in a garbage collector of your choice without it relying on undefined on plataform-specific behaviour, it *does not* mean that the language will maybe, maybe not come with a garbage collector activated behind your back.

    3. Re:Optional GC = Bad by Anonymous Coward · · Score: 0

      That's why bky1701 wrote "Optional"

  10. Re:For my next trick by Anonymous Coward · · Score: 1

    I shall now make two predictions:

    1) Hordes of comments are about to appear that denigrate C++.

    2) 95% of these commenters have never written any C++ code more sophisticated than

    cout << "Hello, World!" << endl;

    Welll, now.

    You see, being a C++ GOD, I have actually overloaded 'Hello World!' and made it into an operator! And with my overload, you just implemented an operating system!

  11. Re:For my next trick by Anonymous Coward · · Score: 2, Funny

    That's way to verbose. I overloaded the ;

  12. Re:For my next trick by Anonymous Coward · · Score: 0

    Yeah, everyone knows 'using namespace' is for chumps.

  13. Not seeing (1) by SuperKendall · · Score: 4, Insightful

    I don't think you'll see a lot of people flaming C++, there just aren't that many people that care one way or the other anymore.

    I think some of the new features look nice but mainstream use has been shifting away from C++ for a while and I'm not sure I see these new features drawing many back...

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:Not seeing (1) by gbjbaanb · · Score: 4, Interesting

      Mainstream use is shifting back to C++ since Microsoft decided that C++ was batter than C# (or at least Sinofsky and the Windows team decided that was the case). Herb Sutter has done a lot of presentations on the new paradigm at Microsoft - do a quick google.

      Of particular note is the reason they're giving for this: in the datacentre native code reduces the amount of energy required to run your apps, and that adds up significantly if you're using dynamic or even JIT language.

    2. Re:Not seeing (1) by shutdown+-p+now · · Score: 1

      mainstream use has been shifting away from C++ for a while

      What do you think most Windows desktop apps are written in these days?

    3. Re:Not seeing (1) by Anonymous Coward · · Score: 0

      We are shifting from C/C++ apps to applications based on HTML/SVG and AJAX. The backend of those applications is mostly in Java, PHP and some C#. On smartphones Objective-C and a Java-derivate is very popular. However, in other areas of embedded systems C++ is used. Nevertheless, in future we will use more DSLs for application development making the GPL below that less important. Even though there are some nice new features in C++ make writing DSLs with C++-templates easier.

    4. Re:Not seeing (1) by SuperKendall · · Score: 1

      Thanks, that was interesting, (I liked his "Welcome to the Jungle" entry on multi-core), but I have to take what he says with a grain of salt...

      He has a C++ book out and also obviously is very involved in the community. While I will say that makes him way more knowledgeable about C++ than most people, I also think he is understating what .Net can do - it's been basically compiled on the fly for a while.

      But more importantly I really feel like modern languages offer better and easier to use constructs for dealing with multi-threading, and just programming in general. C++ is a very powerful language (I spent a number of years working with in in Windows) but I think it's much harder to get people to point where they are writing decent code in C++ than in just about any other modern language.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    5. Re:Not seeing (1) by SuperKendall · · Score: 1

      What do you think most Windows desktop apps are written in these days? .Net or Visual Basic.

      Although desktop apps are a declining field all by themselves.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    6. Re:Not seeing (1) by shutdown+-p+now · · Score: 1

      .Net or Visual Basic.

      For one, those two are the same thing, as VB today runs on .NET - and has been doing that for 10 years now.

      For another, it's plainly not true. Looking at the set of apps running on my desktop, or those around me, I can see maybe 2-3 managed apps, and the rest is native.

    7. Re:Not seeing (1) by Anonymous Coward · · Score: 0

      In Google's/Mozilla's overenthusiastic dreams.

      Unless you count "posting comments to discussions" as an application, "applications based on HTML/SVG and AJAX" even though people's been talking about bright HTML5 future for years.

      Remember how when iPhone was released people were like "We won't need native applications for iPhone, iOS Safari is awesome! HTML5! HTML5!" and how there's still none, because as soon as Apple released iOS SDK there was no more incentive for HTML5 webapps?

    8. Re:Not seeing (1) by RzUpAnmsCwrds · · Score: 1

      Whether the performance of a managed language (most commonly Java or .NET) is inferior to C++ is almost entirely dependent on your workload.

      Java running on the Oracle VM (HotSpot) is actually faster than C++ in many ways (object allocation, virtual function/method calls, the built-in data structures). "Modern" C++ code that uses STL and smart pointers tends to waste a lot of time copying memory around and/or tracking reference counts. Of course, the GC in Java also spends a lot of time copying memory around, but it can be done concurrently and for most programs it is quite efficient.

      C++ wins big in two main ways: latency and with loopy scientific code. The fact that you have GC in Java makes latency hard to predict, and if you need to meet latency targets a high percentage of the time C++ is probably the right choice. As for scientific code, Java VMs typically make very poor use of vector instructions and do not have anywhere near the sort of loop/memory ordering optimizations you find in something like ICC.

    9. Re:Not seeing (1) by Anonymous Coward · · Score: 0

      c/c++, because they are multi-platform programs.

    10. Re:Not seeing (1) by gbjbaanb · · Score: 1

      He does work for Microsoft, I think his expertise in the community was the reason they hired him. Given that, I'd say he is more knowledgeable about the real OS-level limitations of .NET than the rest of us.

      (although I did enjoy reading Chris Brumme's blog posts where he went into detail about the .net runtimes and some of the decisions they'd not do again if they had the chance to start over. The one on exceptions was brilliant).

      Yes, C++ is harder than PHP, but that's maybe the point. I've seen so much truly awful code and most of it is in 'easy' languages. I do despair that the answer to a difficult problem (coding) is to make yet another accessible language that doesn't solve the problem well enough, and you end up with more coders who think they can do the job when really its all about education and training. To my mind C++ isn't that difficult, but then I've been doing it for years and I understand what happens under the covers, which allows me to make much more informed decisions on how to design my code. A lot of my junior colleagues seem to just slap something together that works and leave it at that. Then I have to come in and fix the performance issues.

      Threading is probably better in C++ now. You have the new thread constructs (eg thread thread1 = thread(myfunc, paraam1, param2); will start a thread going. But you also have a load of power over what else you can do compared to other languages).

      Or if threading is too difficult, you should look into things like Thread Building Blocks that try to keep the threads compartmentalised (which is the problem most people have with threading - getting their shared data mixed up between the threads). Or you could use OpenMP which is amazingly easy to code for (just slap a pragma before your code and your loops with magically become parallelised)

      Maybe C++ isn't that hard after all, it just has that 'my language is so much easier and just as powerful' hype working against it.

    11. Re:Not seeing (1) by gbjbaanb · · Score: 1

      "Modern" C++ code that uses STL and smart pointers tends to waste a lot of time copying memory

      this is false. Unless you explictly code to pass by value all the time, the optimiser will be making it work without the copying. Modern C++ even has the move constructs now that make it easy to ensure your memory is moved rather than copied in the tricky cases.

      I always thought the problems with the java-style languages were more memory based. Every one I've seen sucks up RAM like there's no tomorrow - which is fair, coders in those languages are told that memory is cheap and that the GC will fix all their problems for them. Its a lie (of course) but enough still believe it.

      And there are enough reports of poor performance with WPF that you have to think these new languages with their fancy libraries are poorly designed, or engineered. When your GUI requires better performance you know your language isn't up to scratch.

    12. Re:Not seeing (1) by SuperKendall · · Score: 1

      For another, it's plainly not true. Looking at the set of apps running on my desktop, or those around me, I can see maybe 2-3 managed apps, and the rest is native.

      You can release C# / VB apps in compiled form, how do you know that is not what has been done?

      Yes I know VB runs on the .Net runtime, though a lot of VB6 people never moved on because it also changed the language somewhat (just like C++ on the .Net runtime was not quite the same thing either).

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    13. Re:Not seeing (1) by shutdown+-p+now · · Score: 1

      You can release C# / VB apps in compiled form, how do you know that is not what has been done?

      What do you mean by "compiled form"? It's pretty easy to tell a CLR .exe/.dll from a native one.

      just like C++ on the .Net runtime was not quite the same thing either

      Not so. VC++ can actually compile the entirety of ISO C++ (to the extent it normally supports that), sans setjmp/longmp, to target .NET. C++/CLI is a set of language extensions that enables access to CLR object model, which can be used as a glue language between C++ proper and other .NET stuff, but it does not have to be used in C++ code compiled to IL.

    14. Re:Not seeing (1) by Anonymous Coward · · Score: 0

      I suspect he was referring to the original "managed C++" horror show that preceded C++/CLI. Perhaps you've blocked it from memory - nobody would blame you...

      - T

    15. Re:Not seeing (1) by shutdown+-p+now · · Score: 1

      Managed C++ was a bad thing, but everything I said still applies - it was a bunch of syntactic extensions that only had to be used to glue together vanilla C++ code and .NET libraries. You could compile plain C++ to managed IL since the very first versions of VC++ that shipped with .NET - that was not coincidental, as CLR was designed with that in mind, hence why it has e.g. raw function and data pointers.

  14. He's optimistic by mark-t · · Score: 1

    FTA

    I expect to see the first complete C++11 compiler sometime in 2012

    I expect to see the first complete C++11 compiler sometime after I see the apocalypse.

    Oh right... I guess that would be December 2012, wouldn't it? :)

    Seriously... while a lot of compilers implement some of the features, I really don't think there's a hope in hell of seeing any real progression to adopting the standard. With C, the standard developed around what many compilers were already doing... ditto with the original C++ spec. But C++11 describes a standard that absolutely nobody has ever got anywhere close to, so I don't imagine that there's going to be a lot of drive to adopt it.

    1. Re:He's optimistic by 19thNervousBreakdown · · Score: 2

      The majority of it is implemented. http://gcc.gnu.org/projects/cxx0x.html

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    2. Re:He's optimistic by grumbel · · Score: 4, Informative

      > But C++11 describes a standard that absolutely nobody has ever got anywhere close to, so I don't imagine that there's going to be a lot of drive to adopt it.

      All popular C++ compilers already implement large parts of C++11, so the chance of seeing widespread C++11 adaption in the not so distant future is pretty high. Also this wasn't really any different with C++98, which essentially no compiler supported on release and which then took a few years to gain widespread adoption.

    3. Re:He's optimistic by Anonymous Coward · · Score: 0

      When will we see the first C++11 book from Addison Wesley (now Pearson I think) with Brian Kernighan as senior editor?

      I think that'll be the informal "Gentlemen, start your engines" moment with respect to pulling developers' attention away from C++98.

    4. Re:He's optimistic by shutdown+-p+now · · Score: 1

      We never had a "complete" C++98 or C++03 compiler, either. Didn't stop people from writing successful production software in that.

    5. Re:He's optimistic by mark-t · · Score: 1

      Indeed... more of it than what I thought. Thanks for the link

      But the concurrency stuff still seems quite far from being fully supported.

    6. Re:He's optimistic by mark-t · · Score: 1

      My complaint wasn't about lack of successful software, I was complaing about calling something a standard when nobody is really particularly close to following it yet.

    7. Re:He's optimistic by shutdown+-p+now · · Score: 1

      Well, C++ has always been like that. Come to think of it, so has HTML/CSS. It still works out in the end, more or less.

    8. Re:He's optimistic by jgrahn · · Score: 2

      All popular C++ compilers already implement large parts of C++11, so the chance of seeing widespread C++11 adaption in the not so distant future is pretty high. Also this wasn't really any different with C++98, which essentially no compiler supported on release and which then took a few years to gain widespread adoption.

      C++98 was worse. There was extern templates, which was a major mistake (read the proposal to remove it from C++11 for some amusement). There was Microsoft, who lost interest in C++ around that time, and condemned a generation of Windows programmers to Visual Studio 6 and a weak standard library implementation. And yet gcc was usable around 1999 or so. I started using the std namespace in late November that year.

    9. Re:He's optimistic by CSMoran · · Score: 1

      We never had a "complete" C++98 or C++03 compiler, either. Didn't stop people from writing successful production software in that.

      Didn't Comeau C++ use to be 100% compliant, extern included?

      --
      Every end has half a stick.
    10. Re:He's optimistic by shutdown+-p+now · · Score: 1

      They had all the features, yes, but I'm pretty sure they had some conformance bugs, too. With spec of this size (and that many defect reports), everybody does.

  15. Re:George Bjarne Lucas Stroustrup by Anthony+Mouse · · Score: 1

    WTF?

  16. Re:For my next trick by rmstar · · Score: 0, Troll

    Hey you,

    I've written big apps in C++ and can tell you: C++ SUCKS!! It's a piece of shit language with a very crappy garbage collector, a baroque, undecidable syntax, no end of karma, and a community that revels in BDSM programming. With an emphasis on the M.

    So there.

  17. Re:For my next trick by Anonymous Coward · · Score: 0

    I nearly thought you were serious, until you started complaining about C++'s garbage collector...

  18. Re:For my next trick by Anonymous Coward · · Score: 1

    That's nothing. I overloaded eof.

  19. More on C++11 by Anonymous Coward · · Score: 0

    a video of Stroustrup presenting C++11 style: http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Keynote-Bjarne-Stroustrup-Cpp11-Style
    a paper by Stroustrup describing C++11 for software infrastructure: http://www.computer.org/portal/web/computingnow/0212/whatsnew/computer-r?src=cnhome-v1

  20. Re:For my next trick by boaworm · · Score: 1

    C++ SUCKS!! It's a piece of shit language with a very crappy garbage collector

    If you are making extensive use of the C++ garbage collector and it isn't working very well, I can understand your frustration :D

    --
    Probable impossibilities are to be preferred to improbable possibilities.
    Aristotele
  21. A decade late and a dollar short by Animats · · Score: 0, Troll

    The new version of C++ is a decade behind schedule, and consists mostly of marginal features. Memory safety hasn't improved. Concurrency isn't really supported in the language; all that's really been done is to nail down some of the semantic issues that matter when multiple threads are executing on superscalar processors. There are lots of new features only useful to people writing templates, which are a terrible programming environment. "auto" is useful (I wanted to call it "let", but there was objection to a new short keyword), mainly because the type definitions of iterators are so bulky. The main purpose of "auto" is to allow for (auto p = arr.begin(); p != arr.end(); p++) {... } without worrying about the type of arr. As long as arr is an iterable collection, that should work.

    This still doesn't prevent buffer overflows, but at least the most concise way to iterate over an array is reasonably safe. (Not totally safe; modifying a collection over which you are iterating breaks the memory model.) Over the next few decades, the number of buffer overflow bugs might decrease slightly.

    It's an improvement, but not one that was worth waiting a decade for.

    1. Re:A decade late and a dollar short by Anonymous Coward · · Score: 2, Informative

      It is easy to refute your argument on memory safety and auto with a single line of code:

      auto obj = make_shared( arg1, arg2 );

      lambda expressions can only be assigned to an auto, because the actual type is compiler defined.

      auto some_callable_type = []( float f ){ return f * f; };

      Currency isn't supported? What more do you want apart from: threads, mutexes, atomics, thread local storage, concurrency safe memory model, futures, promises, async tasks and thread exception transfer?

    2. Re:A decade late and a dollar short by Anonymous Coward · · Score: 0

      The p++ is wrong, you must use ++p since it doesn't create a copy.

      Clearly you are a terrible C++ programmer, and hence unqualified to comment on it.

    3. Re:A decade late and a dollar short by maxwell+demon · · Score: 1

      The new version of C++ is a decade behind schedule,

      So you're saying it was planned to be finished in 2001? Given that the previous version is from 2003, I strongly doubt that.

      --
      The Tao of math: The numbers you can count are not the real numbers.
    4. Re:A decade late and a dollar short by Anonymous Coward · · Score: 0

      maybe the supreme c++ leader is, too old... or simply doesn't care to move faster..

    5. Re:A decade late and a dollar short by shutdown+-p+now · · Score: 2

      The main purpose of "auto" is to allow for (auto p = arr.begin(); p != arr.end(); p++) {... } without worrying about the type of arr.

      No, it's not. The above is written as follows in C++11:

      for (auto x : arr) { ... }

      And, of course, you can just as well use the actual element type there instead of auto.

    6. Re:A decade late and a dollar short by QuasiEvil · · Score: 1

      If your compiler is doing anything different with p++ and ++p in that expression, it has a sucktastic optimizer. There's no reason it should create a copy when the value of the expression is thrown away.

    7. Re:A decade late and a dollar short by Anonymous Coward · · Score: 0

      > Currency isn't supported?
      You mean dollars, or euros?

  22. Some idiotic stuff too by Daniel+Phillips · · Score: 3, Interesting

    I guarantee you will quickly come to hate the new "narrowing" errors, for example any time int converts to float inside initializer curlies, or double to float. As a language feature, this lies firmly in the category of wanking.

    That said, my code is all full of lambdas now, thankyou. On the other hand, lambda syntax is uglier than sin. While a lambda can do anything a lexically scoped nested function can, it is not pretty. Now obviously, there is no reason not to support proper lexically scoped nested functions, as GCC already does. Arguing that they are now unnecessary because of lambdas is, again, wanking. The practical fallout is that when you move a lambda-style helper function to global scope or to member status, you have a bunch of editing to do, to remove the ugly auto/lambda bits.

    Another big disappointment is, nothing was done to address the good features C99 has that C++ does not. Designated initializers and variable size array parameters, to name two. Wanking again.

    On the whole, there is too much wanking going on in the C++ stewardship process. Guys, you need to remember, C++ does not exist only as a means of compiling the STL.

    --
    Have you got your LWN subscription yet?
    1. Re:Some idiotic stuff too by Anonymous Coward · · Score: 0

      It sounds like you want to be programming in a dynamically typed language where compilers raise a minimum of fuss when you do the wrong thing. Any argument you make to the contrary lies firmly in the category of wanking. Now isn't that a persuasive argument?

    2. Re:Some idiotic stuff too by Daniel+Phillips · · Score: 1

      Dear Mr Coward, I am perfectly happy programming in a statically typed language for the applications I currently develop. However, I am against wanking in general, including the sort of wanking you just stooped to.

      --
      Have you got your LWN subscription yet?
    3. Re:Some idiotic stuff too by Anonymous Coward · · Score: 0

      So.. You put your words into the mouths of people "defending" C++ and refute them. Such a genius you are. Its painfully obvious from your brain vomit in the comment that you have little to no understanding of modern C++. Mental defectives like you are well suited for C. Comparing lambdas which have state and are unnamed function _OBJECTS_ that can be passed around to a UGLY hack (Surprise.. came from the GCC community again.. ) like nested functions (which has none of those things) is stupid. Keep wallowing in your ignorance. Please do post more of your "insights" they are quite entertaining - much in the same way that a monkey in a zoo is.

    4. Re:Some idiotic stuff too by Daniel+Phillips · · Score: 1

      Its painfully obvious from your brain vomit in the comment that you have little to no understanding of modern C++.

      Dear cowardly wanker,

      I do not hesitate to presume that I have written more and better C and C++11 than you. Come back when you are in a correct frame of mind to debate intelligently.

      --
      Have you got your LWN subscription yet?
    5. Re:Some idiotic stuff too by Anonymous Coward · · Score: 0

      Your comment was factually incorrect. I enjoy ridiculing your stupidity.

      I have written more and better C and C++11 than you.

      Oh really? But then how come you have such a tiny penis? You must be some kind of chav.

      cheerio!

      -AC

    6. Re:Some idiotic stuff too by Anonymous Coward · · Score: 0

      You're back, but not any more intelligent than before. Rubbed it raw yet?

    7. Re:Some idiotic stuff too by Anonymous Coward · · Score: 0

      Funny how you presume intelligence when you have demonstrated none.

  23. Assigning new values to constants can be useful! by MarcAuslander · · Score: 2

    I was amused by the comment "If that incr(0) were allowed either some temporary that nobody ever saw would be incremented or - far worse - the value of 0 would become 1. The latter sounds silly, but there was actually a bug like that in early Fortran compilers that set aside a memory location to hold the value 0. "

    Back then, I wrote Fortran subroutines which took computed dimension arrays by declaring the arrays with crazy bounds, numbers I hoped would never be used as constants, and then "assigning" the real bounds to the "constants".

    Those were the good old days.

  24. Better than I expected by Anonymous Coward · · Score: 0

    Actually makes a lot of sense. I normally pretty much ignored the committee, since most of their work seemed to involve things (template madness) that I strictly ban from my teams' projects anyway. The influence of C# is obvious and largely welcome; I'm less thrilled about seeing more boost (a lot of banned code there too, though most of it here looks okay) and attempts to bolt on functional paradigms. That falls under the same heading as garbage collection, as in Apple's misbegotten attempt with Objective-C++.

    Still no viable replacement for the preprocessor, but a fair amount of stuff that looks useful, and some to be avoided.

    1. Re:Better than I expected by Anonymous Coward · · Score: 1

      Banning random parts of the language because you don't like them? Glad I don't work for you. Fucking dinosaurs.

    2. Re:Better than I expected by Anonymous Coward · · Score: 1

      Amen.

  25. Re:George Bjarne Lucas Stroustrup by dyingtolive · · Score: 3, Insightful

    I think he either forgot his LSD today, or took too much. Not sure which yet.

    --
    Support the EFF and Creative Commons. The war is coming, and they're supporting you...
  26. Re:For my next trick by busyqth · · Score: 1

    Since the advent of 64-bit pointers, the garbage collector in all of my C/C++ compilers has been working great.

  27. Re:For my next trick by dyingtolive · · Score: 0

    I overloaded your mom.

    --
    Support the EFF and Creative Commons. The war is coming, and they're supporting you...
  28. Re:For my next trick by Anonymous Coward · · Score: 0

    I've written big apps in C++ and can tell you: C++ SUCKS!!

    Based on your comment about the C++ garbage collector, I assume your big C++ app was something like:

    for (int i=0; i<10; i++)
        std::cout << "Hello, World." << std::endl;
    std::cout << "You had me at the first Hello!" << std::endl;

  29. To little, to late by Anonymous Coward · · Score: 0

    Who cares about C++ these days?

    Time to move on to something modern

    1. Re:To little, to late by Anonymous Coward · · Score: 0

      There is always Common Lisp and Smalltalk to fall back on. Or have all their features been ported into other languages by now? Only took a few decades.

    2. Re:To little, to late by 91degrees · · Score: 1

      Who cares about C++ these days?

      The games industry, the financial software industry, and most companies developing niche hardware.

    3. Re:To little, to late by LizardKing · · Score: 1

      The games industry

      Can't speak for them ... never worked there. However ...

      the financial software industry

      I currently work there, and it's almost all Java or C# apart from a few legacy things in VB (shudder). The only place a subset of C++ is used is with the extremely time critical stuff that a single team uses to do arbitrage where we can host servers close enough to the exchange - and nigh on all of that would actually compile with a C compiler rather than a C++ one.

      and most companies developing niche hardware

      Where I used to work (doing automation), and most of my programming acquaintances still do. And it's mostly C with a little ARM assembler. C++ has never been big there because the libraries are too big and the memory use too unpredictable thanks to the amount of copying idiomatic STL code results in.

    4. Re:To little, to late by 91degrees · · Score: 1

      Plenty of legacy C++ in the finance industry. Heaps of jobs advertised want Boost, and last time I was interviewed for a position (at Bloomberg) they were interested in my C++ skills.

      Not all niche hardware is small scale ARM based. A lot of it is based on Windows or Unix powered by a pretty standard desktop PC. Digital billboards, large touch screens. Things like that.

  30. Re:For my next trick by rmstar · · Score: 0

    I nearly thought you were serious, until you started complaining about C++'s garbage collector...

    Well, the thing is that this is typical C++ brain damage. If you criticize that there is no garbage collector, you get some bullshit involving std::shared_ptr. I mantain that most C++ programmers think that that rotten POS is actually a garbage collector. If you then say, well, whatever, "C++ has a rotten POS of a garbage collector", then, of course, it turns out C++ has no garbage collector. Go figure.

    Brain damage all around.

  31. Just awful what C++ is turning into by GodfatherofSoul · · Score: 1

    I watched a few of the "Gone Native" webcasts on the C++ extensions, and it's crazy what they're doing with the language. Are the features useful? Yes, but they're taking a complex language and slapping on yet more functionality. Some new C++ code syntax doesn't even *look* like C++ anymore it's so different. Not everyone is a C++ guru and the language is bad enough supporting so many different paths to the same implementation outcomes. This is just going to make staffing, testing, training, and code review that much worse trying to juggle yet another barrel-full of C++ "improvements".

    They need to just start from scratch and create a limited subset of features that doesn't pretend to be C and doesn't lug around all of the past mistakes in the standard, and call it C+++.

    --
    I swear to God...I swear to God! That is NOT how you treat your human!
    1. Re:Just awful what C++ is turning into by Anonymous Coward · · Score: 0

      I watched a few of the "Gone Native" webcasts on the C++ extensions, and it's crazy what they're doing with the language. Are the features useful? Yes, but they're taking a complex language and slapping on yet more functionality. Some new C++ code syntax doesn't even *look* like C++ anymore it's so different. Not everyone is a C++ guru and the language is bad enough supporting so many different paths to the same implementation outcomes. This is just going to make staffing, testing, training, and code review that much worse trying to juggle yet another barrel-full of C++ "improvements".

      Your complain boils down to "C++11 has some changes".

      With time you will stop complaining about how things changed, you will learn the new features and you will understand how silly your comment is. The sooner you will learn, the faster you will stop complaining.

      They need to just start from scratch and create a limited subset of features that doesn't pretend to be C and doesn't lug around all of the past mistakes in the standard, and call it C+++.

      So, to your complain that C++ has changed you provide your answer of simply "starting from scratch". Suffice to say, your complaint isn't coherent.

    2. Re:Just awful what C++ is turning into by Anonymous Coward · · Score: 0

      C+++ lol
      How about C-- , or C+- ?

      No ?
      C-+ ?

      Shut up then...

    3. Re:Just awful what C++ is turning into by shutdown+-p+now · · Score: 1

      They need to just start from scratch and create a limited subset of features that doesn't pretend to be C and doesn't lug around all of the past mistakes in the standard, and call it C+++.

      The whole point of C++ is to be a very powerful language while retaining backwards compatibility with a large body of existing C++ code - some decades old by now - and also allowing to reuse plain C headers with little or no changes. It does that admirably.

      If you need a whole new language along those lines, Clay is probably what you want.

    4. Re:Just awful what C++ is turning into by GodfatherofSoul · · Score: 1

      Your complain boils down to "C++11 has some changes".

      That's not my complaint, your level of comprehension maybe

      --
      I swear to God...I swear to God! That is NOT how you treat your human!
    5. Re:Just awful what C++ is turning into by euroq · · Score: 2

      They need to just start from scratch and create a limited subset of features that doesn't pretend to be C and doesn't lug around all of the past mistakes in the standard, and call it C+++.

      They did. Check out the D Programming Language.

      --
      Just because the U.S. is a republic does not mean it is not a democracy. Democracy/republic are not mutually exclusive.
  32. No Problems Here by Anonymous Coward · · Score: 0

    All of the issues with C++ are easily dealt with simply by coding in C and checking back in to see what C++ is like in another ten years.

  33. Re:For my next trick by Anonymous Coward · · Score: 0

    I always thought if you're going to go to all the trouble of smartpointers, you might as well just use garbage collection and make your life easier.

  34. Re:For my next trick by Imagix · · Score: 1

    Don't leave garbage lying around. Clean up after yourself.

  35. So, has it gained a standard ABI yet? by blackpaw · · Score: 1

    Probably the last thing preventing it from being truly safe and useful in shared libraries across implementations.

    How many years has it been?

  36. So what is a good book to learn C++11 by Anomalyst · · Score: 1

    and these new features?

    --
    There is no right to feel safe thru security vaudeville at the expense of everyone's freedom, privacy and tax money.
    1. Re:So what is a good book to learn C++11 by oldhack · · Score: 1

      Ulysses by James Joyce.

      --
      Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
    2. Re:So what is a good book to learn C++11 by LizardKing · · Score: 4, Funny

      Dante's Inferno. Sample quote:

      Obscure, profound it was, and nebulous, So that by fixing on its depths my sight - Nothing whatever I discerned therein.

    3. Re:So what is a good book to learn C++11 by Anonymous Coward · · Score: 0

      Stephen Prata's "C++ Primer Plus" 6th ed is the only book I have found that covers the new standard. He has an entire chapter devoted to the new stuff, so you don't have to wade through the entire book. He does integrate the new stuff into the main text, though, where appropriate.

    4. Re:So what is a good book to learn C++11 by Anonymous Coward · · Score: 0

      "Oscura e profonda era e nebulosa
      tanto che, per ficcar lo viso a fondo,
      io non vi discernea alcuna cosa"

  37. Re:For my next trick by shutdown+-p+now · · Score: 2

    Garbage collectors only manage memory. Smart pointers, on the other hand, can manage any kind of resource - whatever you release in your destructor.

    That's why languages like Java and C# still need stuff like Closeable and IDisposable, and syntactic sugar for them to avoid writing try/finally ladders. Whereas in C++, resource management has always been done right, and memory is treated as just another kind of resource.

  38. Comment removed by account_deleted · · Score: 2

    Comment removed based on user account deletion

  39. Meh... by jythie · · Score: 2, Interesting

    I gave up on C++ years ago. It has really become a 'geek cred' language with a constantly changing 'right' way an aesthetic, perfect for figuring out if a fellow geek is from the same snapshot of teaching you came from, but that is about it. It has become overly complex with redundant language features that one needs to keep relearning in order to understand other people's code.. and of course with complexity comes the ability to show off your knowledge through doing things in 'clever' ways.

    Good for showing off.. bad for getting actual work done, esp for projects that last more then a year or two.

    1. Re:Meh... by Anonymous Coward · · Score: 0

      Bad developers can write bad code in any language. This applies to all code before or without design methods. Some people call that agile even though agile requires a lot of discipline and requires a feature -> design -> code approach (and do not forget to write tests). Back to your argument. C++ was an over engineered language from the beginning. It is not the only one. Therefor we developed approaches to deal with such languages called coding conventions and coding restrictions. Yes these differ from company to company and sometimes from project to project. But that is not really a problem. In the Java-world for instance people you different libraries for the same purpose from project to project. And you have to relearn how they work every time. That is one part of our job, that we are able to use any language and internal and external DSL to develop software.

    2. Re:Meh... by jgrahn · · Score: 2

      I gave up on C++ years ago. It has really become a 'geek cred' language with a constantly changing 'right' way an aesthetic, perfect for figuring out if a fellow geek is from the same snapshot of teaching you came from, but that is about it. It has become overly complex with redundant language features that one needs to keep relearning in order to understand other people's code.. and of course with complexity comes the ability to show off your knowledge through doing things in 'clever' ways. Good for showing off.. bad for getting actual work done, esp for projects that last more then a year or two.

      Well, what are the alternatives? I my domain, it's plain old C. Java is not an option, and from the little I hear fashion changes *more* quickly there anyway.

      I think your impression of the changing "right" way is warped, or perhaps you're in a subculture I'm not familiar with. I see these different ways:
      (a) C with classes, from C programmers who've read a book but don't quite get it.
      (b) OOP/Design Patterns rule! Popular in the mid-1990s. Lots of inheritance and stuff; every piece of code aspiring to generality and inclusion in a reusable library.
      (c) The pragmatic view, e.g. in Stroustrup's "The C++ programming language".
      (d) Template Meta-Programming rules!

      (a) and (b) are dead ideologies today, although you discover lost tribes practicing them now and then. I happily ignore the (d) crowd unless they can provide a stable, documented library which I don't have to debug. Besides, they seem to have settled down a bit in recent years.

      To summarize, I see no big change since the late 1990s.

    3. Re:Meh... by Greyfox · · Score: 2
      I've been doing some system-level programming and... stuff... with the language again lately. I was getting tired of having to load a language VM to run my code (Flavors of perl, Ruby or Java) and not having a whole lot of control over the hardware I'm running on. I'm just as happy rolling up a raw process and seeing how little memory I can get away with using. A mostly-C socket server and a tiny little btree class is all I need to serve up some legitimately useful information with a memory footprint under 20 kilobytes. You can't even run fucking ls in under 20 kilobytes these days!

      I know, I know, why do that when you can dedicate an entire system to an oracle database instead. Eventually you just can't bludgeon your problems to death with hardware anymore and need more subtle solutions.

      My last demo (Which you can find at https://github.com/FlyingRhenquest/fr_demo) is still pretty rough around the edges but was mostly to allow me to play with Cppunit and boost::thread. My C++ socket server makes for a weightier process, but probably scales better since it uses threads instead of forking off a new process for each request. You can always fork if you want to, at least on Linux -- it just copies the thread you're currently in. So you can exec off a new process if you want to. I should probably be using boost::asio instead but that seems like a lot of extra complexity just to get the bits I need.

      Gotta say I really like Cppunit. I feel like I'm abusing it making it test multi-threaded things but it just keeps working beautifully. It's not at all difficult to set up a suite of unit tests to run. If you do it the way I did, most of the work is just linking the new object into your unit test executable in the makefile.

      I also like boost's threads, or more specifically their mutexes. scoped_lock is teh sexieh! C and C++ scope handling in general is just really nice.

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

  40. just awful by khipu · · Score: 0, Troll

    C++ started out as a small set of focused, simple enhancements to C. It didn't pretend to be a great new language, just provide workarounds for some of C's most annoying problems. It was nice and I started using back then, about 25 years ago.

    Now C++ has turned into a disaster, a bloated pig of a language, with features added left and right, incoherently, in order to try to catch up with other languages. But if you want speed, you still have to get rid of all the layers of abstraction that C++ offers and write it in plain C (or a C-like subset). And C++'s attempts at module systems, separate compilation, and garbage collection are still much worse than pretty much any other language.

    1. Re:just awful by Anonymous Coward · · Score: 0

      You don't like the new language features? Well that's great, don't use them then. You can still fall back to plain C code as much as you like. And the resulting code is just as fast as it always was.

      I fail to see what the problem is.

    2. Re:just awful by khipu · · Score: 1

      You don't like the new language features? Well that's great, don't use them then. You can still fall back to plain C code as much as you like.

      How naive are you? In the real world, every language feature that gets added is a feature that all developers have to deal with, because it is used in libraries (including the standard library), affects debuggers, optimization, error handling, resource management, IDEs, etc.

      Furthermore, an even bigger problem is the missed opportunity: C++ tries to be a modern systems programming language, but it fails to do a good job at that. Yet, it has enough inertia to discourage people from investing in doing something better.

  41. 15 years too late by cheekyboy · · Score: 1

    Thats the sort of stuff I heard about 15 years ago, a little late, those guys should have been hard at a new release the day java got popular and got $100s of millions of dollars in developer seeding in the 90s

    Come on intel, give us a microcode C# & java VM accelerator in the cpu.

    --
    Liberty freedom are no1, not dicks in suits.
  42. Re:For my next trick by Anonymous Coward · · Score: 0

    Yeah, right.

    In one corner we have memory, which is 99% of the "resources" needed to be managed, and for which deallocation cannot fail.
    In the other we have everything else, which is not many, and for which deallocation can fail.

    Simple example, open a file, write to it, let the dtor flush and close. If flushing fails, you won't know, because dtors can't return anything, and exceptions in dtors is a big no-no (because, incidentally, there's no GC to free the stuff). That's _wrong_. If you want to do it right, you end up with the same mess.

    This all-resource-should-be-treated-the-same-way stuff, while cute, is a big joke. Smart pointers are a lousy GC scheme that does memory badly (ref counting is inefficient, especially on MP systems, and cannot handle cycles) and does non-memory badly too (because closing these can fail, and dtors can't handle that).

  43. Stroustrup? by Anonymous Coward · · Score: 0

    Stroustrup? Really? Couldn't they find anyone more knowledgeable about C++? They must be really scraping the bottom of the barrel :-)

  44. Doesn't mean all that much... by jonwil · · Score: 1

    Doesn't mean all that much if the compiler vendors dont implement all these great features.

    Visual C++ (the compiler I have to use for a certain project due to C++ ABI compatibility issues with existing code and a better compiler on Windows than GCC IMO) doesn't support any of the interesting stuff like "Delegating Constructors", "Inheriting Constructors", "Initializer Lists", "Range-based for-loop", "constexpr" and "Non-static data member initializers".

    Even the next version is little better on supporting the nice bits of C++11 :(

    Instead Microsoft spent a lot of effort adding all kinds of useless new compiler crap to support their WinRT junk (which to me seems like the answer to a question nobody asked)

  45. Re:For my next trick by shutdown+-p+now · · Score: 3, Interesting

    In one corner we have memory, which is 99% of the "resources" needed to be managed

    Go ahead, count the number of calls to "Close" and "Dispose" in a real world C# or Java app. Then get back to us with some solid number for that 99% claim.

    Simple example, open a file, write to it, let the dtor flush and close. If flushing fails, you won't know, because dtors can't return anything, and exceptions in dtors is a big no-no (because, incidentally, there's no GC to free the stuff). That's _wrong_.

    Suppose you're right, and you detect that flush failed during close. What are you going to do?

    Suppose furthermore that you have an exception in flight, and you've just had flush fail in your finally-block (assuming C#/Java). What are you going to do now?

    If you want exception safety, you need RAII, period. If you have RAII, you might as well use it for memory.

    Smart pointers are a lousy GC scheme that does memory badly (ref counting is inefficient, especially on MP systems, and cannot handle cycles)

    Those claims that refcounting is inefficient are old, but somehow they only show up in synthetic tests. In real world apps, something written in C++ is invariably faster and more responsive than alternatives written in managed languages. That's precisely why C++ is still used far more widely for desktop apps, and is used almost exclusively anywhere perf really matters (like games).

    And there's weak_ptr for cycles.

  46. Re:For my next trick by superwiz · · Score: 1

    Except, of course, in case of circular references. Oh, and before you mention weak references (to be totally honest, I am not even sure if there is a standard weak reference in C++), I'll mention that very few C++ programmers know what they are. The syntax of C++ is so crowded that the language is only used for low level stuff where the extra 5% performance boost is a big deal. I am not sure if CUDA programming can only be done in C++, but I think that if one absolutely needs CUDA, then he is already doing some low-level stuff.

    --
    Any guest worker system is indistinguishable from indentured servitude.
  47. goto is all you need for modern programming? by reiisi · · Score: 2

    (Not arguing with your broad point that these new addirions to C++ will be useful.)

    Goto is no way sufficient for modern programming. You also need some way to manipulate whatever passes for the (effectively stack) constructs that allow nested parameters and locals. And you need some way to hide the bulky extra code (as in text macros and such).

    I got bit on this when I should have known better, back in '97 or so -- using a Fujitsu CoBOL, forgot that the old CoBOL PERFORM was kind of like the old BASIC GOSUB. Found myself trying to use recursive calls in some UI code, and the variables I was expecting to be local to the procedures were, of course, global, and my fancy UI screen would keep blowing up.

    I'd have had to implement effective stacks all over that code to keep it from blowing up. Gave up and reverted to the older, much harder to understand UI.

    --
    Computer memory is just fancy paper, CPUs just fancy pens with fancy erasers; the 'net is just a fancy backyard fence.
    1. Re:goto is all you need for modern programming? by martin-boundary · · Score: 1

      In principle, all you need is to have a set of instructions that can recreate all the machine code instructions in your PC. So that means I think comparisons, jumps and reading/writing global values (a memory location is a global variable, eg named byte000001, byte000002 etc). But your point is well made, without support for local variables and stack frames you'd have to simulate all that as well. There's a lot of layers.

    2. Re:goto is all you need for modern programming? by jrumney · · Score: 1

      Goto is no way sufficient for modern programming. You also need some way to manipulate whatever passes for the (effectively stack) constructs that allow nested parameters and locals. So push, pop and goto then. Anything more is syntactic sugar.

  48. Re:For my next trick by dyingtolive · · Score: 1

    Oh yeah? I modded your mom flamebait!

    --
    Support the EFF and Creative Commons. The war is coming, and they're supporting you...
  49. Prime sieves are easy to miswrite. by reiisi · · Score: 1

    I was playing around with a factoring sieve the other day when I realized just how much my choice of language colored the algorithm I used.

    If you use the same algorithm across all the languages, it prejudices your results. If you use a different algorithm for each, you end up comparing apples and oranges.

    Sure, if you use the stuff in your language that requires overhead, the overhead will be there.

    --
    Computer memory is just fancy paper, CPUs just fancy pens with fancy erasers; the 'net is just a fancy backyard fence.
    1. Re:Prime sieves are easy to miswrite. by superwiz · · Score: 1

      There is a sweat spot for benchmarking though. Roughly 50 mil primes will guarantee that you won't need to go over 4 byte integers. Also don't bother skipping even numbers or numbers divisible by a few of the other lower primes. It will bias the result towards the language with inlining techniques (unless you actually duplicate the code in the languages which don't have inlining). And skipping all the even or all the 3,5 multiples will make you test less numbers, but won't make you spend less time testing. Most of the time is not spend on the numbers which are rejected quickly. Most time is spent on the numbers with least divisors (like primes themselves).

      --
      Any guest worker system is indistinguishable from indentured servitude.
  50. Re:For my next trick by shutdown+-p+now · · Score: 3, Interesting

    Oh, and before you mention weak references (to be totally honest, I am not even sure if there is a standard weak reference in C++)

    std::weak_ptr in C++11. Been there for 7 years now (originally as std::tr1::weak_ptr), and for a few years before that in Boost.

    I'll mention that very few C++ programmers know what they are.

    That's the problem with those programmers, not the language. C++ is powerful and fast by design; that, unfortunately, also makes it complex by design. It's not a language for everyone, and Java and C# certainly have their very large niche. But C++ is a very powerful tool when used right.

    The syntax of C++ is so crowded that the language is only used for low level stuff where the extra 5% performance boost is a big deal.

    That's emphatically not true. I've repeated it several times already in this thread, and I'll repeat it again: most desktop software today is written in C++. Heck, even a fair bit of OS X software is written mostly in C++, especially if you look at the size of it (MS Office, Photoshop). The reason for that is that perf boost (relative to Java/C#) is more like 20% for common tasks; but, more importantly, there is a marked responsiveness improvement due to lack of GC. And responsiveness is some really subtle stuff - it's not quite the same as "fast", but it's very sensitive to stutter on the order of tens of ms (a delay over 100ms is already noticeable by the user).

    You can write good UI software in managed languages, but then you need libraries that are themselves written in native code, at least rendering and input layer. Otherwise you end up with a clumsy pig like Swing.

  51. Hahaha, windows is still bloated by cheekyboy · · Score: 1

    Yeah that has helped, look at Win2008 Server and Exchange 2010.

    What bloody hungry hippos, either too many coders re implementing shit, or fucked If i know.

    But interfaces/guis dont need C++, they would work as well in C#.

    Judging by MS's C++ API, stop using long named objects, and 12 function calls to achieve one objective.

    Hey, windows2000 uses less ram than android on a $60 phone. Why not just use win2000-64bit as a datacenter OS in VMs, running non-MS open sourced linux apps.

    Boot Win2008Svr, and it uses more ram than 4 linux distros running at once in 4 VMs.

    --
    Liberty freedom are no1, not dicks in suits.
    1. Re:Hahaha, windows is still bloated by gbjbaanb · · Score: 1

      amen. Windows 2000 was a good OS. I can't think why the new ones use so much resources to do pretty much the same thing.

      Guis don;t work too well in C# - look at the performance issues many people have with WPF. Now, this can mean that WPF was poorly designed (all that XML... I can believe it) or it can mean it was badly implemented (too much copying 'cheap' memory about?) or it could mean that C# GUI apps can be crap too.

      Given than, I don't think people have many problems with C++/Qt apps though.

      Or imagine just how bad it would be if Windows really was re-implemented in C#.

  52. Yeah but C++ is the Baron Harkonnen of Languages by presidenteloco · · Score: 0

    http://www.youtube.com/watch?v=r5whVyDoLLc&feature=related

    Java is now somewhat bloated, but has not reached C++'s level of fat rolls and pustulence.

    --

    Where are we going and why are we in a handbasket?
  53. Re:For my next trick by superwiz · · Score: 2

    I'll mention that very few C++ programmers know what they are.

    That's the problem with those programmers, not the language. C++ is powerful and fast by design;

    Not really. Most Java programmers know about the weak references in Java. And in Java they are less necessary than they are in C++ (because the C++ gc model steaming from smart pointers is based on reference counts). If a necessary tool goes underused in a certain context, then it is the problem with how the context is presented to its audience -- not with the audience.

    But C++ is a very powerful tool when used right.

    Any tool is only as powerful as it is useful. It is not reasonable to judge tools only by the peak performance achieved by its most committed users.

    The reason for that is that perf boost (relative to Java/C#) is more like 20% for common tasks;

    And I posted a fairly simple benchmark which shows otherwise.

    there is a marked responsiveness improvement due to lack of GC.

    Only for a certain class of problems. Btw, I would say that mark-and-sweep is a type of gc -- not that it is gc. Reference count is also a gc method. But that's a semantic argument. And I am more than willing to admit that it is a matter of opinion.

    You can write good UI software in managed languages

    All application languages are managed.... by the operating system.

    Otherwise you end up with a clumsy pig like Swing.

    Swing is only clumsy because it attempts cross-platform functionality (which necessitates that it supports only the least common denominator of features). It's not clumsy for any kind of inherent performance design issues in the Java language.

    --
    Any guest worker system is indistinguishable from indentured servitude.
  54. The Leviathan... by Anonymous Coward · · Score: 0

    This is just Lisp with an overcomplicated syntax.

    1. Re:The Leviathan... by Chrisq · · Score: 1

      This is just Lisp with an overcomplicated syntax.

      This must be one of the least insightful comments I have ever read.

  55. Being all things to all programmers by caywen · · Score: 1

    I think C++ 11 may be falling into the trap of trying to be all things to all programmers. Certainly developments in C# and Java had something to do with some of these improvements. But, at what point can one say that a system has become too complicated to quickly reason with? Has C++ reached that point?

    That said, certainly these changes are welcome improvements for existing C++ developers who want easier ways to reduce complexity of their code.

    1. Re:Being all things to all programmers by bames53 · · Score: 1

      One thing I found interesting about Herb Sutter's talk at the Going Native conference was his slide comparing language complexity. According to the metric he used (page count of the language specification) C++11 is very close to Java 7 and the current version of C#. (IIRC, marginally smaller than Java, marginally larger than C#).

      And a great thing about C++11 is that many features exist mainly for backwards compatibility, and a new programmer doesn't need to start out learning them at all; there's a clean, modern path through learning C++, and learning the rest can be left to when you actually have to maintain legacy code. Bjarne Stroustrup's intro to programming book teaches C++ this way and it's quite good.

  56. Uh. No. by Anonymous Coward · · Score: 0

    memcpy means undefined behavior if your data type is not a POD.

    Oh, and "many feel" is weasel-wordy to the extreme. Who, exactly, feels this and what are their reasons? Are their reasons sound and well-founded?

    1. Re:Uh. No. by The+Askylist · · Score: 1

      I'm one of those who detests operator overloading, for the simple reason that if you want a new operator behaviour, then you should define a new operator - it makes code easier to read and maintain, and avoids confusion.

      But that's just my experience - you may differ.

    2. Re:Uh. No. by Electricity+Likes+Me · · Score: 3, Informative

      Operator overloading is to address the ambiguity of having by-value and by-reference passing of objects being possible via different semantics in the language.

      If I have a pointer and write:
      ObjType* pObjRef =
      then it's pretty obvious I have an object reference.

      But but what does
      ObjType Obj2 = Obj1;
      actually mean?

      C++ defines this type of transaction as always being a copy operation. But an object is a complex datatype - doing a straight copy of all it's memory doesn't necessarily give me sensible behavior. So you need operator overloading to let you enforce sensible behavior.

      That you can also use it to create syntactic sugar or completely illogical behavior doesn't make it bad though. And absent a garbage collector, I'm not sure it actually makes sense to do what C# does and try and treat all object variables as references (in that when would you deallocate things?)

    3. Re:Uh. No. by Electricity+Likes+Me · · Score: 1

      Huh, ok, did not know I couldn't use the ampersand in a post.

    4. Re:Uh. No. by Anonymous Coward · · Score: 1

      Operator overloading abuse is bad, but being able to write, for example, z*z + c instead of cplx_add(cplx_mul(z,z), c) or set - set2 instead of set.difference(set2) adds a lot to readability.

      I, for one, dislike language communities driven by "Somebody can cut his finger, so let's remove all cutlery from the house" principle.

    5. Re:Uh. No. by The+Askylist · · Score: 1

      I may be biased here - I first came across operator overloading a good decade and a half ago, when C++ was used in the first iterations of object-oriented databases.

      It was a proper mess back then, and I fear it still is - if I want the sort of behaviour you wish to enforce, then Scala would be my language of choice - I still view C++ as C with object wrappings, templates and lots of stuff that gets in the way of efficient code.

    6. Re:Uh. No. by The+Askylist · · Score: 1

      Coming from a Lisp background, I, for one, find cplx_add(cplx_mul(z,z),c) deficient in parentheses and overburdened with commas ;-)

    7. Re:Uh. No. by The+Askylist · · Score: 1

      Try &

    8. Re:Uh. No. by Pseudonym · · Score: 1

      But that's just my experience - you may differ.

      My experience is that it's beyond confusing when you need to use a mathematical ring (say), but its implementation uses operators other than * and + to implement the ring operations.

      My further experience is that using your own operators is a great idea, and works extremely well right up until the point where you use a second third-party library which defines its own set of (sometimes clashing) operators. I also happen to know that no language has yet managed a sane syntax for namespace-qualifying an operator, which suggests that it may be impossible.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  57. Best learning resources? by Anonymous Coward · · Score: 0

    Pretty cool stuff. What are the best resources for learning about the most modern implementation of C++?

  58. Re:For my next trick by CSMoran · · Score: 1

    I am not sure if CUDA programming can only be done in C++, but I think that if one absolutely needs CUDA, then he is already doing some low-level stuff.

    CUDA Fortran is where it's at for hard-core number-crunching. See e.g. http://www.pgroup.com/resources/cudafortran.htm

    --
    Every end has half a stick.
  59. Re:Yeah but C++ is the Baron Harkonnen of Language by petermgreen · · Score: 1

    Still i'd rather have a language with features I don't want than a language that is lacking features I do want.

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  60. So, you enjoy writing web browsers in 6800 asm? by reiisi · · Score: 1

    I can write a FORTH in the old Motorola M6800 assembler. Once I have the FORTH, it's not that far to a rudimentary web browser, although the address space limitations will prove a source of frustration.

    Implementing FORTH on the 6809 is a bit more fun. High level constructs, more registers, access to the stack that does not have to tunnel through arcane sequences of pushes/pops/swaps.

    Implementing FORTH on the 68000 is much more interesting, because it has enough registers to access parameters/locals, persistent allocation areas, thread locals and globals, etc. It's not just syntactic sugar when you don't have to waste half of your code fighting the botlenecks.

    Goto is not enough.

    --
    Computer memory is just fancy paper, CPUs just fancy pens with fancy erasers; the 'net is just a fancy backyard fence.