4 ms·
The great advantage of being standardized is that other people have thought about these issues and dealt with them in libraries. Yes there are many bad ways to
by lmm 11y ago
The great advantage of being standardized is that other people have thought about these issues and dealt with them in libraries. Yes there are many bad ways to generate them, but your library should offer the right way to generate them. Yes the string format is weird, but why would you write that by hand? Let the library print it, let the library parse it. Want to store it in a database? There's a column type for that. Want to send it over the network? There's probably a datatype for it in whatever protocol you're using (whereas with your approach you immediately have endianness issues).
- jovdg 11y agoI can't look-up the details right now, but we ran into some issues when we wanted to use system uuids (via dmidecode) to identify servers and pxeboot them. Apparently, HP server uuids are (subtly) different through dmidecode and via pxeboot... And it could be endianness actually - I did not check why it we different...
- jovdg 11y agoOK just found an experience from someone else: https://ocdnix.wordpress.com/2013/02/26/fuckin-uuids/ https://ocdnix.wordpress.com/2013/02/26/fuckin-uuids/
- TazeTSchnitzel 11y ago> The great advantage of being standardized is that other people have thought about these issues and dealt with them in libraries. Issues that don't exist if you don't use a hideously complex format like UUID in the first place. > Yes there are many bad ways to generate them, but your library should offer the right way to generate them. Yes, a UUID library will have a way to generate the random kind of UUID, but it's telling that you need a library for it. You can generate 16 random bytes without a library, by using fopen() and fread(). > Yes the string format is weird, but why would you write that by hand? Let the library print it, let the library parse it. You shouldn't need a library to handle your identifiers. If you do, your identifiers are too complicated. > Want to store it in a database? There's a column type for that. Want to send it over the network? There's probably a datatype for it in whatever protocol you're using (whereas with your approach you immediately have endianness issues). With the approach of random bytes, there's at least a consistent endianness throughout. And you can solve the endianness issue by treating it as a byte string. Job done.
- lmm 11y ago> You can generate 16 random bytes without a library, by using fopen() and fread(). Sounds more complicated and easier to get wrong. I'd rather have a single function call with an obvious name.
- GFK_of_xmaspast 11y ago> You can generate 16 random bytes without a library, by using fopen() and fread(). Yeah but then good luck getting the right /dev/random vs /dev/urandom on the right platform, and also good luck getting it to work on windows and ios.
- TazeTSchnitzel 11y agoTrue, it has its caveats.
- dalke 11y agoAnd good luck if you are in a chroot'ed jail, or out of file handles. (Hence why OpenBSD added arc4random(), now based on ChaCha20.)