From: Bob Hutchison Date: 2002-03-09T02:41:31+09:00 Subject: Re: Interesting link on static/dynamic typing... On 3/8/02 12:12 PM, "Matt Armstrong" wrote: > Robert Feldt writes: > >> ...relevant to Ruby compared to other languages discussion: >> >> http://www.chimu.com/publications/short/whyDynamicTyping.html > > I'm often surprised that ML (and languages like Ocaml) aren't brought > up more in these discussions. People seem to hold up Java and C++ as > the only examples of statically typed languages. > > But this post describes the same kinds of benefits in Ocaml, a very > strongly typed language. > > http://caml.inria.fr/archives/200106/msg00181.html > > I've long been meaning to explore Ocaml to see if static type > inference/unification + polymorphism really does lead to the same > kinds of benefits as dynamic type checking. > > For example, a common thread on ruby-talk is how to best verify that a > particular object implements a given interface. In languages like > Ocaml, this is not an issue. Programs simply fail to compile if the > interface is not satisfied (type inference/unification) but all > functions are still polymorphic -- i.e. their parameters can be of any > type so long as those types implement the correct interface. I'd like to add/emphasise one thing here, many/most functional languages (e.g. Ocaml, ML, Haskell, Clean, etc) do type inferencing. The compiler will tell you what the types (interfaces) of the arguments to a function are, you don't have to tell it. When you 'call' the function the arguments are checked against what is required. You do not *have* to specify types of arguments or results anywhere (a lot of people do consider it a good practice to specify them). Strong static typing does not necessitate type annotations (except at the time of their creation I suppose) -- and I have no idea how, in practice, this is distinguishable from a strong dynamic language in any sense that could matter. > > With this in mind, the arguments in whyDynamicTyping.html about static > typing leading to stiff, rigid code seems to be refuted. I'd love to > play around with these issues to see for myself. > It isn't that strong static typing makes code rigid, it is bad realisations of strong static typing that does. Eiffel, even without type inferencing, is remarkably flexible compared to Java or C++ (though not what Haskell or ML achieves). If you want to have some real mind bending fun, check out Haskell or Clean. Cheers, Bob