• jsomae@lemmy.ml
    link
    fedilink
    English
    arrow-up
    92
    ·
    7 days ago

    Shout out to Castlevania II, where you can hold anywhere from 0 to 256 laurels. Yes, you read that right – 256, not 255. I inspected RAM to double check. It’s a 16-bit word on an 8-bit system with a maximum value of 0x100. They could have used 8 bits instead of 16. But no, they really did choose this arbitrary number.

      • ouRKaoS@lemmy.today
        link
        fedilink
        English
        arrow-up
        1
        ·
        5 days ago

        Having made a few games back in the day, this isn’t something you add on purpose, this is something that you screwed up, are going to “fix later”, then realize it’s too much hassle to rewrite 45% of your code and you just raise the minimum spec requirements a bit to compensate.

      • jsomae@lemmy.ml
        link
        fedilink
        English
        arrow-up
        32
        ·
        7 days ago

        plausible, but my experience from dissecting these kinds of games is that they tend not to be as space efficient as you’d think they could be if they were the kaze emanuar type. The fact that they opted to have 257 distinct values for the laurels suggests to me that they weren’t prioritizing space efficiency.

        My best (wildly speculative) guess is that a designer, knowing 256 is a common limit, wasn’t thinking carefully and said the maximum value should be 256 (instead of 255), and then an overly pedantic coder implemented this to the letter while rolling their eyes.

        • chimp@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          13
          ·
          7 days ago

          Currently in the industry - it’s exactly this. It’s a communication issue between the programming team and other teams, where designers freely speak for design, artists freely speak for art, etc. but it’s much harder for programmers to speak for implementation since it’s usually in reference to somebody else’s work, and when designers get offended or defensive or dismissive of the non-designer requesting 256 be changed to 255, then it stops being worth it.

          For example, we made an absolutely mint UI backend, it was data driven with editors so anyone could whip up a new UI for the next feature without needing programmers. The design team were like “damn, I hear how complicated this thing was to build, so let’s make the programmers lives easier by not using it and only asking for simple bespoke stuff”. Telling them “the investment has already been paid for so please use it” was tantamount to telling them how to do their job while being ungrateful they had considered us, furthering the communication breakdown.

          Yes I’m bitter and tired. It’s easier to use a short for 256 instead of arguing to have my opinion considered

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

        Even if true, 256 would be a waste of the range. 255 would make sense if trying to stay in one byte, using a whole different data type to get one extra bit just to hold 256 instead of saying “screw it, let’s go to 511” even while using other bits.

        It’s just a very weird thing to do to pick 256 as a value limit back in those days (also oddly specific now, but for different reasons)

      • jsomae@lemmy.ml
        link
        fedilink
        English
        arrow-up
        4
        ·
        6 days ago

        the number of laurels in your inventory is stored as an integer from 0 to 256.

  • rarbg@lemmy.zip
    link
    fedilink
    English
    arrow-up
    59
    arrow-down
    1
    ·
    7 days ago

    A previous version of this article said it was “not clear why WhatsApp settled on the oddly specific number.” A number of readers have since noted that 256 is one of the most important numbers in computing, since it refers to the number of variations that can be represented by eight switches that have two positions - eight bits, or a byte.

    Lol, weird way to say that 256 is a power of two, and computers operate in base two.

    • JackbyDev@programming.dev
      link
      fedilink
      English
      arrow-up
      15
      ·
      6 days ago

      It’s a pretty succinct explanation that links what it is to something most people have heard of (a byte).

    • thisisnotgoingwell@programming.dev
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      6 days ago

      It used to be a way bigger deal when computers were very memory scarce, if you needed to say, represent 1024 values, that means you’d use 10 bits or 2 bytes, the remaining 6 bits could be used to store other related information like flags but more often than not it would be waste (unused values that still have to be represented as 0s)

      These numbers are pretty arbitrary nowadays but they still show up a lot in computing. They didn’t choose 256 so they could represent it in a byte, the real reason is probably that groups larger than 256 can’t realistically be managed by users.

      That’s my 2¢ anyways.

    • InternetCitizen2@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      1
      ·
      6 days ago

      Tbf saying it that way brings a visual metaphor. Simply giving it as a mathematical definition would leave it feeling just as arbitrary.

    • deltapi@lemmy.world
      link
      fedilink
      English
      arrow-up
      57
      arrow-down
      1
      ·
      7 days ago

      No, you can’t have a group of zero, so the counter doesn’t need to waste a position counting zero.

      • HereIAm@lemmy.world
        link
        fedilink
        English
        arrow-up
        12
        ·
        7 days ago

        If you ever create a system where the number of users is “group.members - 1” everywhere in the code, I’d be very disappointed in you and deny that PR.

        On another note; I doubt WhatsApp are so concerned with performance they are actually limiting the number of group members by the data type.

        • BillBurBaggins@lemmy.world
          link
          fedilink
          English
          arrow-up
          10
          ·
          7 days ago

          But it wouldn’t be like that though would it. It would be public group.members() and the u8 would be private.

          If all the millions of groups are saved on a central database then making the size a u8 isn’t really that weird

          • HereIAm@lemmy.world
            link
            fedilink
            English
            arrow-up
            3
            ·
            7 days ago

            I hadn’t thought about it on their server side tbf. But the more i think about it maybe there are other compounding reasons to keep group sizes small, such as the exponential number of links in a growing network and such. But, that is all beyond my knowledge area.

      • seejur@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        7 days ago

        You cannot also have a group of 1, therefore either is 255 or 257. 256 is oddly specific (or the code was made by an intern)

  • 18107@aussie.zone
    link
    fedilink
    English
    arrow-up
    57
    arrow-down
    6
    ·
    7 days ago

    In this case the limit was entirely arbitrary.

    The programmers were told to pick a limit and they liked 256. There are issues with having a large number of people in a group, but it wasn’t a hardware limit for this particular case.

  • tired_n_bored@lemmy.world
    link
    fedilink
    English
    arrow-up
    11
    ·
    6 days ago

    As a software engineer: actually there is no need for a number of people as a power of 2 unless you need exactly 1 byte to store such information which sounds ridiculous for the size of Whatsapp

    • NigelFrobisher@aussie.zone
      link
      fedilink
      English
      arrow-up
      3
      ·
      5 days ago

      It’d make sense at protocol level. Otherwise, yeah, even bit-size database columns end up being stored as a word unless the engine compacts it.

  • BilboBargains@lemmy.world
    link
    fedilink
    English
    arrow-up
    24
    arrow-down
    1
    ·
    6 days ago

    I remember being puzzled by this and many other numbers that kept cropping up. 32, 64, 128, 256, 1024, 2048… Why do programmers and electronic engineers hate round numbers? The other set of numbers that was mysterious was timber and sheet materials. They cut them to 1220 x 2440mm and thicknesses of 18 and 25mm. Are programmers and the timber merchants part of some diabolical conspiracy?

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

      32, 64, 128 etc. are all round numbers, counting in binary. They are powers of two. Since computers work in binary, they make logical sense.

      1220mm is 4ft, and 18 and 25mm are three-quarters of an inch, and an inch respectively.

      • Scubus@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        13
        ·
        6 days ago

        They were making a joke. That being said, im not familiar with lumber or imperial<->metric conversions so their second point was lost on me, so thanks.

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

        Pretty much this…

        Once upon a time, sure, you might have used an 8 bit char to store an array index and incur a 256 limit for actual reasons…

        But nowadays, you do it because 256 is a “cool techy limit”. Developers are almost all dealing with at least 32 bit values, and the actual constraints driving smaller values generally have nothing to do with some power of two limitation.

  • Synapse@lemmy.world
    link
    fedilink
    English
    arrow-up
    23
    arrow-down
    1
    ·
    edit-2
    7 days ago

    Still odd, I very much doubt they use a 8bit variable to set this limit. What would this bring ?

    • qaz@lemmy.world
      link
      fedilink
      English
      arrow-up
      7
      ·
      edit-2
      6 days ago

      When the program is running it’s probably stored with 32 or 64 bits, but that probably isn’t the case for the network packet layout. I can imagine them wanting to optimize network traffic with over 3 billion users even if it’s just a small improvement.

      Also TIL that Erlang’s VM apparently stores strings as linked lists of chars. Very strange.

      data representation of string 'phi'

  • Echo Dot@feddit.uk
    link
    fedilink
    English
    arrow-up
    13
    ·
    7 days ago

    That’s a super old article as well.

    They got rightfully roasted in the comments for not knowing even the most basic things about computing.

  • Mr. Satan@lemmy.zip
    link
    fedilink
    English
    arrow-up
    16
    ·
    edit-2
    7 days ago

    Wouldn’t max value for 8 bit (unsigned) integer be 255? Like the number has 256 distinct values, but that includes 0.

    • squaresinger@lemmy.world
      link
      fedilink
      English
      arrow-up
      32
      ·
      7 days ago

      If this is about a counter for users in the chat, sure. But if this is an array of users indexed by an 8-bit number, then it will fit 256 slots with the first slot being numbered 0.

      • khapyman@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        12
        ·
        7 days ago

        Not to be snarky, in programming there’s rarely (in situations like this) a reason to keep count. Computers are exceptionally good at counting integers so they’d just count individual client id’s (however they’ve implemented that system), not keeping toll on how many clients are in a group chat.

        So one client, be it at position zero is a one client group. Add another client at position one and you have two clients and a two person group.

        • Echo Dot@feddit.uk
          link
          fedilink
          English
          arrow-up
          2
          ·
          7 days ago

          I don’t think it’s the variable for counting the number of us in a group that’s the issue here. There’ll be some internal tracker that gives everyone in the chat group a local ID probably for the purposes of ensuring that everyone stays in sync.

          If you leave the group and then go into a different chat group you’ll probably have a different number in that group because the internal counter is specific to the chat, not to the user ID which will be a unique ID used across all interactions for that phone number.

    • Alaknár@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      7
      ·
      7 days ago

      You’re thinking of the highest integer number, not the “number of numbers” - which is 256, from 0 to 255, and thus 256 possible users in a group chat.

    • Echo Dot@feddit.uk
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 days ago

      Computers start counting at zero, (unless it’s python) so the first person in the group would be ID 0, the second person would be ID 1

  • ObsidianZed@lemmy.world
    link
    fedilink
    English
    arrow-up
    9
    ·
    7 days ago

    I remember thinking something similar when I was a kid modding Starcraft. Max levels/ranks in researching was 256 and I always wondered why such a weirdly specific number.

    • Krzd@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 days ago

      Depends on how they handle groups with 0 members, if they just get deleted once the last person leaves, you shouldn’t run into issues