Have to add that we work exclusively in strongly-typed languages. Kinda want to see how it plays out, but I can’t help but argue with him, so I think I’ll just go.

  • xmunk@sh.itjust.works
    link
    fedilink
    arrow-up
    7
    arrow-down
    10
    ·
    14 hours ago

    I recently tried out Python. I had no idea it still doesn’t have runtime enforced typing…

    I didn’t realize that PHP was decades ahead of it.

    • exuA
      link
      fedilink
      English
      arrow-up
      16
      arrow-down
      1
      ·
      8 hours ago

      Python is dynamically strong typed, meaning you don’t need to specify any types, but unlike JavaScript you can’t just use a string where an int was expected. In that sense it’s absolutely runtime enforced typing.

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        5 hours ago

        … and yet… it lacks clear and enforced type restrictions which help with clear code contracts. It’s certainly better than Javascript but the lack of runtime enforced type checking can force defensive programming in an unnecessary manner.

        Your statement isn’t strict type checking. It’s a restricted form of type coercion. Given how common this feature is in other languages it’s weird that pythonistas feel so defensive when discussing the feature. I enjoy strict type checking, but that’s my opinion - it makes it a poor choice for the sorts of projects I work on but if it’s good for you then enjoy!

    • Pyro@programming.dev
      link
      fedilink
      arrow-up
      19
      arrow-down
      1
      ·
      edit-2
      13 hours ago

      Python 3.x will never have static typing because that would break backwards compatibility.

      However, typing hints have been Integrated into Python for a while, and you are heavily recommended to use them, so your IDE can enforce typing.

      • xmunk@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        ·
        13 hours ago

        Considering there is typing in the code why is there no switch to enable type checking at runtime? PHP does this with a per file declare(strict_types) - why would python be unable to have either a global or per file flag to enable checks?

        • Pyro@programming.dev
          link
          fedilink
          arrow-up
          10
          ·
          13 hours ago

          Typing when you need it gives you more freedom over a toggle. You can choose to type some parts of the code while leaving other parts untyped.

          For example, if I’m writing a quick and simple Python script I may forgo typing, but when iterating on it I’d go back and add the types I need.

          • xmunk@sh.itjust.works
            link
            fedilink
            arrow-up
            4
            ·
            13 hours ago

            This isn’t an issue, though. PHP has the same partial typing flexibility. There are ways to solve that issue and even typed PHP still allows union types including mixed which allows any types.