OT: on IDEs and code writing on steroids

Nick Sabalausky a at a.a
Wed May 20 03:03:53 PDT 2009

"Lutger" <lutger.blijdestijn at gmail.com> wrote in message 
news:gv090o$225$1 at digitalmars.com...
> Andrei Alexandrescu wrote:
> ...
>>> What the heck do you need generics for when you have real templates?  To 
>>> me,
>>> generics seem like just a lame excuse for templates.
>> I agree. Then, templates aren't easy to implement and they were
>> understandably already busy implementing the using statement.
>> Andrei
> While I don't fully understand how generics work under the hood in .NET, 
> there are some benefits to how it is done. For example, you can use 
> runtime reflection on generic types. And the jit compiler
> instantiates them at runtime. They may serve a different purpose than 
> templates:
> "Anders Hejlsberg: To me the best way to understand the distinction 
> between C# generics and C++ templates is this: C# generics are really just 
> like classes, except they have a type parameter. C++ templates
> are really just like macros, except they look like classes."
> It seems that lack of structural typing is seen as a feature:
> "When you think about it, constraints are a pattern matching mechanism. 
> You want to be able to say, "This type parameter must have a constructor 
> that takes two arguments, implement operator+, have this
> static method, has these two instance methods, etc." The question is, how 
> complicated do you want this pattern matching mechanism to be?
> There's a whole continuum from nothing to grand pattern matching. We think 
> it's too little to say nothing, and the grand pattern matching becomes 
> very complicated, so we're in- between."
> From: http://www.artima.com/intv/genericsP.html

I can see certain potential benefits to the general way C# does generics, 
but until the old (and I do mean old) issue of "There's an IComparable, so 
why the hell won't MS give us an IArithmetic so we can actually use 
arithmetic operators on generic code?" gets fixed (and at this point I'm 
convinced they've never had any intent of ever fixing that), I don't care 
how valid the reasoning behind C#'s general approach to generics is, the 
actual state of C#'s generics still falls squarely into the categories of 
"crap" and "almost useless". 

More information about the Digitalmars-d mailing list