<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: CICE: Not So Nice</title>
	<atom:link href="http://cafe.elharo.com/blogroll/cice-not-so-nice/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/</link>
	<description>Longer than a blog; shorter than a book</description>
	<pubDate>Fri, 21 Nov 2008 20:27:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Mick Jagger</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-169580</link>
		<dc:creator>Mick Jagger</dc:creator>
		<pubDate>Thu, 20 Dec 2007 12:38:04 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-169580</guid>
		<description>I think you are missing the point.

The whole idea about having closures is just having a way to pass a Java block as a variable. We already do that using Runnable, but the whole point of Runnable is that it is an anonymous inner class and half the code you type is just boilerplate.

Can we remove the bolierplate?

If the answer is yes, then we don't need to introduce new mechanisms into Java. That should be one of the deciding criteria.

The example should be about moving the block into a variable. Also you are not instantiating a class, but a block (which is finally a method, and it doesn't matter if internally Java uses the anonymous inner class mechanism):

int compare( String, String ) = Comparator.compare( String s1, String s2 ) { return s1.length() - s2.length(); };
Collections.sort( ls compare );

It has better syntax, doesn't it?</description>
		<content:encoded><![CDATA[<p>I think you are missing the point.</p>
<p>The whole idea about having closures is just having a way to pass a Java block as a variable. We already do that using Runnable, but the whole point of Runnable is that it is an anonymous inner class and half the code you type is just boilerplate.</p>
<p>Can we remove the bolierplate?</p>
<p>If the answer is yes, then we don&#8217;t need to introduce new mechanisms into Java. That should be one of the deciding criteria.</p>
<p>The example should be about moving the block into a variable. Also you are not instantiating a class, but a block (which is finally a method, and it doesn&#8217;t matter if internally Java uses the anonymous inner class mechanism):</p>
<p>int compare( String, String ) = Comparator.compare( String s1, String s2 ) { return s1.length() - s2.length(); };<br />
Collections.sort( ls compare );</p>
<p>It has better syntax, doesn&#8217;t it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unilever Centre for Molecular Informatics, Cambridge - Jim Downing &#187; Blog Archive &#187; C#: Fat or Fit?</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-109778</link>
		<dc:creator>Unilever Centre for Molecular Informatics, Cambridge - Jim Downing &#187; Blog Archive &#187; C#: Fat or Fit?</dc:creator>
		<pubDate>Thu, 12 Jul 2007 12:02:42 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-109778</guid>
		<description>[...] Harold has been vocal against adding complexity to the Java language. The complexity loving geek in my stamps his foot [...]</description>
		<content:encoded><![CDATA[<p>[...] Harold has been vocal against adding complexity to the Java language. The complexity loving geek in my stamps his foot [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bharath R</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-54778</link>
		<dc:creator>Bharath R</dc:creator>
		<pubDate>Thu, 08 Feb 2007 05:19:15 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-54778</guid>
		<description>If you find the CICE unreadable, may the force be with you to help you decipher the BGGA proposal.</description>
		<content:encoded><![CDATA[<p>If you find the CICE unreadable, may the force be with you to help you decipher the BGGA proposal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Powers</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-54319</link>
		<dc:creator>Michael Powers</dc:creator>
		<pubDate>Tue, 06 Feb 2007 19:11:53 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-54319</guid>
		<description>Ugh.  Who let the bazaar into the cathedral?

If the future of open source java is scratching everyone's minor itch to "fix" the language, maybe it's finally time to move on to python or ruby.</description>
		<content:encoded><![CDATA[<p>Ugh.  Who let the bazaar into the cathedral?</p>
<p>If the future of open source java is scratching everyone&#8217;s minor itch to &#8220;fix&#8221; the language, maybe it&#8217;s finally time to move on to python or ruby.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Howard Lovatt</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-53864</link>
		<dc:creator>Howard Lovatt</dc:creator>
		<pubDate>Mon, 05 Feb 2007 01:34:36 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-53864</guid>
		<description>I think the CICE proposal is better than the BGGA proposal because it uses an inner class which is more powerful than a simple closure and also already in Java. I have also suggested another alternative syntax for inner classes, C3S (http://www.artima.com/forums/flat.jsp?forum=106&#38;thread=182412), which I think is more Java like than either. Taking the sort example given in the original post above but indenting:

In CICE:
List ls = â€¦ ;
Collections.sort(
  ls, 
  Comparator( String s1, String s2 ) { return s1.length() - s2.length(); } 
);

In BGGA (I think - you need a closure conversion to make a closure into an instance of an interface - which I think is intended to be implicit):
List ls = â€¦ ;
Collections.sort( 
  ls, 
  { String s1, String s2 =&#62; s1.length() - s2.length(); } 
);

Note the use of =&#62; to separate arguments from body and that you can't use return in this context, the value returned is implicitly the value of the last statement and if you add an explicit return it is an error.

In my C3S proposal:
declare ls = â€¦ ; // Note type inference from right hand side of equals sign
Collections.sort( 
  ls, 
  method( s1, s2 ) { return s1.length - s2.length } 
);

I find this C3S more readable than current Java, CICE, and in particular BGGA. What do others think?</description>
		<content:encoded><![CDATA[<p>I think the CICE proposal is better than the BGGA proposal because it uses an inner class which is more powerful than a simple closure and also already in Java. I have also suggested another alternative syntax for inner classes, C3S (http://www.artima.com/forums/flat.jsp?forum=106&amp;thread=182412), which I think is more Java like than either. Taking the sort example given in the original post above but indenting:</p>
<p>In CICE:<br />
List ls = â€¦ ;<br />
Collections.sort(<br />
  ls,<br />
  Comparator( String s1, String s2 ) { return s1.length() - s2.length(); }<br />
);</p>
<p>In BGGA (I think - you need a closure conversion to make a closure into an instance of an interface - which I think is intended to be implicit):<br />
List ls = â€¦ ;<br />
Collections.sort(<br />
  ls,<br />
  { String s1, String s2 =&gt; s1.length() - s2.length(); }<br />
);</p>
<p>Note the use of =&gt; to separate arguments from body and that you can&#8217;t use return in this context, the value returned is implicitly the value of the last statement and if you add an explicit return it is an error.</p>
<p>In my C3S proposal:<br />
declare ls = â€¦ ; // Note type inference from right hand side of equals sign<br />
Collections.sort(<br />
  ls,<br />
  method( s1, s2 ) { return s1.length - s2.length }<br />
);</p>
<p>I find this C3S more readable than current Java, CICE, and in particular BGGA. What do others think?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Augusto</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-53766</link>
		<dc:creator>Augusto</dc:creator>
		<pubDate>Sun, 04 Feb 2007 14:42:10 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-53766</guid>
		<description>In the Runnable examples, how does it know you want to invoke run()? Does it just infer that because it's the only method and has no args?</description>
		<content:encoded><![CDATA[<p>In the Runnable examples, how does it know you want to invoke run()? Does it just infer that because it&#8217;s the only method and has no args?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Russ</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-53221</link>
		<dc:creator>Russ</dc:creator>
		<pubDate>Fri, 02 Feb 2007 09:36:35 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-53221</guid>
		<description>I totally agree that this proposal adds complexity to the language with no real benefit in return; it's totally the wrong direction. We should be trying to smooth out the rough edges of Java rather than add obscure special cases of syntax. Unfortunately while auto-boxing and generics could have increaced the clarity of Java, their implementation introduced more complexity and gotchas. That's exactly what we should be trying to avoid with any new language feature.</description>
		<content:encoded><![CDATA[<p>I totally agree that this proposal adds complexity to the language with no real benefit in return; it&#8217;s totally the wrong direction. We should be trying to smooth out the rough edges of Java rather than add obscure special cases of syntax. Unfortunately while auto-boxing and generics could have increaced the clarity of Java, their implementation introduced more complexity and gotchas. That&#8217;s exactly what we should be trying to avoid with any new language feature.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-53055</link>
		<dc:creator>mike</dc:creator>
		<pubDate>Thu, 01 Feb 2007 18:03:43 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-53055</guid>
		<description>I don't think CICE is the best solution to the problem that inner classes are trying to solve.  In the case of sorting, closures are extremely intuitive.  I don't know what the proposed syntaxes for closures in Java look like, but here's what sorting a list of strings may look like with closures:

List ls = ...
ls.sort(s1, s2) { return s1.length() - s2.length(); }

This is not only shorter, but it's also much more intuitive.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think CICE is the best solution to the problem that inner classes are trying to solve.  In the case of sorting, closures are extremely intuitive.  I don&#8217;t know what the proposed syntaxes for closures in Java look like, but here&#8217;s what sorting a list of strings may look like with closures:</p>
<p>List ls = &#8230;<br />
ls.sort(s1, s2) { return s1.length() - s2.length(); }</p>
<p>This is not only shorter, but it&#8217;s also much more intuitive.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexey</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-53042</link>
		<dc:creator>Alexey</dc:creator>
		<pubDate>Thu, 01 Feb 2007 17:22:18 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-53042</guid>
		<description>"Which is more legible to you?"

The CICE one, after it's properly indented. Nobody forces you to use the unindented version.

"all those silly rules about final local variables, this inside inner classes, and other arcana I can never quite remember..."

You do understand all those silly rules exist _because inner classes are not closures_, right? If Java had real closures, they would go away.

See http://gafter.blogspot.com/2007/01/definition-of-closures.html.</description>
		<content:encoded><![CDATA[<p>&#8220;Which is more legible to you?&#8221;</p>
<p>The CICE one, after it&#8217;s properly indented. Nobody forces you to use the unindented version.</p>
<p>&#8220;all those silly rules about final local variables, this inside inner classes, and other arcana I can never quite remember&#8230;&#8221;</p>
<p>You do understand all those silly rules exist _because inner classes are not closures_, right? If Java had real closures, they would go away.</p>
<p>See <a href="http://gafter.blogspot.com/2007/01/definition-of-closures.html" onclick="javascript:pageTracker._trackPageview('/outbound/comment/gafter.blogspot.com');" rel="nofollow">http://gafter.blogspot.com/2007/01/definition-of-closures.html</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: robert</title>
		<link>http://cafe.elharo.com/blogroll/cice-not-so-nice/#comment-53032</link>
		<dc:creator>robert</dc:creator>
		<pubDate>Thu, 01 Feb 2007 16:18:10 +0000</pubDate>
		<guid isPermaLink="false">http://cafe.elharo.com/java/cice-not-so-nice/#comment-53032</guid>
		<description>Dissing inner classes.  I don't know; is that enough to get tossed out of The Brotherhood?  Niemeyer doesn't like them either.  Maybe it's an O'Reilly fetish?  But I do agree.  Since they're just compiler foolery, best to avoid them.</description>
		<content:encoded><![CDATA[<p>Dissing inner classes.  I don&#8217;t know; is that enough to get tossed out of The Brotherhood?  Niemeyer doesn&#8217;t like them either.  Maybe it&#8217;s an O&#8217;Reilly fetish?  But I do agree.  Since they&#8217;re just compiler foolery, best to avoid them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
