Generics is a waste of time

S

Sharp

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
 
L

Lee Ryman

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
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


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


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iEYEARECAAYFAkKHLXEACgkQhbcFpQga0LA0iwCgqDPNejCSDxlM9aQf2yo+Bebk
O28AoMiOvOlXx5Bbd/I5zJWnU35FmJrq
=OZgX
-----END PGP SIGNATURE-----
 
T

Tony Morris

Sharp said:
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

"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.

--
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/
 
S

Sharp

Sharp said:
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.

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
 
C

Christian Gudrian

Sharp said:
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
 
B

ByteCoder

Point taken.


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.

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.
 
S

Sharp

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
 
P

Paul van Rossem

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 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-
 
S

Sharp

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-

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
 
Z

znôrt

Sharp said:
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 :)
 
H

Harald

Sharp said:
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.
 
R

Ross Bamford


:))

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.
 
C

Chris Smith

Wibble said:
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.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
L

Lasse Reichstein Nielsen

Sharp said:
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?'
 
L

Lee Ryman

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

/L 'or am I feeding a troll?'

*Woooooooeeeep* *Wooooooeeeeeep*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iEYEARECAAYFAkKIpVgACgkQhbcFpQga0LCTWgCfaiPTvSeOZGPAL3aS02e5ORfv
5bEAn07cwo2Nk19kIjy8ktNOQcm9iR2n
=YMWK
-----END PGP SIGNATURE-----
 
C

Christian Gudrian

Paul said:
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
 
H

HalcyonWild

Lasse said:
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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

generics puzzle 57
Generics Amanuensis? 2
Generics annoyance 18
Generics 12
Generics for a multiplevalue hashmap 8
Is using splint a waste of time ? 6
Generics, for non collection types 33
Studying Generics 3

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top