• masterspace@lemmy.ca
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    6
    ·
    3 days ago

    Lol name one outside of it’s well known equality rules that linters check for.

    Also, name the language you think is better.

    Because for those of us who have coded in languages that are actually bad, hearing people complain about triple equals signs for the millionth time seems pretty lame.

    • tyler@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      1 day ago

      JavaScript only has a single number type, so 0.0 is the same as 0. Thus when you are sending a JS object as JSON, in certain situations it will literally change 0.0 to 0 for you and send that instead (same with any number that has a zero decimal). This will cause casting errors in other languages when they attempt to deserialize ints into doubles or floats.

        • tyler@programming.dev
          link
          fedilink
          arrow-up
          1
          arrow-down
          1
          ·
          edit-2
          22 hours ago

          JSON schema is not a standard lol. 😂 it especially isn’t a standard across languages. And it most definitely isn’t an ISO standard 🤣. JSON Data Interchange Format is a standard, but it wasn’t published until 2017, and it doesn’t say anything about 1.0 needs to auto cast to 1 (because that would be fucking idiotic). https://datatracker.ietf.org/doc/html/rfc8259

          JSON Schema does have a draft in the IETF right now, but JSON Schema isn’t a specification of the language, it’s for defining a schema for your code. https://datatracker.ietf.org/doc/draft-handrews-json-schema/

          Edit: and to add to that, JavaScript has a habit of declaring their dumb bugs as “it’s in the spec” years after the fact. Just because it’s in the spec doesn’t mean it’s not a bug and just because it’s in the spec doesn’t mean everywhere else is incorrect.

          • masterspace@lemmy.ca
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            22 hours ago

            Yes, it most literally and inarguably is:

            https://www.iso.org/standard/71616.html

            Page 3 of INTERNATIONAL STANDARD

            • ISO/IEC 21778 - Information technology — The JSON data interchange syntax

            8 Numbers A number is a sequence of decimal digits with no superfluous leading zero. It may have a preceding minus sign (U+002D). It may have a fractional part prefixed by a decimal point (U+002E). It may have an exponent, prefixed by e (U+0065) or E (U+0045) and optionally + (U+002B) or – (U+002D). The digits are the code points U+0030 through U+0039.

    • thedeadwalking4242@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      3 days ago

      Recently I encountered an issue with “casting”. I had a class “foo” and a class “bar” that extended class foo. I made a list of class “foo” and added “bar” objects to the list. But when I tried use objects from “foo” list and cast them to bar and attempted to use a “bar” member function I got a runtime error saying it didn’t exists maybe this was user error but it doesn’t align with what I come to expect from languages.

      I just feel like instead of slapping some silly abstraction on a language we should actually work on integrating a proper type safe language in its stead.

          • masterspace@lemmy.ca
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            1 day ago

            Because that object is of a type where that member may or may not exist. That is literally the exact same behaviour as Java or C#.

            If I cast or type check it to make sure it’s of type Bar rather than checking for the member explicitly it still works:

            And when I cast it to Foo it throws a compile time error, not a runtime error: