Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2005

Tip: Looking for answers? Try searching our database.

Generics is a waste of time

Thread view: 
Sharp - 15 May 2005 11:49 GMT
Hi

The new Java construct generic is a waste of time - I just read about it.
Not sure if construct is the correct word to use,
but the point is using generics only slows down development.

I understand the reason for using generics: to avoid run-time errors caused
by unchecked casts at compile time.
My argument is that the programmer should know what type of object is being
dealt with and thus what appropriate cast to use.
If you don't know, then what does it say about you as a programmer?
My two cents.

Cheers
Sharp
Lee Ryman - 15 May 2005 12:07 GMT
> Hi
>
[quoted text clipped - 11 lines]
> Cheers
> Sharp

And yet in the Real-World(TM) applications are made of many different
components, tiers, APIs, SPIs, all often written by different people
with different levels of understanding and particular areas of
expertise, and all expected to Just-Work(TM).

IMHO the time it takes to add the extra bit of syntax would be greatly
less than the time resulting from users of your APIs having to debug
their software because you didn't use generics. That said, its a nicety,
not a necessity.

Are you saying that you write perfect code 100% of the time?

Kind regards,

Lee
Sharp - 15 May 2005 12:54 GMT
> > Hi
> >
[quoted text clipped - 21 lines]
> their software because you didn't use generics. That said, its a nicety,
> not a necessity.

Point taken.

> Are you saying that you write perfect code 100% of the time?

No, and I often pick up errors at run-time.
But is that so bad?
Whats the difference of picking errors at run-time than compile time? - It's
just another level.
Why such the emphasis of detecting errors at compile time?
One must run the program and check for errors too... not just syntactical
ones.

Cheers
Sharp
Christian Gudrian - 15 May 2005 13:17 GMT
> Whats the difference of picking errors at run-time than compile time?

"If you don't know, then what does it say about you as a programmer?"

Christian
LOL - 15 May 2005 13:40 GMT
> > Whats the difference of picking errors at run-time than compile time?
>
> "If you don't know, then what does it say about you as a programmer?"
>
> Christian

LOL :-)
Ross Bamford - 15 May 2005 22:12 GMT
> > > Whats the difference of picking errors at run-time than compile time?
> >
[quoted text clipped - 3 lines]
>
> LOL :-)

:))

To the OP, what's the difference between you seeing a problem in your
development cycle and fixing it, and some customer seeing the problem
the morning after it dumps their mission-critical database at 3am?

I like Generics in terms of collections, and certain generic classes too
(Class springs to mind). And as for always knowing a variable's type,
the point about a generic collection is not necessarily to know the type
per se, but to restrict to a particular branch of a hierarchy.

I'm realising more and more that we must be careful not to overuse
Generics, however. In a similar way to VarArgs, we need to carefully
consider whether we need it *this time* every time.

Signature

  [Ross A. Bamford]     [ross AT the.website.domain]
Roscopeco Open Tech ++ Open Source + Java + Apache + CMF
http://www.roscopec0.f9.co.uk/ + info@the.website.domain

ByteCoder - 15 May 2005 13:56 GMT
>> > Hi
>> >
[quoted text clipped - 39 lines]
> One must run the program and check for errors too... not just
> syntactical ones.

IMO it's more user-friendly if you catch all errors. This would allow
you to show a nice error message instead of a stacktrace to the user.

Signature

-------------
- ByteCoder -           ...I see stupid people
-------------
                  Curiosity *Skilled* the cat

Sharp - 15 May 2005 14:08 GMT
> >> > Hi
> >> >
[quoted text clipped - 42 lines]
> IMO it's more user-friendly if you catch all errors. This would allow
> you to show a nice error message instead of a stacktrace to the user.

Point taken.
Compile time errors are easier to debug than run-time errors.

Cheers
Sharp
Tony Morris - 15 May 2005 12:21 GMT
> Hi
>
[quoted text clipped - 11 lines]
> Cheers
> Sharp

