46 ms·
The following isn't a serious contribution to the discussion, but somehow this reminds me of the people in Hitchhiker's Guide to the Galaxy unable to invent the
by bloak 3y ago
The following isn't a serious contribution to the discussion, but somehow this reminds me of the people in Hitchhiker's Guide to the Galaxy unable to invent the wheel because they can't decide what colour to make it. Personally I just generate a reasonable number of random bits, encode them in a reasonably efficient manner, and move on to something more interesting. By ignoring "standards" I make my UUIDs just that little bit more "unique"!
- lbriner 3y agoI don't understand this statement. UUIDs rarely have to be unique compared to every other place in the world where they are used, they just need to be unique within the same context. The reason for using NIC addresses and time is to ensure that the chance of a collision is really small (but not 0). Saying that you are making them a little more unique doesn't sound like good motivation. The second part is that just using random numbers gives you no real guarantees of uniqueness since without seeding with time and NIC, it would be highly likely that multiple systems around the world would generate the same number.
- ademarre 3y ago> it would be highly likely that multiple systems around the world would generate the same number. "Highly likely"? No. You are ignoring probability. See UUIDv4, which does not use time or NIC/MAC but does use 122 random bits.
- dugmartin 3y agoIn another comment I mentioned I use nanoid in my projects now. It has a default space of 64^21 and has an a page where you can play with key lengths and alphabet sizes and see the probability of collisions : https://zelark.github.io/nano-id-cc/ https://zelark.github.io/nano-id-cc/ At the default 64 character alphabet with a 21 character key length it would take ~41 million years in order to have a 1% probability of at least one collision if you generated 1000 ids per second.