• Mniot@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    But this was arbitrary. It’s not like “why are there only 16 colors on this video game” (because of space constraints). They could have made it 257 users and nothing would overflow. Given that, I think they should have made a human-comfortable number (multiple of 10) instead of a machine-comfortable number (power of 2).

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      0
      ·
      1 year ago

      Dev here. Just because CPUs don’t directly use 8 bit numbers anymore doesn’t magically mean 257 wouldn’t overflow. If you’re storing the 8 bits in part of something else that’s 32 or 64 bits (or whatever), like maybe the ID of the chat, then you only have 8 bits. A lot of time this comes down to making compact data representations of things to make uploads/downloads quicker. JSON is the most popular data format to transfer data in (probably), but other more compact binary formats like Avro, Protobuf, and even application specific custom formats exist.

    • chonglibloodsport@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      It’s only arbitrary if you ignore the history of computing and the eventual settling on a standard of 8-bit bytes as the smallest addressable value in most programming languages and operating system libraries (though not always addressable in hardware).

      Unless you’re making the very meta claim that it was arbitrary for us to settle on 8 bits instead of 10 or something. I think there are a lot of technical merits to 8 bit bytes (being a power of 2 is nice and 4 bits is just too small).

      • Tja@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Yes, but this is not a historical piece of code, it is a 21 century app. I very much doubt they are using a uint8 to represent the array size, it’s probably a 64 bit int. They might as well have used 300 or 250, or 1000.

        • chonglibloodsport@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          WhatsApp’s back-end is written in Erlang. Erlang is a very old language with weird limitations. For one thing, it doesn’t have different machine-sized (16, 32, 64 bit) integers the way C does. Arbitrary-precision integers are the only primitive integer type. This makes it quite a slow type to use for something like a group chat member ID.

          However Erlang also has a type called a binary which is used for space-efficient storage of binary data (along with primitive operations on bits). These types are stored as sequences of bytes. I’m guessing this is how WhatsApp does group chat IDs, which would make the 256 user limit perfectly understandable (keep every ID contained within a byte).

          • Tja@programming.dev
            link
            fedilink
            arrow-up
            0
            ·
            1 year ago

            I don’t think every user would have an ID in the chat of 1 byte, that would be a nightmare when leaving and joining the group, reusing IDs, etc… each user needs to be identified with its uuid (or whatever else they chose).

            Using a 32 at 64 bit size and limiting the value makes much more sense, any subsequent changes would be a config tweak instead of a major refactor. I would guess the limit was a fun “Easter egg” type of thing rathar than a hard technical limit.

            • chonglibloodsport@lemmy.world
              link
              fedilink
              arrow-up
              0
              ·
              edit-2
              1 year ago

              WhatsApp has billions of users. Scaling to that level and maintaining perfect real-time chatting with arbitrary user-created groups is not trivial. Storing 64 bit UUIDs for every single message and other interaction in a group chat would be inefficient, not to mention unidiomatic in Erlang (due to previously-mentioned lack of machine-sized integers).

              The use-case of a group having <256 current users but >256 historical users and the desire to scroll back and read very old messages of people who left the group is very uncommon. It makes perfect sense to put a situation like that on a slow path while optimizing for the common case of <256 chatting right now.

  • JillSteinsPuckeredAnus@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    24 days ago

    Unless the programmer specifcally coded the person count with an option base 0, the actual limit would likely be 255. A uint8 ranges from 0 to 255. When “one” person in the group chat, the programmer would likely count naturally, and set the variable’s value to 1, not 0.

    • crandall@lemmy.today
      link
      fedilink
      arrow-up
      0
      ·
      24 days ago

      Perhaps there’s no need to represent zero, since any chat would have at least one person in it? Maybe not true, I don’t know how WhatsApp works.

      • gens@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        1 year ago

        Isn’t that like Amdahls law, where you don’t ask a question but say something wrong on the internet?

        • FlihpFlorp@piefed.zip
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 year ago

          No you’re thinking of Murphys Law, where the number of transistors in a circuit doubles roughly every two years

          • lime!@feddit.nu
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 year ago

            no you’re thinking of Sturgeon’s law, where you can replace all resistors and capacitors in a circuit with a big one of each of the same total value

              • djvinniev77@lemmy.ca
                link
                fedilink
                arrow-up
                0
                ·
                1 year ago

                I think you’re thinking of Cole’s Law, where you are only allowed to include up to 5 citations in your report out of Cole’s Notes. Also word salad.

    • unmagical@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      1 year ago

      Pretty sure the “Yikes” was because the number was obviously not arbitrary and the tech reporter didn’t know that.

      If it were truly an arbitrary number it likely wouldn’t warrant a “yikes.”

      • 🔍🦘🛎@lemmy.world
        link
        fedilink
        English
        arrow-up
        0
        ·
        1 year ago

        …what? Lol

        Say the chat size increased to 317. Why would the tech writer say “yikes”? Just because it’s not divisible by 5 or 10?

        • chaogomu@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          1 year ago

          The tech writer didn’t say yikes. The first person to post it did, then someone else reposted while keeping the original poster’s reaction.

          • 🔍🦘🛎@lemmy.world
            link
            fedilink
            English
            arrow-up
            0
            ·
            1 year ago

            Ah yeah I see that now. Still a bizarre reaction from the randim tumblr user, but that’s just typical tumblr stuff.

            • Ajen@sh.itjust.works
              link
              fedilink
              arrow-up
              0
              ·
              1 year ago

              I had the same reaction, because someone who doesn’t understand the significance of the number 256 isn’t qualified to be a tech journalist.