News for hackers. Stuff that matters.
Re:Getting Lazy with C++ by throwaway7548 on Monday April 21, 2014 @11:13PM (#7625567)
Sorry about being an asshole here, but really. The problem with articles like that, is that a novice developer, with some 5-10 years of experience can pick up an article similar to that one and use such techniques without any need. With disastrous consequences. How do I know it? I've seen it happen. Again and again. Hell, it had happened to myself, years back.

An article like that should start with: "unless you really really know what you are doing and are an adult (20+ years of coding) you should probably avoid using techniques like that in the production code."

Re:Getting Lazy with C++ by rapala on Tuesday April 22, 2014 @03:25AM (#7626278)
I'm pretty sure C++ (and any language for that matter) has more than enough quirky features to obfuscate any piece of code. No need to read this article for that. But if 20 years of experience makes lazy streams seem unfit for production, then someone has spent 10 years burying their head so deep in the sand that their feet are barely showing. Java's iterators, Python's generators, you work with them even in C. And is it not obvious that one needs to really know what they are doing if they are working as a professional developer?

The example of the article was simple of course. But solving the problem of printing Pythagorean triples was not the aim of the article. The aim was to show what makes lazy streams tick, to show that they can be implemented in C++ and that an uniform interface can be provided with functor, monoid and monad. Finally, the simple problem was solved with the new tool to show the inversion of control.

PS. std::vector is a stateful functor.

Re:Getting Lazy with C++ by throwaway7548 on Tuesday April 22, 2014 @11:26AM (#7628231)
Don't get me wrong. I like functional approach. I am developing in functional languages as well as in C/C++. I think these techniques actually do have a place in the production level code.

But, the mail point of the post was, that if you write an article like that, it should start from a warning to novices. This point of view is based on the experience of having to deal with fuckups from novice developers, who were trying to use and abuse the language to the full extends of their abilities. Including fuckups of my own.

PS. std::vector is a container.

Re:Getting Lazy with C++ by chetanahuja on Monday April 21, 2014 @11:47PM (#7625686)
Hah... "novice... with some 5-10 years of experience". Actually you're not too off the mark. And in any case, with c++11, pretty much everyone who's not been following the c++0x/c++1x process assiduously, counts as a novice.
Re:Getting Lazy with C++ by enjoy-your-stay on Tuesday April 22, 2014 @08:00AM (#7627110)
I would have to agree with your comment there.

Although having over 7 years experience as a c++ programmer, since I'm not using it so much now I haven't managed to keep up so much with the changes in c++11 and feel a bit noviced overnight.

Still, move constructors are pretty handy so that's one change I use whenever I can.

Re:Getting Lazy with C++ by fauigerzigerk on Tuesday April 22, 2014 @04:02AM (#7626366)
In this case I think 20 years of C++ experience doesn't help much. At least it doesn't help me. This is a challenge for procedural programmers to really think through what functional primitives are all about by implementing them in a procedural language. It's not the usual template metaprogramming brain teaser.
Re:Getting Lazy with C++ by throwaway7548 on Tuesday April 22, 2014 @11:16AM (#7628167)
I very much agree. I should have stated more clearly that "20 years of coding" requirement in my post should include software (and hardware development) in a variety of languages, including functional languages. Or even domain specific languages like SQL, Matlab or VHDL/Verilog.
Re:Getting Lazy with C++ by reality_czech on Monday April 21, 2014 @11:33PM (#7625644)
Hey, that's not fair.

Experts can use them for disastrous consequences as well. This is C++ we're talking about here!

Re:Getting Lazy with C++ by jeremiep on Tuesday April 22, 2014 @05:16PM (#7630508)
Years of experience is also hard to define. It's as precise a metric as lines of code are.

I've seen people saying 10 years of experience when they're closer to have 10 times one year of experience since they continuously do the same thing over and over. I've also seen people with barely a year or two of experience already coding circles around people with 10+ years.