• spongebue@lemmy.world
    link
    fedilink
    English
    arrow-up
    39
    arrow-down
    1
    ·
    10 days ago

    So, I get that 256 is a base 2 number. But we’re not running 8-bit servers or whatever here (and yes, I understand that’s not what 8-bit generally refers to). Is there some kind of technical limitation I’m not thinking of where 257 would be any more difficult to implement, or really is it just that 256 has a special place in someone’s heart because it’s a base 2 number?

    • AbsolutelyNotAVelociraptor@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      57
      arrow-down
      1
      ·
      10 days ago

      Because 256 is exactly one byte. If you want to add a 257th member, you need a whole second byte just for that one person. That’s a waste of memory, unless you want to go to the 64k barrier of users per chat.

      • Zagorath@aussie.zone
        link
        fedilink
        English
        arrow-up
        25
        arrow-down
        10
        ·
        10 days ago

        Except that they’re almost certainly just using int, which is almost certainly at least 32 bits.

        256 is chosen because the people writing the code are programmers. And just like regular people like multiples of 10, programmers like powers of 2. They feel like nice round numbers.

        • Lodespawn@aussie.zone
          link
          fedilink
          English
          arrow-up
          22
          ·
          10 days ago

          It’ll have to do with packet headers, 8 bits is a lot for an instant message packet header.

        • ViatorOmnium@piefed.social
          link
          fedilink
          English
          arrow-up
          12
          arrow-down
          2
          ·
          10 days ago

          For high volume wire formats using uint8 instead of uint32 can make a huge difference when considering the big picture. Not everyone is working on bootcamp level software.

        • jaybone@lemmy.zip
          link
          fedilink
          English
          arrow-up
          5
          ·
          10 days ago

          It’s not that they “like it”. It’s ultimately a hardware limitation. Of course we can have 64 bit integers, or however many bits. It’s an appealing optimization.

      • spongebue@lemmy.world
        link
        fedilink
        English
        arrow-up
        6
        arrow-down
        2
        ·
        10 days ago

        If each user is assigned a number as to where they’re placed in the group, I guess. But what happens when people are added and removed? If #145 leaves a full group, does #146 and beyond get decremented to make room for the new #256? (or #255 if zero-indexed). It just doesn’t seem like something you’d actually see in code not designed by a first semester CS student.

        Also, more importantly, memory is cheap AF now 🤷‍♂️

        • morphballganon@lemmynsfw.com
          link
          fedilink
          English
          arrow-up
          6
          arrow-down
          1
          ·
          10 days ago

          There would be no need to decrement later people because they’re definitely referred to using pointers. You’d just need to update the previous person’s pointer to the new next person.

          • spongebue@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            10 days ago

            If it’s a numeric ID (0-255) assigned to each person in the group, you’d either need to decrement later people or assign based on some kind of lowest available method, in which case you’d get kinda funny UX when new-member-Jerry can be #3 on the list because he’s taking over for old-member-Gerry, or he can be #255 because that’s the last spot.

            If we’re talking about pointers, I assume you mean a collection with up to 256 of them. In which case, there are plenty of collection data structures out there that wouldn’t really have a hard limit (and if you go with a basic array, wouldn’t that have a size limit of far more than 256 natively on pretty much any language?)

        • ViatorOmnium@piefed.social
          link
          fedilink
          English
          arrow-up
          3
          ·
          10 days ago

          Memory and network stop being cheap AF when you multiply it by a billion users. And Whatsapp is a mobile app that’s expected to work on the crappiest of networks and connections.

          • spongebue@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            9 days ago

            It is also used to transmit data including video. I don’t think an additional byte is noticeable on that kind of scale

    • mEEGal@lemmy.world
      link
      fedilink
      English
      arrow-up
      14
      ·
      10 days ago

      when writing somewhat low-level code, you always make assumptions about things. in this case, they chose to manage 256 entries in some array; the bound used to be lower.

      but implicitly there’s a tradeoff, probably memory / CPU utilisation in the server.

      it’s always about the tradeoff between what the users want, what is easier for you to maintain, what your infrastructure can provide, etc.

    • SparroHawc@lemmy.zip
      link
      fedilink
      English
      arrow-up
      10
      ·
      10 days ago

      There’s often a lot of fun cheats you can use - bitwise operators, etc - if your numbers are small powers of two.

      Also it’s easier to organize memory, if you’re doing funky memory management tricks, if the memory you’re allocating fits nicely into the blocks available to you which are always in powers of two.

      They’re not necessarily great reasons if you’re using a language with sufficient abstraction, but it’s still easier in most instances to use powers of two anyways if you’re getting into the guts of things.

    • jaaake@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      10 days ago

      The issue isn’t storing each individual ID, it’s all of the networking operations that are done and total things that are stored/cached per user in each chat. All of those things are handled and stored as efficiently as possible. Sure they could set it to any number, but 256 is a nice round one when considering everything that is happening and the use cases involved. They have user research data and probably see that 128 is too close to a group size that happens with some regularity, but group sizes very rarely get close to 256, and 512 is right out.