r/programminghorror • • Mar 23 '24

🤦

Post image

[removed] — view removed post

733 Upvotes

58 comments sorted by

296

u/CleverDad Mar 23 '24 edited Mar 23 '24

Two immediate thoughts on this:

  1. If you don't recognize the significance of 28 in a software context you have totally outed youself as clueless (OP's point), but also

  2. It's pretty weird to let any aspect of modern software be limited by the range of an unsigned byte. I mean, who even uses those anymore?

26

u/PrinceEntree8 Mar 23 '24

Indeed, as a software engineer I wonder how the WhatsApp database is structured.

I guess it all started with a ā€œgroupā€ table that stored members in a column-based format o something similar.

As today standards I would create a mapping table between users and groups ids with additional data like permissions or roles.

I don’t think that Meta has ever wrote a tech blog post about their database structure of Whatsapp

10

u/Wall_Hammer Mar 23 '24

5

u/PrinceEntree8 Mar 23 '24

Interesting, but it doesn’t seem to describe the database structure neither the database stack…

120

u/NoahZhyte Mar 23 '24

I'm pretty sure it's an arbitrary number choose by a developer that like number which are power of 2 and it could be more without any impact on the database

6

u/laaazlo Mar 23 '24

Yep, just like when I allocate memory for a container. Does it need to be a power of two? No, but if feels weird to me if it isn't

28

u/Skrynesaver Mar 23 '24

I tend towards high blood pressure and so I've a monitor, prior to my last visit to ER I discovered that my monitor uses an 8 bit int - this was not good 😊

16

u/mrheosuper Mar 23 '24

I too hate it when i have negative blood pressure.

6

u/Bacon_Techie Mar 23 '24

In this case it would go back around to 0 since it is unsigned

14

u/pawcafe Mar 23 '24

i think devs just like those numbers

22

u/CleverDad Mar 23 '24

I'm a dev myself and I reluctantly must agree this is plausible.

7

u/ZhouNeedEVERYBarony Mar 23 '24

It's not necessarily the range of an unsigned byte; it could also be 32 bytes treated as bitflags, or something like that, where each participant has an index and the bit is flipped if they've read a certain message. Since you'd rarely need to query for "which messages has X user read in this thread", and frequently need to query for "which users in this thread have read X message", that would make for a pretty dense representation.

2

u/z0d007 Mar 23 '24

Ones and zeros still power everything. It may look miles ahead from the 90s but underneath the hood even on modern software, you still want to optimise as much as possible. It may seem insignificant but it very well could be a limit decided after months of research and testing. They may have limitations based on their architecture and environment.

2

u/ICantBelieveItsNotEC Mar 24 '24

It's pretty weird to let any aspect of modern software be limited by the range of an unsigned byte. I mean, who even uses those anymore?

It might be something to do with end-to-end encryption. WhatsApp uses asynchronous ratcheting trees for group chats. ARTs use a binary tree and their worst-case performance is proportional to tree depth, so it makes sense for the group size limit to be a power of two - the tree is going to have 8 layers for any group size greater than 128, so you might as well allow the tree to be complete. As for why they picked 256 instead of 512, it's probably the largest group size that performs reasonably well on the oldest/shittiest phones they support.

-6

u/a45ed6cs7s Mar 23 '24

Wonders of DEI hiring. They are clueless most of the time.

2

u/laaazlo Mar 23 '24

"they" meaning whom?

6

u/AaTube Mar 23 '24

Note that this is the wrong subreddit

1

u/PrinceEntree8 Mar 23 '24

Which one do you suggest?

2

u/AaTube Mar 24 '24

2

u/PrinceEntree8 Mar 24 '24

You are definitely right

16

u/wind_dude Mar 23 '24

What’s next 512 or will they jump to 1024 next?

7

u/Sploffo Mar 23 '24

Probably 65535 as using 5 or 6 bits to represent a number is pretty unusual (and sounds like a pain in the ass with very few to no upsides)

16

u/Theolaa Mar 23 '24

Did anyone consider that they did that tagline on purpose to drive this kind of engagement?

3

u/apheax Mar 23 '24

255 has entered the chat

1

u/DanishNinja Mar 23 '24

Tech <> Software development

0

u/AutoModerator Mar 23 '24

This post was automatically removed due to receiving 5 or more reports. Please contact the moderation team if you believe this action was in error.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-13

u/[deleted] Mar 23 '24

256 is a wrong "specific" number tho. 0-255 is the ubyte limit. We all write 256 because its a number of variants byte can have, which is wrong to have as a limit of something.

23

u/[deleted] Mar 23 '24

No, if you have the 0th person be in the group, you should be able to have 0-255 people making the total number 256.

