Live data from Hacker News

Goodbye integers, hello UUIDv7

buildkite.com

31–40 of 376 posts

Re: Goodbye integers, hello UUIDv7

#31

It’s 2023. Why aren’t we using more characters from the utf-8 keyspace to make things like UUIDs use less characters?

UUIDs are 128-bits, not characters. The string representation is just for humans.

I think the parent is saying that we can make UUIDs more human-readable by displaying the underlying 128 bits with a larger set of characters.

Re: Goodbye integers, hello UUIDv7

#32

Earlier quoted context omitted.

UUIDs are 128-bits, not characters. The string representation is just for humans.

I think the parent is saying that we can make UUIDs more human-readable by displaying the underlying 128 bits with a larger set of characters.

Base58 and Base64 exist in pure-ASCII space. Expanding into non-ASCII characters would probably just be confusing.

Re: Goodbye integers, hello UUIDv7

#33

Earlier quoted context omitted.

UUIDs are 128-bits, not characters. The string representation is just for humans.

I think the parent is saying that we can make UUIDs more human-readable by displaying the underlying 128 bits with a larger set of characters.

We could make the string representation more compact with more characters, but I’m not sure compactness and readability are the same, especially any compactness that takes more than the ASCII character set (sure, just the hexadecimal digits may be fewer than ideal.)

Re: Goodbye integers, hello UUIDv7

#34

It’s 2023. Why aren’t we using more characters from the utf-8 keyspace to make things like UUIDs use less characters?

UUIDs are 128-bits, not characters. The string representation is just for humans.

I think it's a fair question, because yes you should store them as numbers, but they are still often sent in text formats and urls. Wanting a shorter representation is reasonable.

The easiest is probably to just base64 the binary representation of the 128 bit number, which results in a 128/6=22 character string, which is a bit smaller.

If glyph-length and not byte-length is more important you could go even smaller but I'm less sure if that's a good idea.

Re: Goodbye integers, hello UUIDv7

#35
This is great for internal distributed systems where having ordered keys is useful, however, it should probably be noted that these probably shouldn't be used as public identifiers (even though this will probably be the defacto standard and used publicly without thought).

Having any information, specifically time information, leaking from your systems may or may not have unanticipated security or business implications. (e.g. knowing when session tokens or accounts are created).

Re: Goodbye integers, hello UUIDv7

#36
post #27

Earlier quoted context omitted.

I've been seeing a few different vendors do this already. MongoDB's ObjectIds are inherently timestamps (so you can actually generate generic MongoDB IDs to query based on time). There's also Discord's Snowflakes as well. I'm sure there's loads of others. All it tells you is when something was generated, not much else. I do love how MongoDB has it stored in such a way that it is easy to query against. I wonder if any…

There are definitely many cases where it isn't an issue since you were going to tell the user the time anyway (like sent time on a message)

I think Twitter also does it as well. I think its really nice honestly.

Re: Goodbye integers, hello UUIDv7

#37
post #20

Can you take the first portion of the UUIDv7 string, and decode it to figure out the exact date and time that record was created? I'm wondering if there might be security/privacy concerns in some situations if the UUID codes are visible in your app?

I just commented the same thing. I can't imagine most applications would want to leak time information in their identifiers but these undoubtedly will be used most placed out of convenience. In a year or so we'll read about an attack and everyone will migrate back to v4 or have to maintain a cryptographic identifier in addition to their temporal identifier.

Re: Goodbye integers, hello UUIDv7

#40

It’s 2023. Why aren’t we using more characters from the utf-8 keyspace to make things like UUIDs use less characters?

Firstly, "it's current year" is never a good argument, but you seem to be confusing things (UTF-8 vs Unicode). UTF-8 can take as much as 6 bytes to encode a Unicode codepoint.

If you want to store UUIDs as compactly as possible you'd use 16 bytes.

If you want to store them as text, mapping them to Unicode would be a terrible idea because: many characters are from scripts you've never heard of, many characters look identical (Α vs A), many characters are decomposed and it can change the encoding if they're decomposed[1], &c.

[1]: https://en.wikipedia.org/wiki/Precomposed_character

Post reply on HN