

Have Generics Killed Java? - mellis
http://www.artima.com/forums/flat.jsp?forum=106&thread=299081

======
gills
Er...[if you have the misfortune of being paid to work in Java] they remove a
pile of type-casting cruft and make code more useful to large and/or transient
teams.

The author conveniently glosses over the type-casting from pre-generics Java
and instead compares to Ruby. Duh...of course Ruby is a cleaner read. But
compare learning a new API:

    
    
      // pretty evil
      List<Thing> getTheThings();
    
      // really evil
      List getTheThings();
    

Or iteration:

    
    
      // pretty evil
      for (Thing t: getTheThings()) {...}
    
      // kill me now
      for (Iterator it = getTheThings().iterator(); it.hasNext()) {
        Thing t = (Thing) it.next();
        ...
      }

------
mfukar
They provide more type safety and not syntactic sugar. One cannot have
complete type safety at runtime using type casts; if he thinks he can, he
needs to take a simple programming course again.

If the OP wanted readability, he could use iterators. It's amazingly clear:

    
    
      private void printCollection(Collection c) {
        Iterator<String> i = c.iterator();
        while(i.hasNext()) {
          System.out.println("Item: "+i.next());
        }
      }

------
mhd
There's just no real alternative to generics in Java. It's either that,
casting (terminally insecure) or a more modern type system, which would be a
huuuge change for the language (and in which case, you might as well use
Scala).

If you want to complain about things that make code harder to understand, I
wonder why the author doesn't rant about annotations.

