Thirty years later, JavaScript is the glue that holds the interactive web together, warts and all.

  • The_Decryptor@aussie.zone
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 day ago

    The entire number and math system is just a straightforward implementation of IEEE 754.

    Yeah, but using doubles for everything is its own downsides e.g. it’s why JSON “can’t” store 64bit integers for starters.

    They did add the BigInt class recently, which annoyingly you can’t use with JSON because it requires specialized handling (Because of the aforementioned issue with JSON).

    (So you “can” store 64bit integers in JSON, the spec just says not to, so people just ignore the spec. You just then run into silent truncation issues with clients that do follow it, like browsers.)

    • ThirdConsul@lemmy.ml
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      1 day ago

      Safe json handling requires that all properties are stringified anyway and you cast them to their correct types (because json sucks and you can never tell what someone will put in there anyway).

      • The_Decryptor@aussie.zone
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        17 hours ago

        Yeah, I actually really don’t like JSON. It looks simple but actually isn’t, that’s a bad combo.

        CBOR is much nicer, but annoyingly they made their human readable debug version of it similar enough to JSON that people assume it’s just a binary form of JSON, it isn’t.

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

      Yeah, I completely agree. It’s straightforward, but it’s got a lot of downsides. Everything always takes eight bytes. Even if you’re just storing 0 or 1.

      It makes handling numbers a lot simpler in most cases, though, and simplicity was the goal of JavaScript. I just wish there was a better solution than typed arrays.