"Fail early, fail as early as possible".
Generics supports this concept by moving the deferment of error handling
from runtime to compile-timer.
It does far more than prevent runtime cast errors.

Signature

Tony Morris
Software Engineer, IBM Australia.
BInfTech, SCJP 1.4, SCJP 5.0, SCJD

http://www.jtiger.org/ JTiger Unit Test Framework for Java
http://qa.jtiger.org/ Java Q&A (FAQ, Trivia)
http://xdweb.net/~dibblego/

Paul van Rossem - 15 May 2005 14:33 GMT
> Hi
>
[quoted text clipped - 6 lines]
> My argument is that the programmer should know what type of object is being
> dealt with and thus what appropriate cast to use.
If you always know a variable's type, then why not use a single type as
the only type? Why the hassle of creating all kinds of typed objects and
scalars and casts and such? Waste of time?? Why not go back to VB or Pascal?
-paul-
> If you don't know, then what does it say about you as a programmer?
> My two cents.
>
> Cheers
> Sharp
Sharp - 15 May 2005 15:11 GMT
> > Hi
> >
[quoted text clipped - 10 lines]
> scalars and casts and such? Waste of time?? Why not go back to VB or Pascal?
> -paul-

Your logic does not flow from one point to another.
Always knowing a variables type and suggesting to have a single type for
everything makes no sense.

Sharp
Christian Gudrian - 17 May 2005 07:06 GMT
Paul van Rossem schrieb:

> Why not go back to VB or Pascal?

As far as I remember Pascal is very strongly typed and provides only
very few implicit type conversions.  That's why I used to like it that
much. :)

Christian
znôrt - 15 May 2005 15:59 GMT
> My argument is that the programmer should know what type of
> object is being dealt with and thus what appropriate cast
> to use. If you don't know, then what does it say about you
> as a programmer? My two cents.

Getting around that cast would have been quite simple taking care of that at
compile time, just looking at the type on the assignement's left side.
Something like

MyElement c ; c =  someCollection.iterator().next() ;

could automatically be translated into

MyElement c ; c = (MyElement) someCollection.iterator().next() ;

and it would be useful and nice 99% of the time. A pityfull warning would have
been more than enough. But then, generics aren't there just to avoid that
cast, but because there was a significant demand for typed collections as
such.

I should mention that adding the extra cast doesn't bother me either, but
then, specs are not just for you and me :-) As Java gets more involved into
"business", it's just natural to expect the spec to be a biased towards
"productivity" issues. In large business projects where programmers come
and go, and you can't really rely on them to be specially smart or involved.
Typed collections "have been said to be" a convenient way to deal with poor
attention, favouring more quality, which I'm far from sure of. Me too, I would
say the best remedy for poor attention is favouring more attention, but that's
the deal. It is not so to say that type safe collections *weren't* available until
1.5, it's just that type checking had to be dealt with by he programmer, which  
some of us would find only natural, and far mor convenient than the proposed
generics thing, which is (most respectfully) way more of a hassle. I don't
think I'm going to "use" them that much, but it seems we all will have to "get
used" to them :-)
Harald - 15 May 2005 22:01 GMT
> My argument is that the programmer should know what type of object is being
> dealt with and thus what appropriate cast to use.
> If you don't know, then what does it say about you as a programmer?

Yeah, what's this business with all the types anyway. Just "Object"
for everything would be completely sufficient, because I know exactly
what I store in all those vars of mine.

> My two cents.
Cheap enough.

 Ooompf,
 Harald.

Signature

---------------------+---------------------------------------------
Harald Kirsch (@home)|
Java Text Crunching: http://www.ebi.ac.uk/Rebholz-srv/whatizit/software

LDB - 16 May 2005 00:04 GMT
Then don't use it ...  :))

LDB

> Hi
>
[quoted text clipped - 11 lines]
> Cheers
> Sharp
Wibble - 16 May 2005 02:40 GMT
And make sure your promoted before you have to fix
those runtime errors in production.

