You are not logged in.

#1 2007-11-29 11:10:16

Bison
Member
From: Jacksonville, FL
Registered: 2006-04-12
Posts: 158
Website

Java Generics vs. C++ Templates and Haskell/ML Parametric Polymorphism

I'm not terribly familiar with Java Generics (We use 1.4 at work, and I find myself unmotivated to use java on a regular basis at home).

I've heard a lot of people say that java generics are pretty weak compared to the alternative generic programming styles in other languages.  I know in haskell you can do stuff like this

data MyDataType a b
     = ...

So that is one (small) example.  What are some other ways that Java Generics falls short of its alternatives?  I would also be interested to see if Java Generics has things other generic styles doesn't.

Offline

#2 2007-11-29 16:58:19

lloeki
Member
From: France
Registered: 2007-02-20
Posts: 456
Website

Re: Java Generics vs. C++ Templates and Haskell/ML Parametric Polymorphism

the main drawback of java generics is that they are not true generics per se, but more of a notation or syntax that will generate stuff automatically behind the scene. the main limitation is that most tests are done at compile time instead of run time because of type erasure.
I used generics on a java project some (~1yr) time ago and it greatly simplified some code I had.

that said generics are only for java 1.5 (or 5.0 depending on the versioning you use) so 1.4 is out of question.

see http://en.wikipedia.org/wiki/Generic_pr … cs_in_Java for some details.

that said, some blog posts are interesting:
http://www.oluyede.org/blog/2004/06/28/ … is-cooler/
http://mindview.net/WebLog/log-0050 (and its followup article)

Last edited by lloeki (2007-11-29 17:13:33)


To know recursion, you must first know recursion.

Offline

Board footer

Powered by FluxBB