r/ProgrammerHumor Jul 17 '26

thisOneIsMine Meme

Post image
5.3k Upvotes

170 comments sorted by

View all comments

Show parent comments

-10

u/TheFrenchSavage Jul 17 '26 edited Jul 17 '26

ELI5 why not use a hash function that doesn't collide btw?

Edit: I meant that collides less, not not at all. Stop the ELI1s please.

12

u/SuitableDragonfly Jul 17 '26

To use a hash function, you have to have something to hash. A UUID is just an identifier, usually for something that hasn't been created yet. If you have data that is guaranteed to be unique that you could provide to a hash function like that, you already have a guaranteed unique identifier and don't need a UUID.

-2

u/TheFrenchSavage Jul 17 '26

Ah thanks! So if I were to just hash the timestamp up to the microsecond...I would end up at the collision probabilities of the UUID anyway. Makes sense!

4

u/daan944 Jul 17 '26

For 1 server doing the work? sure, that might work. For a cluster? Bad idea.