<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: What Java generics needs</title>
	<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/</link>
	<description>A weblog for Keith Lea and the Joust Project.</description>
	<pubDate>Wed, 10 Mar 2010 21:59:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Anonymous</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-1562</link>
		<pubDate>Sun, 09 Oct 2005 19:16:16 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-1562</guid>
					<description>generics suck. 

Trying to write a simple sorting class, takes an array of comparables, sorts them into a temp array. 
Comparable[] temp = new Comparable[10]; this gives
The expression of type Comparable[] needs unchecked conversion to conform to type Comparable[] Warnings.

change it to this
Comparable[] temp = new  Comparable[10]; and you get the error:
Cannot create a generic array of Comparable.

WTF???

In Java 1.4 all this was just Comparable[] temp = new Comparable[10]; done, end of story. How hard does this have to be? And why?? Because some ass might put a String into a linked list of Longs or something. Please.</description>
		<content:encoded><![CDATA[<p>generics suck. </p>
<p>Trying to write a simple sorting class, takes an array of comparables, sorts them into a temp array.<br />
Comparable[] temp = new Comparable[10]; this gives<br />
The expression of type Comparable[] needs unchecked conversion to conform to type Comparable[] Warnings.</p>
<p>change it to this<br />
Comparable[] temp = new  Comparable[10]; and you get the error:<br />
Cannot create a generic array of Comparable.</p>
<p>WTF???</p>
<p>In Java 1.4 all this was just Comparable[] temp = new Comparable[10]; done, end of story. How hard does this have to be? And why?? Because some ass might put a String into a linked list of Longs or something. Please.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Keith Lea</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-136</link>
		<pubDate>Wed, 08 Dec 2004 18:37:41 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-136</guid>
					<description>The last three comments (#6-8) were posted from the same IP address and e-mail address.</description>
		<content:encoded><![CDATA[<p>The last three comments (#6-8) were posted from the same IP address and e-mail address.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Anonymous</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-135</link>
		<pubDate>Wed, 08 Dec 2004 17:37:20 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-135</guid>
					<description>Agreed, Java generics seem to invigorate those who &quot;create complexity for complexity sake&quot;

Nuff said. Can we go home now?</description>
		<content:encoded><![CDATA[<p>Agreed, Java generics seem to invigorate those who &#8220;create complexity for complexity sake&#8221;</p>
<p>Nuff said. Can we go home now?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Anonymous</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-134</link>
		<pubDate>Wed, 08 Dec 2004 17:31:30 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-134</guid>
					<description>Agreeing with the previous poster... JUST SAY NO!</description>
		<content:encoded><![CDATA[<p>Agreeing with the previous poster&#8230; JUST SAY NO!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Anonymous</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-133</link>
		<pubDate>Wed, 08 Dec 2004 17:21:41 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-133</guid>
					<description>First off, I don't like generics because they're part of the reason I preferred Java over C++ back in 1995. They had to mess up a good thing...

Just because they don't want developers to write a simple dynamic cast! Give me a break! There are way more important things to worry about... Like:

- Getting in the right features into the product
- Having a proper design because you involved the right stakeholders
- Choosing to implement the right patterns
- Isolating your implementation from your interfaces
- Proper use of polymorphism
- Not having getters and setters for everything (so everything needs to change because a data-type changed).
- etc.

I wouldn't touch generics with a 10-foot pole!

But that's just me...</description>
		<content:encoded><![CDATA[<p>First off, I don&#8217;t like generics because they&#8217;re part of the reason I preferred Java over C++ back in 1995. They had to mess up a good thing&#8230;</p>
<p>Just because they don&#8217;t want developers to write a simple dynamic cast! Give me a break! There are way more important things to worry about&#8230; Like:</p>
<p>- Getting in the right features into the product<br />
- Having a proper design because you involved the right stakeholders<br />
- Choosing to implement the right patterns<br />
- Isolating your implementation from your interfaces<br />
- Proper use of polymorphism<br />
- Not having getters and setters for everything (so everything needs to change because a data-type changed).<br />
- etc.</p>
<p>I wouldn&#8217;t touch generics with a 10-foot pole!</p>
<p>But that&#8217;s just me&#8230;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Peter Ahe</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-128</link>
		<pubDate>Sun, 05 Dec 2004 20:33:04 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-128</guid>
					<description>If the generics FAQ for Eiffel is as short as claimed, then it is missing an important
aspect: generic types in Eiffel are covariant.  This was later discovered to lead to
type unsoundness.  AFAIK, this was later resolved by some special rules that ought to
be described in a FAQ on the language.  So apparently, the Eiffel FAQ is hiding some
complexity.

However, there are some special rules in Java generics that we would rather have been
without.  These rules are mostly there because due erasue and/or compatibility reasons,
see &lt;a href=&quot;http://gafter.blogspot.com/2004/09/puzzling-through-erasure-answer.html&quot;&gt;Neal
Gafter's Blog&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>If the generics FAQ for Eiffel is as short as claimed, then it is missing an important<br />
aspect: generic types in Eiffel are covariant.  This was later discovered to lead to<br />
type unsoundness.  AFAIK, this was later resolved by some special rules that ought to<br />
be described in a FAQ on the language.  So apparently, the Eiffel FAQ is hiding some<br />
complexity.</p>
<p>However, there are some special rules in Java generics that we would rather have been<br />
without.  These rules are mostly there because due erasue and/or compatibility reasons,<br />
see <a href="http://gafter.blogspot.com/2004/09/puzzling-through-erasure-answer.html">Neal<br />
Gafter&#8217;s Blog</a>.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Keith Lea</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-121</link>
		<pubDate>Fri, 03 Dec 2004 17:19:26 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-121</guid>
					<description>There's no need to use arrays in Java, except for primitive types. You can use a List of parameterized types in Java just like arrays in Eiffel.

When I said Java's generics are probably more powerful, I was talking about things like variance, type bounds, and type inference. Being able to create new instances of types specified by generic type arguments is a feature that may be cool in Eiffel, but wouldn't make sense in Java, because you never know what parameters a class's constructor takes. C# generics has something called a &quot;constuctor restriction&quot; which takes care of this, but I think that's the wrong solution to the problem. The solution in Java is probably to pass a generic Factory&amp;#60;T&amp;#62; to classes which need to instantiate T.

I do consider it a limitation of Java's generic types system that you can't use primitive types as type arguments. However, there's no functionality lost due to this, only performance, because you can still use the wrapper classes Integer, Byte, and so on.</description>
		<content:encoded><![CDATA[<p>There&#8217;s no need to use arrays in Java, except for primitive types. You can use a List of parameterized types in Java just like arrays in Eiffel.</p>
<p>When I said Java&#8217;s generics are probably more powerful, I was talking about things like variance, type bounds, and type inference. Being able to create new instances of types specified by generic type arguments is a feature that may be cool in Eiffel, but wouldn&#8217;t make sense in Java, because you never know what parameters a class&#8217;s constructor takes. C# generics has something called a &#8220;constuctor restriction&#8221; which takes care of this, but I think that&#8217;s the wrong solution to the problem. The solution in Java is probably to pass a generic Factory&lt;T&gt; to classes which need to instantiate T.</p>
<p>I do consider it a limitation of Java&#8217;s generic types system that you can&#8217;t use primitive types as type arguments. However, there&#8217;s no functionality lost due to this, only performance, because you can still use the wrapper classes Integer, Byte, and so on.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Anonymous</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-118</link>
		<pubDate>Fri, 03 Dec 2004 10:42:34 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-118</guid>
					<description>Actually Eiffel generics are more much powerful than Java generics.  For example, you can have an array of parameterised types -- did you know you can't do that in Java?  You can create new instances and arrays of types that are parameters of generic types -- again, you can't do that in Java.  Type parameters can be &quot;primitive&quot; types -- in fact there is no concept of primitive type in Eiffel; all types fit into the class hierarchy.</description>
		<content:encoded><![CDATA[<p>Actually Eiffel generics are more much powerful than Java generics.  For example, you can have an array of parameterised types &#8212; did you know you can&#8217;t do that in Java?  You can create new instances and arrays of types that are parameters of generic types &#8212; again, you can&#8217;t do that in Java.  Type parameters can be &#8220;primitive&#8221; types &#8212; in fact there is no concept of primitive type in Eiffel; all types fit into the class hierarchy.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Keith Lea</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-115</link>
		<pubDate>Thu, 02 Dec 2004 18:07:44 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-115</guid>
					<description>I haven't used Eiffel's generics, but the complexity in Java's implementation lets you do more advanced things with the type system that you probably can't do in Eiffel.

I think the only cases where you can't use generic types in Java are with primitives, and in instanceof expressions.</description>
		<content:encoded><![CDATA[<p>I haven&#8217;t used Eiffel&#8217;s generics, but the complexity in Java&#8217;s implementation lets you do more advanced things with the type system that you probably can&#8217;t do in Eiffel.</p>
<p>I think the only cases where you can&#8217;t use generic types in Java are with primitives, and in instanceof expressions.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Anonymous</title>
		<link>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-114</link>
		<pubDate>Thu, 02 Dec 2004 10:10:10 +0000</pubDate>
		<guid>http://joust.kano.net/weblog/archive/2004/12/01/what-java-generics-needs/#comment-114</guid>
					<description>It amazes me how the Java team have managed to make generics so complex -- there are so many special cases about where you can and cannot use generic types and parameter types.  The FAQ on generics is several pages long.  In comparison, look at generics in the Eiffel language.  It can be summed up as: &quot;any type can be parameterised by one or more types&quot;.  End of story.  No special rules for generic types, no special cases where you can't use generic types or parameter types.  It just works.</description>
		<content:encoded><![CDATA[<p>It amazes me how the Java team have managed to make generics so complex &#8212; there are so many special cases about where you can and cannot use generic types and parameter types.  The FAQ on generics is several pages long.  In comparison, look at generics in the Eiffel language.  It can be summed up as: &#8220;any type can be parameterised by one or more types&#8221;.  End of story.  No special rules for generic types, no special cases where you can&#8217;t use generic types or parameter types.  It just works.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
