• FishFace@piefed.social
    link
    fedilink
    English
    arrow-up
    3
    ·
    12 hours ago

    A language’s deficiencies are rarely obvious when everyone is writing it perfectly.

    But a coherent type system gives the programmer confidence - for free. Do you know what [1] + [2] is in JavaScript? Do you know what type it is? JavaScript teaches you that it has operator overloading for built-in types but then it behaves in such a dumb way you can’t use it.

    That’s explained by a desire to be extremely lenient, but it’s not justified by it. Programming langauges are generally not made by idiots, so every bad decision has an explanation.

    • hperrin@lemmy.ca
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 hours ago

      I would assume [1] + [2] would give you either 0 or 2, but maybe "12". But why you ever write that? I’ve never bothered to memorize what happens there because I would never write that. The plus operator is not for arrays. It’s for numbers and strings. If you’re trying to concatenate arrays, there’s a function for that. Would you do that in Java or C? People trying to make JavaScript do silly things just because it refuses to crash when you do then calling the language bad for it is just silly to me.