[589] in java-interest
Re: Operator overloading
daemon@ATHENA.MIT.EDU (Francois BOUSSARD)
Wed Jul 5 13:28:22 1995
Date: Wed, 05 Jul 95 13:12:03 0200
From: Francois BOUSSARD <francois@coplanet.fr>
To: java-interest@java.Eng.Sun.COM
> Henri BROUCHOUD - FT.CNET/LAA/EIA/AIA (brouchou@lannion.cnet.fr)
> Thu, 29 Jun 1995 11:52:44 +0200
>
> Sorry I don't actually understand where goes this discussion ...
> It seems to me that there are no differences between method or
> operator definition other than syntactic. All the problems, ambiguities,
> obscurity that you can introduce with operators can be introduce
> with methods too.
>
> > then you really need
> > a degree in pure maths to work out the group theory for any non-trival
> > classes that you want to use these features for.
>
> > If it looks like * it needs to act like *, so the group of all your
> > classes instances needs to be reflexive, transitive, have a unity
> > instance etc. etc.
>
> ??? You give your defined operator the semantic you want (like any method
> behavior), and why should it be a transitive group ?? .
> In the string class : S1 + S2 ( =3D S1.append(S2)) is certainly not
> the same as S2 + S1 ( =3D S2.append(S1)) ! And S1 * S2 has no sense !
> I don't think the meaning of "operator" in programming language is the
> same as in group theory.
Fully accord with henri :
- The + and * are not lows to respect : they are concepts to honor. Most of
objects can be added each-other : the ADD is a universal concept. The objects
have not to respect comutativity and so on : only to be added one to the other !
- And, for programers who use and imagine to implement + operator on his
objects, it's _VERY_ more fine to remember that his objects can be added as to
remember that he has to do obj1.add(obj2) to perform it.
- A future user of the class can then use directly obj1+obj2 and he has not to
read the doc of each classes he imports for knowing how to add them.
>
> Moreover ,
> You always can write bad code with any language you use, and
> it is the programmer's responsability to write clear and maintainable code.
> With the same reflexion you could say : Why introduce <procedure> concepts in
> modular language such as Pascal and others since you can write :
>
> procedure _67JJUlo__90 ( LI89 : integer, _$YU7_ppOL :real) ...
>
> which can introduce a lot of obscurity on what this procedure actually does .
> Same for multiple inheritance ...
>
Whatever the language can be, everyone can write howfull codes. EVEN in Java.
Good programers can write Object Oriented pure and clear assembler codes.
The langage is just a tool for programers : not a low to respect.
> Introducing a new language on the market suppose to provide more than what
> exists
> today , not to be restrictive ! If _I_ consider that operator definition makes
> my
> code "obscure", _I_ will not use this feature, this is _MY_ responsability to
> take
> such a decision (that's what I do today with C++).
Since a long time, new langages gave us more than older languages.
Java give us
- the Interface concept : good thing in place of virtual functions of C++.
It's provides the concept of virtuality by explicit encapsulation of what is
virtual and implemented : realy prety thing .
- the garbage-collector : mervellous idea to control internally al the uses of
pointers. It's a problem unsolved in C++. And there, we can create pointers as
we want, we are sure that when no reference point to it, it will be freed :
thank you.
- the plateform-independance : it's why it can be the standard on internet.
That's the core progress of Java. Without that, we'd not been interested about
it.
- the multi-tasking basic tools : in C++, it was possible to do these things
on every multi-task OS, but each time on plateform-dependant code. Now, a unique
code permits it whatever OS could be : fine. But, whatabout semaphores,
interprocessus communications, real multi-task (and not only multi-thread)..
- well, that's all ..
Java RESTRICT us on:
- C++ TEMPLATE powerfull concept is not in Java. Why NOT ?. It's so
comfortable to write ONE code whatever datas could be. I am not sure that the
use of Java 'interface' for parameters permit us the same abstraction as C++
'templates'.
- C++ function pointers and methods pointers : it's really more than a gadget.
It's permit us to write scheduler who receives registration-calls of=A0unknown
object instances which give their callback function pointer to scheduler. How to
do that in Java ?
- C++ operator redefinition : it's the most powerfull abstraction tool of C++.
It's hiding the internal component of classes : imagine a class about matrix. In
C++ you can write ONE class of matrix whatever can be the internal objects on
the matrix : you just have to use TEMLATES, and using the standards operators on
the objects in matrix. The same work in Java could be hazardous and complicated.
> On the other side if I _NEED_ operator definition for some reason of mine, I
> will not
> use Java but C++ or other ...
>
I will use Java for internet programming, because he offer me :
- plateform independence
- libs for using network protocols
But, I always prefer C++ for the abstraction level you can build with.
(humm, sorry for my english writing)
--
__________________________________________________________________________
Francois BOUSSARD
Coplanet : Tel : 44.64.87.60
162 Bd Davout. 75020 PARIS
FRANCE fb@coplanet.fr
__________________________________________________________________________
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com