15 Nov 2001 chalst   » (Master)

Dynamic vs. static typing: Unusually long time to respond to a diary entry -- graydon posted an argument for the superiority of statically typed systems over dynamically typed system back in March. He points out that with type inference one of the usual complaints about type declarations vanish, and indeed one must tell the computer less about types than one must with dynamically typed systems.

I'm not convinced though:

  • One can perform type inference in dynamically typed languages just as well as for statically typed languages; the difference is that user code is not treated as incorrect if it cannot be assigned one correct type. Most code is type correct, but there are situations where one needs dynamic types: supporting dynamic dispatch on method invocation being the most important.
  • The core of Haskell's type system: Hindley-Milner polymorphism plus recursive types, is indeed an elegant system in which one can write a lot of nontrivial code. Not enough, though, and so Haskell supports type classes, an extension needed for the way it integrates IO into its lazy execution mechanism, in the presence of which one loses principal types (ie. the existence of context-independent `best' types for program fragments), and so one finds some puzzling peculiairities in the type system. One also loses the ability to perform separate compilation, rather undermining the arguments for the superior compilation performance of Haskell over dynamically typed languages.
  • I'm also struck by the stability of the set of types one has in scheme, compared to the constant calls for extensions to the type system faced in statically typed languages. From a theoretical point of view, I am struck by the ease with which one can model dependent types in dynamically typed languages, a useful-to-programmers type abstraction that cannot by statically type checked. I think it is plausible that scheme's type system is `theoretically complete', ie. there is no need to extend the underlying language to support the types that its programmers need.

I finally posted this entry after reading Kent Pitman's second set of interview responses on slashdot: his comments to question 14 are relevant here.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!