Re: Why Generics?



Mike Schilling wrote:

> [me:]
> > Funny thing, I know you intended this as sarcasm, but I agree with it as
> > written. Well. not quite literally -- I don't suppose there's any
> > conspiracy -- but I do think that generics have been introduced out of
> > ill-considered, or unconsidered, C++-envy.
>
> Why C++, in particular?

My reason is simply that people have been discussing adding "templates" to Java
since well before C# was invented (or at least publicly admitted to). Same
goes for enums.


> The next version of C# has generics, and the
> current one has auto-boxing, variable-length argument lists, for-loops
> over collections, etc. Given that Java competes for mindshare with .NET,
> I think competition with C# is a more likely motive for the 1.5 changes.

I agree that C# provides competition and a source of ideas (both good and
bad). I don't doubt for a minute that Java's auto-boxing etc, have been added
more in imitation of C# than convergently with it.

BTW, do you know of a description (readable, rather than a formal spec) of the
semantics/implementation of C#''s generics ? I gather that it's being done at
the VM level rather than by compiler kludgery. If so then it may be that C#''s
generics are less problematic than Java's.

-- chris




.