Re: Why Generics?





David Blickstein wrote:
> In Java5, the powers that be added generics.
>
> Can someone please explain to me what value they add to Java? I think they
> are one of the biggest (of many big) mistakes in C++. And I always felt
> that they only reason they were in C++ was because it made the huge mistake
> of not having a common root for the entire class hierarchy: Java's Object
> type.
>
> Java didn't need any language features to implement container classes
> because of this. An reference of type Object can hold ANY Object.
>
> The biggest objection I've ever heard to that is it forces you to cast down
> when you extract from the container. Big deal!
>
> That's nothing compared to what I've always had to go thru to make generics
> work in C++.
>
> Am I missing something or did C++ weenies invade the language committee?

It was the C++ weenies, definitely. You're entirely
correct: The C++ saboteurs have contaminated Java with
generics simply and only to make the language unattractive
and cause its ultimate demise. The Java people have been
suckered into kissing the Bjarne Stone.

Oh, yeah, and one other teeny-tiny thing: If you make
a mistake, it gets diagnosed at compile time instead of at
run time. Which would you rather receive: a compiler error
that you alone see, or a ClassCastException with all the
honchos from The Big Customer watching? If you'd prefer
the former, learn to like generics.

--
Eric.Sosman@xxxxxxx

.



Relevant Pages

  • Re: Has Java become too complicated?
    ... all the nice features of C++ without any of the ugly bits. ... The OP also seems to think that generics have reduced the value of Java, where most seem to think they have enhanced it. ... Most people in my observation that are "frustrated" with one or another Java feature don't understand it, are simply trolling, or both. ... There are assuredly aspects of Java that could have been done better, but come on, citing generics and inner classes as declines in the language? ...
    (comp.lang.java.programmer)
  • Re: Why Generics?
    ... >> generics simply and only to make the language unattractive ... Given that Java competes for mindshare with .NET, ... because it was hyped as the early 90's "it" language and too late realized ... very nearly the HIGHEST per-capita taxes ...
    (comp.lang.java.programmer)
  • Re: Java type-casting -- Q3
    ... ...And I also now start to suspect that "generics" is ... look the same in an object-oriented language as in a functional language. ... The way generics works in Java is appropriate to the style of Java as a language, it isn't a "poor man's" anything. ... My point is that generics fulfills the definition and purpose of parametric polymorphism. ...
    (comp.lang.java.programmer)
  • Re: Java Generics: limitations?
    ... cannot go around and do something similar to what I've said, then Java ... generics cannot be called generics, ... have pointed out, the HasXY interface is not necessary, and could be ... public int getX(); ...
    (comp.lang.java.programmer)
  • Re: Getter & Setter
    ... ich zumBbeispiel auch nicht sicher bin was Row Types ... C++ und Ada machen das ebenfalls nicht (wobei Ada nur benannte Generics ... Performanz in Java hauptsächlich in den Methodenaufrufen zu finden ...
    (de.comp.lang.java)