News for hackers. Stuff that matters.
Re:TIL: Versions of UUID and when to use them by efilife on Sunday August 25, 2024 @05:44PM (#41351729)
Uuid 4 is just a random bytes generator that inserts hyphens in specified places. You don't need to use it, you can just generate random bytes yourself and save on space (unnecessary hyphens, version info and so on)
Re:TIL: Versions of UUID and when to use them by wongarsu on Sunday August 25, 2024 @06:41PM (#41352162)
UUID 4 also sets 4 bits to fixed values to indicate it's version 4. You can argue whether creating different namespaces between the different methods of creating UUIDs is useful. But your plain random number generator has only a 1/16 chance of generating a valid UUIDv4. (setting the bits correctly is however trivial if you do want to roll your own uuid generator)
Re:TIL: Versions of UUID and when to use them by badindentation on Sunday August 25, 2024 @07:53PM (#41352610)
From reading wikipedia it seems it's less than that since the 4th group also uses bit to set the variant.

e.g.

XXXXXXXX-XXXX-4XXX-[89AB]XXX-XXXXXXXX

From looking at all the ones in my system.

Re:TIL: Versions of UUID and when to use them by edflsafoiewq on Monday August 26, 2024 @03:08AM (#41354708)
Each method is designed so two IDs both generated with that method don't collide with each other. Reserving bits for the method avoids the problem of having to also ensure that for all pair-wise combinations of methods, two IDs generated with those methods don't collide. This is also why there is only a finite set of universally agreed upon methods.
Re:TIL: Versions of UUID and when to use them by Lammy on Sunday August 25, 2024 @05:57PM (#41351823)
UUIDs are 128-bit numbers and the hyphenated-string representation is only one of many ways to represent that number, sort of like how an IPv4 address is a 32-bit number of which the “dotted-quad” is only one representation. If you are thinking of UUID as a string format then your most fundamental concept of UUID is flawed.

Even if you do just want a random identifier (not really the original point of UUID but has become their most popular form) I still think it's cool how random UUIDs have a little flag bit to tell you that it's intended to be random. Useful when one runs across a lone identifier with zero context.

Re:TIL: Versions of UUID and when to use them by sweca on Sunday August 25, 2024 @05:53PM (#41351785)
True but the appeal for most developers is it's simple to implement. Virtually every language has a UUID library that works in one line or code.

Like in Go, it's just uuid.New().String() vs using crypto/rand to read random data, convert it into Base64 of hex... which will take more lines and effort.

Re:TIL: Versions of UUID and when to use them by lopkeny12ko on Sunday August 25, 2024 @06:04PM (#41351886)
This is an unfair argument. Which standard library in Go gives you uuid.New().String()? Anyone can publish a third party library that condenses reading random data, creating an identifier from it, and rendering it as a string into a single line of code API.
Re:TIL: Versions of UUID and when to use them by sweca on Sunday August 25, 2024 @07:31PM (#41352481)
No, it's not a standard library, but my point is UUID is standard and thus present in almost every language with a one line abstraction.
Re:TIL: Versions of UUID and when to use them by bigiain on Sunday August 25, 2024 @10:38PM (#41353527)
> Anyone can publish a third party library

I propose leftpad.js