• JackbyDev
    link
    fedilink
    English
    31 year ago

    Can you give any examples of such “otherwise valid programs”? Because a lot of times static typing also has ways to do everything dynamic typing can but it is just more difficult or (obviously) won’t have the benefits of static typing.

    • @zygo_histo_morpheus@programming.dev
      link
      fedilink
      English
      11 year ago

      I think the way some dynamically typed languages use maps is interesting. In most languages if you have a hashmap, all values have to have the same type. In a dynamic language you can have some members be methods, some members be values of potentially different types and so on. Of course, depending on what you want to achieve, you might be able to use a struct for example. A map is more flexible though. You can union two different maps, or you can have a function that takes a map that has either a or b. It’s not necessarily impossible to express this in static types either, but there are many things here that quickly become tedious to do with types that Just Work in dynamically typed languages.