[Proposal]

Mike Parker aldacron71 at yahoo.com
Mon Jun 19 00:20:18 PDT 2006


Daniel Keep wrote:

> Generics in .NET and Java should really be called Object Generics, since
> it's all but useless for basic types.

They call it Generics and not templates for a reason, methinks. I know 
nothing about C#, but Java's Generics are not equivalent to templates in 
C++/D at all. For now, the implementation does little more than ensure 
type-safety at compile time and handle class casts and autoboxing behind 
the scenes so that you don't have to.

This is one thing, among many, that trips up a lot of C++ programmers 
when they come to Java. Generics are not templates, the usual operators 
can't be used on objects (except that String allows + for 
concatenation), and what have you. Because of this, someone very 
experienced in C++ is not going to be a good Java programmer without a 
lot of time and patience. Most don't bother. The languages have two 
different paradigms and you just can't attack the same problem the same 
way. There was some grumbling in the Java community when Generics were 
first introduced, but once people got comfortable with it the noise 
settled down. It's really better having them than not, though there are 
still a few week points.

If you ask a Java programmer what Java's warts are, they'll give you a 
nice long list, but it's going to be very different from the list a C++ 
programmer would give for the same question. What C++ programmers 
consider Java warts, many Java programmers see as strengths. It's a 
different language with a very different paradigm. Java is from Venus 
and C++ is from Mars.

The thing about D is that it lives on Mars, too, but it's like the first 
generation child of immigrants from Venus. I think that's why both Java 
and C++ programmers can get comfortable with it. They can each find 
something of their own cultures. I'll take Java over C++ any day of the 
week for most tasks. But D kicks them both in the teeth.



More information about the Digitalmars-d mailing list