Syntax poll, take 2

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Jun 13 09:58:20 PDT 2011


Hi
I just wanted to add a data-point that you could find interesting; from 
our measurements on existing code, around 90% of anonymous instance 
creation expression that can be 'lambdified' has a body with less than 5 
lines. It might be interesting to come up with some numbers for the 'one 
liners' bodies.

Maurizio

On 13/06/11 17:30, Reinier Zwitserloot wrote:
> I'm concerned that this poll relies a little too much on your average
> lambda-devver experimenting.
>
> The instructions include examples, but these examples are rather unlikely to
> be representative of what Joe Java is _ever_ going to write. Anyone filling
> in this poll based primarily on looking at them is going to make an
> uninformed decision.
>
> All examples in the instructions share 2 properties:
>
> (A) They are a single expression.
>
> (B) They are written as a physical single line. (one-liner).
>
> While some closures will certainly be a single expression, I'd expect many
> (probably over three quarters*) to be multi-statement, and some to be single
> statement, which is for some proposals actually relevant. Piling multiple
> statements all on one line is obviously not going to happen in actual live
> code use, and the instructions do not offer any suggestion as to what that
> would look like (in fact, in many cases the syntax isn't even clear!)
>
> More to the point, writing these things in a single line does not seem like
> something Joe Java will ever do. The majority of the community will refuse
> to write something like:
>
> if (x == null) return null;
>
> instead adding braces and some newlines. Given that the community evidently
> finds that too complicated to one-line, I fail to see how any of the closure
> examples are palatable to Joe Java. Why do we think closures will all of a
> sudden cure Joe from his obsession with line breaks?
>
> The only one of the 4 proposals that is obviously line-breakable is strawman
> (newline after the brace, just like everywhere else in java). For all other
> proposals I'd like to see a style guide which is suitable for Joe Java (i.e.
> does not attempt to pile too much into a single line), and which is
> virtually enforced (i.e. consistently applied everywhere, with a link to a
> style guide distributed at the same time as the official proposal) as lambda
> is promoted to blogs and eventually java 8, so that most of the community
> ends up using a single style to write them. Nothing is more annoying than a
> language where the community breaks into a near even split across various
> completely different styles. See tabs v. spaces debate. I doubt anyone would
> argue that's good for the language.
>
>
> *) Very *very* few closures used in my own code as well as open source
> projects I looked at ever use closures with a tiny one-expression body.
> However, if lambdas had been in java, code that currently doesn't use
> closures might have used closures, i.e. the balance between one-expression
> closures and (much) larger ones is different when closures are easier to
> use. Nevertheless, it seems obvious that multi-statement closures will not
> all of a sudden become the rare case when lambda is out.
>
>   --Reinier Zwitserloot
>
>
>
> On Sat, Jun 11, 2011 at 9:44 PM, Brian Goetz<brian.goetz at oracle.com>  wrote:
>
>>> I'm curious - why the 100 responses limit? Is that how few people are
>>> subscribed to lambda-dev? (I can't check myself right now, sorry)
>> Partially laziness -- the easiest way to do the survey was the free
>> SurveyMonkey account, which is limited to 100.  There are ~300
>> subscribers on lambda-dev, but only ~100 that have posted.  So the
>> laziness-induced limit seemed adequate to the task.  And if 100 is not
>> enough, 200 (two polls) will surely be.
>>
>> The polluted poll has been set aside and you have a chance to express
>> yourself in the new one.
>>
>>



More information about the lambda-dev mailing list