Re: Operator overloading in Java ?
From: Anthony Borla (ajborla_at_bigpond.com)
Date: 02/22/05
- Next message: Tilman Bohn: "Re: OO programming - illumination? - whoopsie"
- Previous message: bugbear: "Re: design experiment?"
- In reply to: Thomas Weidenfeller: "Re: Operator overloading in Java ?"
- Next in thread: exquisitus: "Re: Operator overloading in Java ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Feb 2005 12:08:14 GMT
"Thomas Weidenfeller" <nobody@ericsson.invalid> wrote in message
news:cveu2q$b9b$1@newstree.wise.edt.ericsson.se...
> Paul wrote:
> > The point to operator overloading in C++ [distilled from
> > Stroustrup] was to simply mimic the mathematical operations
> > available on elementary data types and also indexing with [],
> > dereferencing, and most others.
>
> But even the father of C++ (Stroustrup himself) couldn't
> resist the temptation and sanctioned the abuse of the
> bit-shift operators for I/O.
>
Oh you mean overloading them for stream-based I/O ? I find this particular
use quite intuitive [then again, C++ was my first OOPL]. Horses for courses,
I guess :) !
>
> With that he set the precedence for an endless amount of
> operator-overloading abuse in C++ by programmers all
> over the world. If the language's father can't stay clean,
> how should his loyal followers?
>
I don't mind the operator overloading facility in C++ - it is very, very
flexible - and, correctly, and *sparingly* used, can truly enhance a design,
making it more understandable. Of course this is a subjective observation:
it depends very much on whether someone prefers code which looks like this:
a == b
or like this:
a.equals(b)
Unfortunately its very flexibility makes it a facility that can be very
easily abused. Not much that can be done about that except perhaps
appropriately educate / train developers, and draw up, and enforce,
standards that will prevent, or at least minimise such abuse.
>
> IMHO, one of the best design decisions for Java was to
> leave out that stuff. Unlike in the 1960s numeric computation
> is no longer what most programs do, so for many programmers
> it is not essential at all. There are other languages for those who
> need it. Sooner or later some scientists with apparently to much
> time on their hands will try to force that stuff into Java because
> they need it, while the many more people who don't need it can't
> spent time in the decision-making comities to fight it.
>
> I could make a similar case for generics. Yes, they are not
> templates. Yes, you can use them for something useful.
> But if I see the many attempts to use them like templates
> and e.g. the number of "generic" classes like Pair classes
> which suddenly pop up left, right and center then I see my
> worries confirmed. Generics will do harm to the language
> in the long term. I bet there are already several people who
> try to build an SGL (Standard Generic Library) for Java to
> mimic C++'s STL and to force it down the throat of Java
> programmers. :-(
>
I haven't experimented enough with 1.5 to venture an opinion on Java
generics. I will say, however, that whilst some of the work with C++
templates - particularly template metaprogramming - is quite astonishing and
clever, but it's also esoteric, mindboggling, and reeks of 'trickery', not
features that I think should be associated with a usable programming
language, and is one aspect of C++ that I've grown to dislike.
As for the future of Java, I can only say that I know of no commercial
programming language that has *removed* features as part of its evolution.
Language standards documents only ever *grow* [resulting in more tree
deaths] over time !
Rememember, also, that when trying to sell a product, one way to
differentiate it from competitors, thus make it more attractive to potential
customers is to enhance existing, and add new, features. I think we all know
what that means when applied to programing languages :) !
Cheers,
Anthony Borla
- Next message: Tilman Bohn: "Re: OO programming - illumination? - whoopsie"
- Previous message: bugbear: "Re: design experiment?"
- In reply to: Thomas Weidenfeller: "Re: Operator overloading in Java ?"
- Next in thread: exquisitus: "Re: Operator overloading in Java ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|