The Artima Developer Community
Sponsored Link

Java Buzz Forum
Generics in Java Are Evil?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Generics in Java Are Evil? Posted: May 13, 2004 8:27 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Generics in Java Are Evil?
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

Dean Wette's talk about Collections and Generics in J2SE 1.5 at the St. Louis Java Users Group tonight is livelier than usual.

Here's the gist of the talk:

  • Generics are evil: The deeper I dig into the specification, the scarier it gets.
  • Generics solves a problem that's not there: The kinds of errors that a type safe collection prevents are the trivial programmer errors that's easily detected with unit tests. IDE's can help with the drudgery of casting when working with Collections.
  • JDK 1.5 generics uses erasure: None of the parameter type information is present in bytecode. Therefore instanceof doesn't work with generic types. Many intuitive programming constructs are illegal. The erasure decision was made so that Sun doesn't have to modify the JVM. They ended up modifying the JVM anyway.
  • The new syntax is too complicated: I've been doing Java since 1996 and am pretty good at it. I'm having trouble with the syntax. Just imagine what a new Java programmer will feel.
  • I would rather use C++ templates!

Dean did talk about several things that he likes: autoboxing, and the enhanced for loop. The java.util.concurrent classes were not covered tonight but were favorably mentioned.

Jeff Grigg urged programmers to take a look at C# for generics done right.

How would you like code like this?

public <T extends Comparable & Serializable> T foo(Collection<T> c1,
    Collection<? extends T> c2) {
    // ...
}

Read: Generics in Java Are Evil?

Topic: Zoe: Google your email Previous Topic   Next Topic Topic: Reinventing the wheel, and how if we didn't we would be riding on square ones?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use