[929] in java-interest

home help back first fref pref prev next nref lref last post

Re: overloading of operators

daemon@ATHENA.MIT.EDU (Terence John Parr)
Tue Aug 15 17:26:20 1995

Date: Tue, 15 Aug 1995 10:40:12 -0700
From: Terence John Parr <parrt@parr-research.com>
To: Matthew-Newman@deshaw.com, MikeDacon@aol.com, Tako.Schotanus@bouw.tno.nl,
        java-interest@java.sun.com
Cc: gary@Intrepid.COM, johnm@alumni.EECS.Berkeley.EDU

Hi gang,

> I don't understand you guys at all! It's not as if *your* programs would be
> any worse off for just having a feature built into the language!

We are all worse off if you allow a language feature.  If it exists,
people will use it.

> And as for other people's programs, you're basically telling them "you can't
> use that feature because I don't like it".

That's right; so that when I get a piece of code written by somebody that
thought + was the right way to say database.addRecord(...), I don't have
to scratch my head and then say "oh, must be some wacko operator that
is hiding somewhere up in the hierarchy."

This is how C++ started: never saying no to new features.  Remember just
because you can do it, doesn't mean it's a good idea.  Ask yourself which
of the following is easier to understand (yes, even you have
to understand your code later):

database.addRecord(foo);
database += foo;

Maybe += does something else...you don't know...you have to go back
and look.  Note that I chose a reasonable example, there are many
insane ones.

I don't program in APL either, BTW.

> I don't mind if we don't get operator-overloading, but if the Sun-people
> really listen too us on this list we'd better make sure we make our reasons
> for having or not having something are good ones.

The reason is simple: C++ is too complicated.  Java is not.  Let's keep
it that way.

As a person who's life revolves around implementing language tools, I
must say you increase the complexity and difficulty of every Java tool
with every addition.  At the moment, it's a no-brainer (well almost).

I can send you my slides that I use to scare people when giving a talk:

	"C++ Parsing (Or, How to induce heartattack)."

> So for me: *I* like operator-overloading, I think that if you use it in a
> controlled way it can make your code more elegant, but that's a personal
> opinion for sure.

Key word is control.  Most people have none, but you might.  I appreciate
your control and your opinion, but I still like to read English programs
not APL. ;)

> As for the fact that somebody else might find it difficult to understand my code,
> well to be honest (as long as I don't publish the code ;) I don't give a
> .......... (fill in your favourite rodent's backside).

Let's hope you don't have to maintain your code at some point. ;)
[my favorite rodent is "rat"]

> I apologise if this is a bit rude, but I really think that it's nobodies
> business but mine to decide what features I'm going to use or not.

That's right; so let's not allow features that can be so easily abused.

> So shortly put: If there are NO compelling reasons NOT to have the feature
> we might as well considering putting it in for the people who want it.

The reasons are simplicity and readability (read that maintainability).

I type fast and don't worry about a few keystrokes for readability.
My variable names tend to be long.  For a good laugh you should see
my translator I built for some Army code...it had function names
like:

	TraverseASTAndGenerateListOfImplicitlyDefinedScalars(AST *t);

No doubt what *that* function does :).  Better than a comment because I'll
change the function name if its function changes, but programmers don't
typically change comments. ;) ;)

Terence of the Surf
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post