Re: Mutability
Re: Mutability
- Subject: Re: Mutability
- From: John Hörnkvist <email@hidden>
- Date: Wed, 21 Nov 2001 20:02:52 +0100
On Wednesday, November 21, 2001, at 06:42 , Julien Dufour wrote:
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.
That's funny; I spend a fair amount of my time working in Haskell. The
project is a strongly typed object oriented language with parametric
polymorphism, dynamic dispatch and extreme type based optimizations.
Very strong Hindley-Milner style typing as is provided by Haskell is a
fine tool, but it my experience it makes programming large systems
harder, mostly because refactoring becomes more cumbersome.
With all static type systems, there is a very delicate balancing act;
making the type system more complex to allow more freedom to the
programmer, and keeping the type system simple enough that it is
possible to implement. Moving some decisions to run time --- when there
often more information available --- makes the type system more
comprehensible, easier to implement and less restrictive. The cost of
this is some run time type checking, dynamic dispatch, etc. However,
there are techniques to lower those costs significantly.
As I see it, the most obvious mistakes in Objective-C's static type
system are that id acts as both top and bottom, and that there is no
"self" type.
By introducing self and nil (top) types, the static type system would be
a lot more expressive.
The dynamic side suffers slightly from untyped selectors, which gets in
the way of dynamic type safety.
Regards,
John Hornkvist
--
ToastedMarshmallow, the perfect Cocoa companion
http://www.toastedmarshmallow.com