1. 3

    I want to hear more about the kinds of tricks that would be hard or impossible to replicate in static type systems

    There is nothing “impossible to replicate” and what is “hard to replicate” is usually not hard in other statically typed languages and just as hard in other dynamically typed languages. For the example with subclasshook, how would you do that in Javascript? And the statically typed C++ can probably replicate your CoordinateAbc via template instantiation. I use “probably” because I’m not quite sure what you are trying to achieve in this example.

    For further inspiration, I can recommend Rob Harper:

    To borrow an apt description from Dana Scott, the so-called untyped (that is “dynamically typed”) languages are, in fact, unityped. Rather than have a variety of types from which to choose, there is but one!

    And this is precisely what is wrong with dynamically typed languages: rather than affording the freedom to ignore types, they instead impose the bondage of restricting attention to a single type!

    1. 1

      There is nothing “impossible to replicate” and what is “hard to replicate” is usually not hard in other statically typed languages and just as hard in other dynamically typed languages.

      That’s quitter talk.

      Okay, more seriously, what I’m trying to do is find examples of what makes dynamic types interesting. Saying the equivalent of “nothing” is like saying “there’s nothing functional programming gives you that OOP doesn’t”: regardless of whether it’s true or not, it doesn’t give us anything to work with. It doesn’t give us anything worth investigating.

      Also, I’d be absolutely shocked if dynamic typing provided nothing aside from “unityping”. Especially given that (anecdotally) there’s a huge amount of research into making better static type systems and there’s almost no research in dynamic typing. I don’t want to write off something we haven’t even explored.

      1. 1

        The example is essentially trying to write a typeclass instance like

        instance (HasLength a, HasAdd a) => CoordinateAbc a
        
        1. 1

          Correct me if I’m wrong, but don’t you have to explicitly declare the typeclass on a? With __subclasshook__ isinstance(a, Abc) even if we don’t say that a inherits from Abc at definition, or if a is declared without an add method but it’s dynamically added at runtime.