|
 |
Warp wrote:
> Orchid XP v8 <voi### [at] dev null> wrote:
>>> Java supports generics.
>
>> ...OK, I just learned something.
>
> Java generics are a bit ironical because before they existed the
> common consensus among Java people was that C++ templates are an
> abomination (in the same category as, for example, multiple inheritance,
> if not even worse).
>
> Of course this was before all the generic programming craze, and when
> it hit, the Java people had to swallow their pride and introduce some
> crippled template mechanism into Java. Naturally since templates were
> always considered an abomination they couldn't call them that, so they
> tried to save even a bit of their pride by renaming them to "generics".
> (I suppose "generics" rides more on the whole "generic programming"
> thing.)
>
> Of course Java generics are a bit crippled because they don't support
> basic types (such as int). Thus they solve only part of the problem which
> Java had before.
Well, actually Eiffel calls it generics too. I don't know when Eiffel
was designed, but it's had generics from day 1, and that has always been
its name.
I don't actually know how C++ templates work, but my take on it is this:
- Generics is the ability of a programming language to implement classes
that are parameterised over another class.
- C++ implement this ability using templates.
- Templates can do other things besides implementing generics.
So to say that Java's generics is a crippled copy of C++'s template
mechanism isn't entirely true.
OTOH, I haven't seen Java generics or C++ templates "for real", so maybe
I'm mistaken.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
 |