• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Educate me on generics please...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Educate me on generics please...


  • Subject: Re: Educate me on generics please...
  • From: Ian Joyner <email@hidden>
  • Date: Fri, 8 Feb 2008 11:45:14 +1100

On 07/02/2008, at 3:41 PM, Chuck Hill wrote:

On Feb 6, 2008, at 4:06 PM, Ian Joyner wrote:

On 07/02/2008, at 7:37 AM, Chuck Hill wrote:

From Art:

http://weblogs.java.net/blog/arnold/archive/2005/06/generics_consid_1.html

Hey, I used to work with David Holmes, many a happy hour spent discussing type systems, etc. (Well, OK maybe a few arguments as well). He put in a tremendous effort reviewing my own book.


Objects Unencapsulated: Java, Eiffel, and C++?

Gee, Chuck your knowledge is amazing! Did you get one of the three copies that were sold?


The article seems to dismiss generics altogether, but it is just the poor implementation in Java. Sun was not prepared to fix the JVM, in fact at OOPSLA in Vancouver in 1997 I remember someone getting up and telling Sun to "just fix the damn JVM". Sun never did.

I agree. Generics as a concept are useful. It is just that most developer's contact with them has been either C++ or Java. Neither is a shining example.

C++ templates are just horrible leading to code bloat, but since it was hacked on later it had to duplicate all code for different generic parameters to preserve type info at run time. Java went completely the other way, avoiding bloat, but losing run time info. Mind you, it probably isn't so important in Java since everything is an object, but in C++ you can have objects and primitive types as generic parameters (or can you do that in Java?).

I'd use generics for two reasons:

* you put the type spec in once in the generic in a neat declaration instead of clutter all over the code in the form of type casts (which are evil and should be abolished) (hence code is easier to change - just one change and recompile, OK refactoring support in IDEs make that easier, but that is just solving an introduced problem, that should not have been there in the first place).
* errors are caught at compile time


They are mainly used to specify a least required object type in collections.

That aspect of them is useful, even in Java. I can see myself using that. But they can get really confusing, really fast in Java. I'll stick to the low hanging fruit.

Yes, I also use them for just the simple cases, but that is really all over the place – I don't think I have used them in any complicated way.


This discussion is rather like the one they have just had on Cocoa- dev on garbage collection. Generics, multiple inheritance, and GC are great ideas and done properly simplify programming, but when hacked into something that didn't provide for them in the first place make programming more complicated. Hence, people mistakenly write them off. (I think the GC seems to be well done for Objective- C and Cocoa, but the problem seems to be in its interaction with C.)

I am still not quite convinced about multiple inheritance, but I blame that on C++. :-)

I just find the whole Class/Interface separation rather artificial. No one has really put up a convincing argument for Java's so-called "theoretical correctness" on this matter. It's the old interface inheritance vs. implementation inheritance debate. Without multiple implementation inheritance, Java has inner classes, etc to supposedly get around this, but that makes my head hurt just as much as the details of their generics.


The obsession the industry has with hacking good and clean concepts into C-based languages in horrible ways, debasing the simplicity and power of those concepts has held the programming profession back. (Hmmm, turning into a Rick Wakeman-style grumpy rant!)

Ian

Chuck


http://www.mindview.net/WebLog/log-0050

YMMV  :-)

Chuck


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Educate me on generics please...
      • From: David Elliott <email@hidden>
References: 
 >Educate me on generics please... (From: James Cicenia <email@hidden>)
 >Re: Educate me on generics please... (From: Chuck Hill <email@hidden>)
 >Re: Educate me on generics please... (From: Ian Joyner <email@hidden>)
 >Re: Educate me on generics please... (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Problem showing project images in app ported to WOLips from XCode
  • Next by Date: Re: Educate me on generics please...
  • Previous by thread: Re: Educate me on generics please...
  • Next by thread: Re: Educate me on generics please...
  • Index(es):
    • Date
    • Thread