Sun to Add Variance to Java in 1.5?
Ahe writes "I have been working on a joint project between
Sun Microsystems,
The University of Aarhus,
and The Alexandra Institute.
As you might know, Sun has for long been commited to
adding generics
to Java. Our project was to extend this with variance annotations for
more flexible typing of parameterized classes and arrays. Recently
Sun has released the project result as a
new prototype
with variance. If you like variance, please vote for this bug."
Generics are at best a trade-off: compile-time type safety in exchange for less readable code. A poor trade-off at best.
Java never has and never will suffer the catastrophic consequences of type casting that C++ can. Type casts are all subject to runtime checks, so that the worst possible result is that an exception will be thrown. Where C++ has no safety without generics, Java has runtime safety.
As for readability, C++ has two major benefits over Java: a preprocessor and typedefs. Without at least one of these features, generics make code almost unreadable. Little wonder that developers new to C++ are very cautious about getting involved with generics, or that old hands know how long it has taken for the STL to become mostly stable (I say mostly, because using STL with threads in cross-platform development is a recipe for disaster).
Java is starting to look very much like something designed by a committee. A pity, because at its core it is still a good thing.
i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
Ok. This is my first real drooling mad rant. Forgive me.
[rant]
about C++ casting (covariant model of generics): old-style casting was never of real use. use new_style_casts(x) and you have run-time checking, too. other stuff said about this is C++ ignorance.
[/rant]
ohboy, I had to get it off my chest.
It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048