Re: Mutability
Re: Mutability
- Subject: Re: Mutability
- From: Julien Dufour <email@hidden>
- Date: Wed, 21 Nov 2001 18:42:13 +0100
On Wednesday, November 21, 2001, at 05:45 PM, Ondra Cada wrote:
Julien,
JD> >So far as I understand OOP, the proper OO point of view is "give
_any_
JD> >object to me; I'll determine what kind it is, and I'll behave
JD> >accordingly".
JD>
JD> That's not OOP, that untyped langage programming.
Yeah, untyped -- that what's an object is! There are no "types" in the
object world: anything's an object, and differences are resolved by
polymorphism, not by typing.
No! Object oriented does not mean untyped!!! Those things are differents
but not incompatible. I agree that I have never seem a strongly typed OO
langage (unfortumately). C++ is the stronger I know (thanks to
parametric polymorphisme).
JD> Typechecking is compilation stage where the compiler tells
JD> you if you are doing something wrong. Stronger typesystems lead to
JD> robuster programs
____Quite the contrary!!!____
There is *always* a possibility to send an object of a different type
than
compiler thought -- be it due to bad header used, or an out-of-date
plugin
loaded, or an upgraded dynbamic library, or whatever.
That because of security hole, like casts, and dynimic library that do
not check that typing is respected.
In "your" world, the result might be just anything: crash, improper
behaviour, anything's possible.
No, or because there are holes in the typesystem.
That's exactly why C++ verges on the edge of
unusability: both the compiler and programmer "know" beforehand what
type the
argument has, and make the code accordingly. In reality they just
_though_
they knew, something other really happens, and the result? All hell
breaks
loose.
Don't use any cast, or other tools that break the typing, and try to
find one program that don't work because of typing error... C langage
familly have a really weak typing, that's why there are so many bugs and
crashes. Take a look at functional langages like ocaml or Haskell that
have a stronger typesystem and you will change your mind.
OTOH, in _object oriented_, ie. _runtime_, ie. _untyped_ world its all
right: both the compiler and programmer presumed that _any_ object can
be the
argument. Therefore, the code is made so that it either works properly,
or,
at the worst, it crashes properly (ie. at the place and time where the
problem occurred, and with an appropriate report).
Don't mix OO and typing, there is typed OO langages, untyped OO
langages, typed non OO langages and untyped non OO langages.
No, it's only a workaround because the compiler produce code that is
able to fail.
Do believe me. The preceding two paragraphs are not some theory I have
conjured last evening; it's a very practical result of many hundreds of
thousands lines written in plain C and ObjC, of many tens of thousands
lines
written in C++, and the experience with robustness, debugging,
maintaining
and upgrading them.
Do believe me. My point of view comes from thousands of papers written
by researcher, that have been mathematically prooved, not by the
experience of people that always have worked with arguable tools.
I think were are really going off topic. I suggest you to continue this
discution out of the mailing list if you want.
--
Julien Dufour