> Then don't use it ...  :))
>
[quoted text clipped - 17 lines]
>> Cheers
>> Sharp
Chris Smith - 16 May 2005 03:51 GMT
> > Then don't use it ...  :))

> And make sure your promoted before you have to fix
> those runtime errors in production.

I like generics, actually... but that's ridiculous.  Generics are not,
and have never been, necessary in order to develop good quality
software.  They help (mainly, IMO, by making code more self-documenting
and making development tools more capable... not by catching potential
ClassCastException scenarios), but plenty of good code was written
before they existed.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Lasse Reichstein Nielsen - 16 May 2005 12:12 GMT
> The new Java construct generic is a waste of time - I just read about it.

The try using it, and see if you still think so. :)

> Not sure if construct is the correct word to use,
> but the point is using generics only slows down development.

How? Is it because of the extra letters to write?  Do you have any
measurements to back this up?

> I understand the reason for using generics: to avoid run-time errors caused
> by unchecked casts at compile time.

Or to more precisely describe what is going on, both to the computer
and to readers.

> My argument is that the programmer should know what type of object
> is being dealt with and thus what appropriate cast to use.

Floating point numbers is a waste of time. "Any competent mathematician
should be capable of keeping track of decimal points ... ".

Editors that lets you edit inline is a waste of time. "I don't feel a
need for them, I don't want to see the state of the file when I'm
editing".

> If you don't know, then what does it say about you as a programmer?

I'm human? (and Von Neumann and Ken Thompson wasn't :)

/L 'or am I feeding a troll?'
Signature

Lasse Reichstein Nielsen  -  lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
 'Faith without judgement merely degrades the spirit divine.'

Lee Ryman - 16 May 2005 14:51 GMT
> /L 'or am I feeding a troll?'

*Woooooooeeeep* *Wooooooeeeeeep*
HalcyonWild - 17 May 2005 13:37 GMT
> > The new Java construct generic is a waste of time - I just read about it.
>
> The try using it, and see if you still think so. :)
>
> How? Is it because of the extra letters to write?  Do you have any
> measurements to back this up?

Hi

Apart from collections, is there any other place we can think of using
Generics. Plus you wont use generics if you are keeping instances of
different objects in a Vector, eg. (String)vec.elementAt(0); and
(Hashtable)vec.elementAt(1);
Phillip Lord - 17 May 2005 13:56 GMT
>>>>> "HalcyonWild" == HalcyonWild  <Halcyon.Wild@gmail.com> writes:

 >> "Sharp" <Sharp@SharpAddress.com> writes:
 >>
 >> > The new Java construct generic is a waste of time - I just read
 HalcyonWild> about it.
 >>
 >> The try using it, and see if you still think so. :)
 >>
 >>
 >> How? Is it because of the extra letters to write?  Do you have
 >> any measurements to back this up?
 >>

 HalcyonWild> Apart from collections, is there any other place we can
 HalcyonWild> think of using Generics.

Anything with a data model. Swing is an obvious example--instead of
ListModel, you will use DefaultListModel, and the contents of the
ListModel will be generic'd.

 HalcyonWild> Plus you wont use generics if you are keeping instances
 HalcyonWild> of different objects in a Vector,
 HalcyonWild> eg. (String)vec.elementAt(0); and
 HalcyonWild> (Hashtable)vec.elementAt(1);

In almost all cases, this is a bad idea anyway. If you do this, you
are either going to dispatch the object returned based on it's class
(which is okay, but not normally necessary), or you are using
implicit structuring in an vector (first element is a name, second a
phone number perhaps). In which case you should be using an object.

Phil
Tim Ward - 18 May 2005 16:17 GMT
> The new Java construct generic is a waste of time - I just read about it.
> Not sure if construct is the correct word to use,
> but the point is using generics only slows down development.

Tee hee. Clearly a BCPL fan!

--
Tim Ward
Brett Ward Limited - www.brettward.co.uk


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.