Wilhelm Fitzpatrick wrote:
| unfortunately in the future Java code will be obscure just like C++
| code with many templates is
| so we won't need any obfuscation just use generics :-))
I replied:
| *Well-designed* C++ code isn't obscure, even with templates. And bad
| programs can be written in any language.
Rolf Howarth commented:
| That's true of course. But templates (and even worse, operator
| overloading - uuggghh!) make it that much easier to write poorly
| designed code, and to write code which is difficult to understand.
No argument there. With power comes responsibility, and C++ gives you a lot of power, assuming that the programmer has the discipline and knowledge to use it properly.
It's worth remembering that templates in C++ started out as nice, simple things roughly comparable to Java generics. They got complexificated as people said "if I can do *this* with templates, why can't I do *that*?". Much of the obfuscation potential comes from people discovering that templates as currently defined can do amazing things if you poke around in the right dark corners. (You can, for instance, use them to find out *at compile time* whether a class has a particular method defined, or to declare a variable of the same type as the third argument of a function.) There seems to be fairly widespread agreement in the C++ community (including those on the language standard committee) that templates could stand serious revamping; the uncertainty is what form that revamping should take, and how to reconcile that with efforts at taming--or eliminating--the macro preprocessor. Java fans wanting to keep generics clean should take an active interest in how C++ deals with the !
template problems.
Rolf Howarth wrote:
| Even if the original design is ok, when someone else comes along and
| has to fix something in code using templates.
If templates make the code *simpler*--clearer, more maintainable, etc.--fine. If not, then they shouldn't be there, and you're seeing an incompetent programmer at work.
I added:
| Do recall that generics were added because the user
| base--programmers--wanted them, not because the teachers did.
Rolf Howarth wrote:
| I'm sure that's true, but I wonder whether Java programmers who
| wanted them or C++ programmers?
Since the *first* edition of the Java Language spec mentions that proposals for adding parameterized types (which is what generics are) were already in hand, I'd suspect the Java people. Besides, the C++ fans would have pushed for overloaded operators, too, something else where the two languages differ, and something which would have required less change to the language. (After all, Java already *has* operator overloading, just no way for the programmer to define his own.)
| By that I mean, how many people who'd
| actually immersed themselves in Java for a period really missed
| templates or whether it wasn't just people who spent most of their
| time doing C++ but were tinkering a bit with Java and finding it
| different who were shouting loudly "java is crap, it doesn't even
| have templates".
The C++ fanatics think Java is crap for a lot more reasons than that (garbage collection, for instance). And generics designed by C++ users would probably more closely resemble C++ templates in all their glory.
| All I know is that after working on a large C++ project with many
| developers and then switching to Java it was like a breath of fresh
| air, precisely it because it didn't have them (or cast operators and
| operator overloading - uuggghh!), so many problems had they caused on
| my previous project.
As always, the "best" language is in the eye of the beholder. Me, I lean towards the C++ side of things, though not so radically that I can't see Java's strengths.
Glen Fisher
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden