[Haskell-cafe] Re: What I wish someone had told me...

Richard O'Keefe ok at cs.otago.ac.nz
Fri Oct 17 00:38:51 EDT 2008

On 17 Oct 2008, at 9:53 am, Daryoush Mehrtash wrote:

> So does this mean that the reason for complexity of generics is the  
> Java inheritance?

No.  The reason for the complexity of generics in Java is that
they weren't designed into the language in the first place.
It took several attempts and quite a lot of work to come up with
a version of generics that was 100% interoperable with earlier
JVMs *and* still worth having.

The central fact about Java generics is "erasure semantics";
every Java generic class is equivalent to (and is compiled
as if it were) a Java class without any generics at all.
One has the odd result that there is elaborate type checking
for Java collection classes all of which can be bypassed by
linking it with code compiled in Java 1.4 mode, so that all
the run-time type checking *still* has to be done.

You could have something very like Java generics but without
the strangeness if you designed it into the language from the
beginning, as Betrand Meyer did with Eiffel.  Of course, what
_he_ didn't design in from the beginning was lambdas, now
present as "agents".  Eiffel has its own kinds of strangeness.

More information about the Haskell-Cafe mailing list