I don't think it is impossible to begin adding type inference and stronger typing to clojure or any fully dynamic language.
You could begin with a set of runtime tests (such as range of a given number or what keys are in a dictionary). These tests allow you to go from an untyped world to a typed world, essentially saying if it passes test X then it fullfills the contract for type Y. Next you can run all the type inference you want within sections of your code. Where types can be inferred they are and where they can't be runtime tests are used to ensure they match what one would expect. In short, I think that it is theoretically possible to add partial static typing (Hindley-Milner if you desire) to any fully dynamic language. I also think that it is possible, using this system of an extensible type system, to allow eiffel style contracts to be partially checked at compile time and partially checked at runtime thus getting you the benefits of contract based programming without typing your fingers to the bone writing asserts and programming in tedious, error prone ways that a machine should be able to generate. There is significant overhead to learning to use any sort of type inference as the errors you get are quite mystifying at first. In any case, people have built very large, long lived, performant, and stable systems with dynamic languages. They have built these systems just as quickly as people building systems with statically (and strongly) typed languages and in a lot of cases quicker. I don't think anyone has ever proved that a type system drastically increases productivity for experienced programmers, regardless of the types of bugs it finds. So it seems ridiculous to me, in a practical sense, to force a given type system for every line of code in a program. I think that it is also damn useful to have the compiler catch a lot of problems. I personally love working in F# and think C# is a joke in terms of amount of code you have to write to get something done. I don't think that very much of what Jon said was irrelevant or FUD, and I don't think that even though emotions are high on this subject that the proponents of fully dynamic typing are spewing a bunch of nonsense either. Lets take this discussion forward and think of how we could incrementally add the important benefits of strongly typed and inferred systems like ML, Haskell, and F# to Clojure while keeping the very beautiful and clean syntax and minimal mental overhead of using a LISP derivative. Chris On Mar 11, 2:12 pm, Jon Harrop <j...@ffconsultancy.com> wrote: > On Wednesday 11 March 2009 18:35:46 Cosmin Stejerean wrote: > > > On Wed, Mar 11, 2009 at 1:03 PM, Jon Harrop <j...@ffconsultancy.com> wrote: > > > Another red herring: you are describing a disadvantage of nominal over > > > structural typing. Not dynamic vs static typing. > > > You are correct, my apologies. I was trying to show an example of > > situations where what I know and what the compiler wants is different, but > > as you pointed out my example is only valid in the case of a nominal type > > system. > > No problem. > > The most commonly cited examples in academia are the fix point combinator and > polymorphically recursive functions, neither of which type directly in the > Hindley-Milner type system that today's statically-typed FPLs are almost all > based upon. However, not only do both OCaml and Haskell handle those examples > fine but the examples themselves are of little practical relevance. > > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd.http://www.ffconsultancy.com/?e --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---