3

u/echo-whoami Mar 23 '24

You are also clueless

-32

u/mistrzegiptu Mar 23 '24

Actually it's kinda weird since 8 bit variable has range from 0 to 255

50

u/ShadauxCat Mar 23 '24

Which is 256 total values.

-26

u/mistrzegiptu Mar 23 '24

Sure, if you treat 0 as 1, but what about empty group then? Also it could lead to some overflows

6

u/PrinceEntree8 Mar 23 '24

Since a the creator doesn’t count I suppose they have 256 members actually.

Once there was the counter and if you are the creator and admin of a group without anyone it showed ā€œmembers 0/255ā€.

I think that a group with 0 members (including no creator) is set to ā€œnullā€ indicating that the group has been closed since no one would be able to join anymore.

1

u/mistrzegiptu Mar 23 '24

That makes more sense, but 256 members + admin overflows 8 bit unsigned variable, so I still think there is no point setting limit to 256

17

u/x1rom Mar 23 '24

Are empty groups even possible?

1

u/mistrzegiptu Mar 23 '24

If everyone leaves group chat I think it's still stored in your history, so technically it's possible

4

u/All_Up_Ons Mar 23 '24

It's 256 total values regardless. 00000000 through 11111111. It doesn't matter how you think about it. An 8-bit integer has 256 possible values.

1

u/ShadauxCat Mar 23 '24

Who says the number is being used as a counter? It could be indexes into an array. It could be IDs for the users within the group. A flat "number of users in chat" is not architecturally that useful.

0

u/scorpi1998 Mar 23 '24

I don't see why this is getting disliked. A 1-bit number also has two possible values, but can only track up to 1 person.

5

u/Trade_econ_ho Mar 23 '24

How do you have a group chat consisting of 0 people

1

u/Sereczeq Mar 23 '24

Going with this logic, you also cannot have a group of:

  • 1 person, since that's chat with yourself not a group

  • 2 people, since that's just normal chat

So actually with this logic, the group would start at 3 ppl, so value 0 would be 3 ppl and value 255 would be 258 ppl.

Doesn't make sense.

You should never have 0 mean anything else than 0

2

u/Trade_econ_ho Mar 23 '24

A chat with yourself is a group of size 1.

1

u/Sereczeq Mar 24 '24

No it's not. Groups have plenty of features that normal chats don't have and vice versa. Group is a completely separate functionality to a chat

-1

u/scorpi1998 Mar 23 '24

Would you really write software relying on the number of people in a group to never ever be 0?

3

u/Trade_econ_ho Mar 23 '24

Yes. If the number of people is 0 then the chat doesn’t exist

2

u/scorpi1998 Mar 23 '24

Yes? Can you ensure me that Whatsapp deletes a group as soon as there are no members left? Do you work there?

1

u/Trade_econ_ho Mar 23 '24

Yes. Yes. No.

1

u/scorpi1998 Mar 23 '24

And how can you ensure that then?

→ More replies (0)

2

u/HyScript7 Mar 23 '24 edited Mar 23 '24

Yes, because if there is no one in a group, no one can add anyone, cause no one is in the group, so yes, I am pretty confident having a group of size 0 is impossible, and if it's possible, utterly useless, cause then we can just delete it to save space. I mean they're basically inaccessible messages at that point.

Edit: Also storing group chat members in an array of size 256 or as an integer is very stupid, so the limit was probably chosen at random by someone who likes numbers that are a power of 2 or maybe it's some limitation in their tech stack or something. Any sensible person would use an N:N relation in a relational table database to describe memberships of group chats, which by default does not enforce any limits. Maybe the query to retrieve how many people are in a group chat is stored in an 8 bit unsigned number, and they wanted to avoid either wasting some of those bits or allocating more than 8 bits for the member count? I'm probably overthinking now, so I'll hope someone else figures that out.

5

u/FunnyForWrongReason Mar 23 '24

Arrays start at index zero. The size limit is basically a limit on the size of a char array. Index 0-255 or 256 total value of 256 total characters.

-12

u/LotosProgramer Mar 23 '24

I mean it's kinda weird that it isn't 255 isn't it?

0

u/[deleted] Mar 23 '24

[deleted]

11

u/TheKiller36_real Mar 23 '24

I believe it was 250 prior to the change lol

47

u/[deleted] Mar 23 '24

[removed] — view removed comment

19

u/joshuakb2 Mar 23 '24

They already do! "Any sufficiently advanced technology is indistinguishable from magic"

6

u/All_Up_Ons Mar 23 '24

They already do in a lot of cases. Anyone younger than a zoomer was born with an iphone in their hands.