He's right to say that Generics adds a certain level of complexity to the language. But it's designed to simplify programming. If you don't abuse it, it is a benefit rather than a hindrance.
Consider C++... Why do people think it's so difficult? It's because there are so many different ways to do things and a lot of the features are abused. But if you only use a controlled subset of the features in a consistent way, that complexity goes down and it becomes manageable.
It's the same with Generics. He's given some examples of some real weird stuff that could be done with it. But why would you want to do it? If the whole point of this is to simplify things, why do things like that? I've used Generics and I feel it has made things better. When you're looking over code and you see them declarations which specify what type of object the data structure contains, it makes things so much more clear.
I can't say people in the .NET community have voiced similar concerns, but that may be partly cause .NET 2.0 hasn't come out yet. Maybe once it's out there for a while and people start seeing problems like this there'll be some complaints. I haven't seen a total/complete comparison between the Java/.NET implementations and what can be done with them so I dunno if what he's talking about can be done in .NET also (I would assume so). So lets see.
As I said, my personal feeling is that Generics is definitely an improvement and is something that is needed.
As an aside - Just noticing these two trends... Java and .NET are moving to things like Generics which require you to specify MORE detailed type information, whereas there's also a huge move towards dynamic languages like Python, Ruby and Javascript which are the opposite and infer all type info.
No comments:
Post a Comment