<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>porges</author><text>&amp;gt; After instructions, participants were given printouts of sample code they could refer to while solving tasks. Group Lambda got code of a C++ program using lambda expressions and group Iterator received code of the same program written using iterators. They then had time to study the samples before starting the tasks and could refer to these samples later.&lt;p&gt;These samples do not appear in the paper, so we don&amp;#x27;t know what they saw.&lt;p&gt;The “iterators” discussed are Java-&amp;#x2F;C#-style iterators, not C++ ones (as I expected reading the abstract).&lt;p&gt;In a C++ context I would have expected lambdas vs iterators to be something like:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    &amp;#x2F;&amp;#x2F; lambda
    float retVal = 0;
    std::for_each(mb.cbegin(), mb.cend(), [&amp;amp;](item x) { retVal += item.price; });
    return retVal;

    &amp;#x2F;&amp;#x2F; pure iterator
    float retVal = 0;
    for (auto it = mb.cbegin(); it != mb.cend(); ++it)
    {
        retVal += it-&amp;gt;price;
    }

    return retVal;
&lt;/code&gt;&lt;/pre&gt;
... and the first would be better off as:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    return std::accumulate(mb.cbegin(), mb.cend(), 0f,
        [](float acc, item x) { return acc + x.price; });

&lt;/code&gt;&lt;/pre&gt;
I think the need to use ref-capture (since you only get a side-effecting `std::function` to play with in their sample) would be the thing most likely to throw people off – as it’s something that should be avoided in most code, anyway ;)</text><parent_chain></parent_chain></comment><story><title>An empirical study on the impact of C++ lambdas and programmer experience</title><url>http://dl.acm.org/authorize?N03390</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>byuu</author><text>Context always matters. I use lambdas sparingly in my applications, except for one &lt;i&gt;major&lt;/i&gt; area: user interfaces.&lt;p&gt;I can&amp;#x27;t begin to stress what a huge timesaver it is being able to bind a button&amp;#x27;s callback to a quick lambda instead of having to bind a callback to an std::function, add the function to the class header, and then put the actual button-click code somewhere else in the project in a separate function ... and then repeat that process for a large UI with hundreds of widgets.&lt;p&gt;It&amp;#x27;s not even the initial extra typing, it&amp;#x27;s having all the code right where it&amp;#x27;s most relevant instead of scattered around everywhere and having to name all of these callback functions.</text><parent_chain></parent_chain></comment><story><title>An empirical study on the impact of C++ lambdas and programmer experience</title><url>http://dl.acm.org/authorize?N03390</url></story>