[1044] in java-interest
Re: Operating Overloading
daemon@ATHENA.MIT.EDU (Ray Cromwell)
Thu Aug 17 14:16:43 1995
From: Ray Cromwell <rjc@clark.net>
To: java-interest-digest@java.sun.com
Date: Thu, 17 Aug 1995 11:30:44 -0400 (EDT)
I vote yes on operator overloading simply because it is so convenient
for dealing with numeric and string libraries (and streams are very
convenient) . Yes, simply because they are convenient. Object Oriented
languages are nothing more than a convenience. One could do OO by hand if
one wanted.
IMHO, a = b*c + d is much more readable than
assign(a,add(mult(b,c), d)) or
a.assign(b.mult(c).add(d))
Any language allows abuse. Anyone can write sloppy, hard to read and
maintain code in Java. I once saw some code in C that only used
x and y throughout for variable names. If more than two variables were
needed, "x_", "x__", etc were used. If someone writes a bunch of
classes that have member functions with the same name (like List::add(),
Number::add(), String::add(), Salary::add() ), you're still going
to have the same problem when reading the code as you would with '+'.
I want a language that makes it harder for you to shoot yourself in
the foot (as with C and pointers and malloc()/free() ), but I don't
want to lose notational convenience. Java makes operator overloading
much more efficient than C++ because in C++ there is no garbage
collection so you must return temporary objects for expressions
which need to be copy constructed, then assigned. (whereas
in Java, you'd just new the object and return the reference)
Given the "componentware" aspect of OO/Java, I don't see that you
really need to know what the internals of an object library look like
anyway. Only the interface is really important. If you don't like
using Op-Ov then don't. If you're going to be maintaining someone else's
code, and you have a hard time reading it, subclass it and override
the things that need rewriting. IMHO, a language is not a substitute for
good programming style.
-Ray
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com