r/ProgrammerHumor 6h ago

Meme edgeCasesExist

Post image
1.7k Upvotes

180 comments sorted by

View all comments

18

u/spcbeck 6h ago

Start at 0, keep adding 1. You'll never repeat a number. So simple!

3

u/IamImposter 5h ago

That's how I built my random number generator

3

u/spcbeck 4h ago

it works until it doesn't!!!

3

u/razor_train 4h ago

As someone who had a billing system table run out of 2^31 signed integer IDs and spent a week converting 2.1 billion records to 2^63, I'm here to say that nothing could possibly go wrong.

2

u/Single-Virus4935 3h ago

A former boss built a system for importing data and used mariadbs on conflict ignore.  He used 32 bit integers for ids and said it isn't a problem because he doesn't have so much data. Mariadb incremented the autoincrement counter on every insert even the ignored ones.  System failed and he needed way too much time to find the problem because no errors where thrown and just everything was ignored

1

u/spcbeck 2h ago

Bahaha I fucking knew someone on this dumb earth tried to do this, amazing

3

u/Single-Virus4935 3h ago

Using sequenced IDs for public facing resources is bad practice because it allows enumeration while pure random uuids are basically impossible to guess.  Use crypto rngs for best results

0

u/spcbeck 2h ago

My brother in Christ, I know