Stewart Stremler wrote:
begin  quoting Christopher Smith as of Sun, Jun 10, 2007 at 12:00:46AM -0700:
Stewart Stremler wrote:
Generics changed that. Java is becoming C++ like.
I've heard a few Java people say as much, and I find it bizarre. I guess it is C++ like in that you have a little bit of type theory in there and it uses <> symbols,

No, it's because when you read up on Generics, you get an explanation
peppered with "you'd think X, but suprisingly, this isn't the case", and
then it goes off to provide a very logical reason why the language can't
do what you'd expect it to do.
Type theory is sadly not taught to a lot of programmers, even though most programming languages are typed and a good chunk of them are statically typed. This tends to produce programs with errors that are very much like the ones that Java's Generics help address. ;-) That said, Java's Generics are *very* limited, and that does produce a number of disappointments when using them, but providing "limited" versions of things in an attempt to reduce complexity is a *very* Java thing, and a very *non*-C++ thing.
It's violating the principle of least suprise.
I'm all for the principle of least surprise, but one of the catches with it is that what is surprising depends a lot on your context. In general, most of "surprises" with generics I've heard people complain about fall in to two categories: 1) things it can't do and 2) things it won't let you do, but if you'd did them without generics you'd have similarly disappointing results.
It's exactly like reading about many C++ features. At least to me.
Honestly, on its worst day, Java Generics doesn't have half as many surprising gotchyas as C++.
but frankly Java without generics just had this huge gaping eyesore of a problem in its type system,

Never bothered me. Bothered some of my collegues, but I figured that
if you're passing around raw collections, you're writing poor OO code
anyway, so why worry about it.
It's the having to wrapper your raw collections with the same stupid type checking logic that can be done far more consistently and correctly by computer. It's the having to put in type checking logic even when you can prove that it is totally unnecessary, etc.
All I wanted was covariant return types.

But now I read that you're not supposed to use those... Wah!
covariant return types unfortunately can get you in to trouble. Contravariant are somewhat better, in that the nature of the trouble is somewhat better, but still.
"Wouldn't it be neat if..." is a poor design aesthetic.
I think if you read Stroustrup's writings on the matter, you'll find that this was not the C++ design aesthetic.
Honestly, if they could just generalize what they did with the "synchronize" keyword a bit more, the language might turn out to be halfway decent.

It already was halfway decent.

Had they put the thought they put into "synchronize" into generics, they
hopefully could have come up with something less obnoxious.  Or decided
that it wasn't important (like multiple inheritance).
They actually put a LOT of thought in to generics. Java Generics represents the better part of a decade's worth of work on the matter, not to mention all the other work that has gone on in the larger field. The synchronization stuff is very weird though. I mean, what sane person really thinks that monitors are the *only* thing that would benefit from succinct, encapsulated, guaranteed lexical scoping.
I don't want a one-language-fits-all-problems language. It just results
in a language that is equally unpleasant for all problems...
Hmm... I think this was intended as a critique of C++, but it reads like a critique of Java. ;-)

--Chris

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to