Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Not the OP, but I'm going to put my vote down for a simple and comparatively less discussed feature: initializer lists. Declarative programming is a huge win, and being able to declare objects just like you do "static data" is a huge readability win.

Other stuff is mostly about fixing bugs in the standard (<cough> rvalue references </cough>), cleaning up the syntax (auto) or providing new syntax for useful but comparatively rare operations (lambdas). That's all good, but initializer lists can change the paradigm of how the code is presented, and that's better.



"useful but comparatively rare operations (lambdas)"

I think it is rare just because people is not used to it, once they discover the flexibility of lambdas functions you would start seeing them more often (even abuse of them)

I am remaking a event system that I did for a turn based card game and the use of lambdas is just so natural that I realized now how painful and weak was the previous code.


Lambda functions are just syntax, they aren't "flexible" in any meaningful way I can see. And I argue that they certainly are rare -- virtually all major languages (other than C and C++03) have some form of straightforward anonymous function with some form of local scope closure (and to be clear: C++11's implementation of that bit is sort of a mess!).

Other than node.js, virtually none of them make regular use of them. When they do, it's mostly just to have a convenient way of passing a callback.

Lambda's are good. But as implemented in C++11 they really don't do anything to change the nature of the code being written. On the other hand, proper use of initializers does, by virtue of not having to write a thousand setXXX() functions, etc...


"Lambda functions are just syntax, they aren't "flexible" in any meaningful way I can see"

I disagree with that statement. To the best of my knowledge, lambdas functions are implemented as functors which are created by the compiler. So to have a comparable code you have to create those functors by hand. Which can be a lot of repetitive and boring work if you are doing something like an event system.

"virtually all major languages (other than C and C++03) have some form of straightforward anonymous function"

What about Java? :)

"virtually none of them make regular use of them. When they do, it's mostly just to have a convenient way of passing a callback."

Coming from Scheme (which yeah we can argue whether is a major language or not) I can see a lot of benefits of using closures, way more than just a convenient way to pass a callback.

"Lambda's are good. But as implemented in C++11 they really don't do anything to change the nature of the code being written."

Even when is not as powerful as the implementation in other languages still is a huge gain rather not having them at all. If you use them accordingly you would found a more concise and clear code in comparison with not using them. At least that was my personal experience.


For me, the lack of lamba functions meant I was less likely to use many of the algorithms from the standard library. In general, you want to provide a functor to such functions, and it doesn't make sense to define a class, overload operator(), and get the member variables and instantiations to line up when you could just write a for loop. With lambdas, the compiler will do that boiler plate for me.

(Yes, I say "will" - I'm not yet working on something that lets me use C++11 features. Sigh.)


This is what a like about C++11, it feels a safer language and lets me do lots of functional style programming.

Sadly I am stuck in JVM/.NET on the day job.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: