• zygo_histo_morpheus
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    2
    ·
    1 year ago

    The main argument against strictly typed languages imo isn’t that types are time-consuming to write, it’s that they forbid some otherwise valid programs. When writing down your types you are forced to write down some of the assumptions you make about your data (which is usually a good thing) but all assumptions aren’t necessarily possible or ergonomic to express in your given programming languages type system.

    Overall I have a strong preference for statically typed languages as they (usually) make code more readable and help prevent prevent bugs, but it’s important to not strawman fans of dynamic types either!

    • JackbyDev
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 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
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 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.