<?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: Native collections are Groovy, man</title>
	<atom:link href="http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/feed/" rel="self" type="application/rss+xml" />
	<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/</link>
	<description>Can you dig it man?</description>
	<pubDate>Sat, 22 Nov 2008 06:44:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
		<item>
		<title>By: Redsolo</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-14978</link>
		<dc:creator>Redsolo</dc:creator>
		<pubDate>Mon, 18 Jun 2007 08:18:32 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-14978</guid>
		<description>What I love with python is the support for "-1". There are so many times I have to do collection.getLength() or collection.getSize() only to get the index of the last item.

With python you can only do:
lastItem = collection[-1]

It is also so easy to get a subset of a collection:
subset = collection[1:-1]

This is what they should bring into the next release of java!</description>
		<content:encoded><![CDATA[<p>What I love with python is the support for &#8220;-1&#8243;. There are so many times I have to do collection.getLength() or collection.getSize() only to get the index of the last item.</p>
<p>With python you can only do:<br />
lastItem = collection[-1]</p>
<p>It is also so easy to get a subset of a collection:<br />
subset = collection[1:-1]</p>
<p>This is what they should bring into the next release of java!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glen Pepicelli</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-14174</link>
		<dc:creator>Glen Pepicelli</dc:creator>
		<pubDate>Fri, 15 Jun 2007 21:13:36 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-14174</guid>
		<description>If you look at some idiomatic Perl scripts you will see collections used almost every line.  So it definately opens up a new style of programming.  

What I really like about Groovy is that your can swap out the default implementations of the list and maps with any class that extends those interfaces-- really cool.

Glen</description>
		<content:encoded><![CDATA[<p>If you look at some idiomatic Perl scripts you will see collections used almost every line.  So it definately opens up a new style of programming.  </p>
<p>What I really like about Groovy is that your can swap out the default implementations of the list and maps with any class that extends those interfaces&#8211; really cool.</p>
<p>Glen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13745</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Thu, 14 Jun 2007 14:23:35 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13745</guid>
		<description>Pablo- I couldn't agree more with you! I had an interesting experience using the Cargo framework in Groovy first and then having to port some of it to a Java based implementation for a particular client and I found myself amazed on how easy it was to get things working in Groovy (as opposed to Java) due to its relaxed nature.</description>
		<content:encoded><![CDATA[<p>Pablo- I couldn&#8217;t agree more with you! I had an interesting experience using the Cargo framework in Groovy first and then having to port some of it to a Java based implementation for a particular client and I found myself amazed on how easy it was to get things working in Groovy (as opposed to Java) due to its relaxed nature.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pablo</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13603</link>
		<dc:creator>Pablo</dc:creator>
		<pubDate>Thu, 14 Jun 2007 02:09:39 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13603</guid>
		<description>I think that the power of Groovy does not lie so much on it's sintactic sugar, but on the power it has no wrap up some complex Java APIs. The first thing that comes into my mind is JMX:

Java:
println server.getAttribute(beanName, 'Age')
server.setAttribute(beanName, new Attribute('Name', 'New name'))
Object[] params = [5, 20]
String[] signature = [Integer.TYPE, Integer.TYPE]
println server.invoke(beanName, 'add', params, signature)

Groovy:
def mbean = new GroovyMBean(server, beanName)
println mbean.Age
mbean.Name = 'New name'
println mbean.add(5, 20)

That kind of things are the ones that are useful for me.

JM2C.</description>
		<content:encoded><![CDATA[<p>I think that the power of Groovy does not lie so much on it&#8217;s sintactic sugar, but on the power it has no wrap up some complex Java APIs. The first thing that comes into my mind is JMX:</p>
<p>Java:<br />
println server.getAttribute(beanName, &#8216;Age&#8217;)<br />
server.setAttribute(beanName, new Attribute(&#8217;Name&#8217;, &#8216;New name&#8217;))<br />
Object[] params = [5, 20]<br />
String[] signature = [Integer.TYPE, Integer.TYPE]<br />
println server.invoke(beanName, &#8216;add&#8217;, params, signature)</p>
<p>Groovy:<br />
def mbean = new GroovyMBean(server, beanName)<br />
println mbean.Age<br />
mbean.Name = &#8216;New name&#8217;<br />
println mbean.add(5, 20)</p>
<p>That kind of things are the ones that are useful for me.</p>
<p>JM2C.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13587</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 13 Jun 2007 19:22:36 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13587</guid>
		<description>Stephan-

You raise a great point-- I really wrote that code to demonstrate iteration, not so much as an example of creating collections. I agree-- I rarely do this in practice too!</description>
		<content:encoded><![CDATA[<p>Stephan-</p>
<p>You raise a great point&#8211; I really wrote that code to demonstrate iteration, not so much as an example of creating collections. I agree&#8211; I rarely do this in practice too!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13586</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 13 Jun 2007 19:04:10 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13586</guid>
		<description>As a side note, this posting was bound to get some great thoughts and other view points as I learned long ago when starting to write Groovy &#038; Java comparisons-- for some excellent points check out these threads:
&lt;a href="http://www.theserverside.com/news/thread.tss?thread_id=32224#159515" rel="nofollow"&gt;Groovy making good progress&lt;/a&gt; and &lt;a href="http://www.theserverside.com/news/thread.tss?thread_id=31192" rel="nofollow"&gt;Practically Groovy: Get Groovy with JDBC programming&lt;/a&gt; both of which appeared on TheServerSide in 2005. 

One of my favorite comments related to some Java I wrote and compared to Groovy: "If that is your 'normal' Java, no wonder you like Groovy. But I can say in all honesty, if someone came up to me using this as a selling point of Groovy, I'll laugh them out the door." And he's got a valid point too. Groovy has a number of selling points, but something to keep in mind-- Groovy also obeys the 80/20 rule-- it is more concise and easier to write for roughly 80% of the code you normally write in Java or it is easier and more concise for roughly 80% of the people who write Java...</description>
		<content:encoded><![CDATA[<p>As a side note, this posting was bound to get some great thoughts and other view points as I learned long ago when starting to write Groovy &#038; Java comparisons&#8211; for some excellent points check out these threads:<br />
<a href="http://www.theserverside.com/news/thread.tss?thread_id=32224#159515" rel="nofollow">Groovy making good progress</a> and <a href="http://www.theserverside.com/news/thread.tss?thread_id=31192" rel="nofollow">Practically Groovy: Get Groovy with JDBC programming</a> both of which appeared on TheServerSide in 2005. </p>
<p>One of my favorite comments related to some Java I wrote and compared to Groovy: &#8220;If that is your &#8216;normal&#8217; Java, no wonder you like Groovy. But I can say in all honesty, if someone came up to me using this as a selling point of Groovy, I&#8217;ll laugh them out the door.&#8221; And he&#8217;s got a valid point too. Groovy has a number of selling points, but something to keep in mind&#8211; Groovy also obeys the 80/20 rule&#8211; it is more concise and easier to write for roughly 80% of the code you normally write in Java or it is easier and more concise for roughly 80% of the people who write Java&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13585</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 13 Jun 2007 18:51:08 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13585</guid>
		<description>L-Dog- right on! That's much easier than repetitively calling &lt;code&gt;add&lt;/code&gt;. Thanks for pointing that out!</description>
		<content:encoded><![CDATA[<p>L-Dog- right on! That&#8217;s much easier than repetitively calling <code>add</code>. Thanks for pointing that out!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13584</link>
		<dc:creator>Andy</dc:creator>
		<pubDate>Wed, 13 Jun 2007 18:50:13 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13584</guid>
		<description>Yep, you are 100% on, man. The new &lt;code&gt;for&lt;/code&gt; loop in Java does make iteration much, much easier. Thanks for calling me on that. :)</description>
		<content:encoded><![CDATA[<p>Yep, you are 100% on, man. The new <code>for</code> loop in Java does make iteration much, much easier. Thanks for calling me on that. <img src='http://thediscoblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: afsina</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13580</link>
		<dc:creator>afsina</dc:creator>
		<pubDate>Wed, 13 Jun 2007 17:16:04 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13580</guid>
		<description>for(Iterator iter = coll.iterator(); iter.hasNext();){
  String value = (String)iter.next();
  System.out.println(value);
}

can also be written as 

for(String s : coll )
  System.out.println(s);

Although i agree that Java should have some more helpers for Collections (not necessarily 'in' the language syntax), you don't have to show Java code unnecessarily verbose.</description>
		<content:encoded><![CDATA[<p>for(Iterator iter = coll.iterator(); iter.hasNext();){<br />
  String value = (String)iter.next();<br />
  System.out.println(value);<br />
}</p>
<p>can also be written as </p>
<p>for(String s : coll )<br />
  System.out.println(s);</p>
<p>Although i agree that Java should have some more helpers for Collections (not necessarily &#8216;in&#8217; the language syntax), you don&#8217;t have to show Java code unnecessarily verbose.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan Schmidt</title>
		<link>http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13551</link>
		<dc:creator>Stephan Schmidt</dc:creator>
		<pubDate>Wed, 13 Jun 2007 07:16:13 +0000</pubDate>
		<guid isPermaLink="false">http://thediscoblog.com/2007/06/13/native-collections-are-groovy-man/#comment-13551</guid>
		<description>What astonishes me is the fixation of many people on collection sugar. When looking back at my long Java development history, I can't remember an instance where I needed to create a collection of Strings. Either the data comes from the database, from a config file or the data comes from the user. But usually never from the application. Most of the time the developer only inititializes an empty list, like in List customers = []; which is only marginally shorter than List customers = new ArrayList(); 

@Andy: Do you have real examples of initializing lists with data in an application?

As a sidenote: for (String value: collection) { sout( value ) } is probably shorter than your iterator example :-)

(I like Groovy a lot :-) The Groovy syntax though is helpful for unit testing, see below. A clever IDE (like IDEA) perhaps could just show you [] instead of ArrayList and only show ArrayList as a tooltip. And it could also hide the generic information for more readability.

@L-Dog: Excellent. This is the exception to the rule, I've been using your construct quite often for JUnit tests, where this is handy to create test data.</description>
		<content:encoded><![CDATA[<p>What astonishes me is the fixation of many people on collection sugar. When looking back at my long Java development history, I can&#8217;t remember an instance where I needed to create a collection of Strings. Either the data comes from the database, from a config file or the data comes from the user. But usually never from the application. Most of the time the developer only inititializes an empty list, like in List customers = []; which is only marginally shorter than List customers = new ArrayList(); </p>
<p>@Andy: Do you have real examples of initializing lists with data in an application?</p>
<p>As a sidenote: for (String value: collection) { sout( value ) } is probably shorter than your iterator example <img src='http://thediscoblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>(I like Groovy a lot <img src='http://thediscoblog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> The Groovy syntax though is helpful for unit testing, see below. A clever IDE (like IDEA) perhaps could just show you [] instead of ArrayList and only show ArrayList as a tooltip. And it could also hide the generic information for more readability.</p>
<p>@L-Dog: Excellent. This is the exception to the rule, I&#8217;ve been using your construct quite often for JUnit tests, where this is handy to create test data.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
