Live data from Hacker News

Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

github.com

121–130 of 236 posts

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#121
post #64

Earlier quoted context omitted.

> The page says the reason for excluding U is "accidental obscenity'. Crockford is being cheeky. To make a nice base32 alphabet out of non-confusable alphanumeric characters you only need to exclude O, I, and L. This leaves you with 33 characters still, so you need to remove one more, and it doesn't matter which one you remove, so you might as well pick an arbitrary reason for the last character that gets removed (an…

You could argue that U can be confused with V.

5 and S seems more likely.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#122
post #120

A couple of suggestions: Lock down the prefix string now before it’s too late and document it. I see in Go that it’s lowercase ascii, which seems fine except for compound types (like “article-comment”). May be worth looking at allowing a single separator given that many complex projects (and ORMs) can’t avoid them. The Go implementation has no tests. This is very unit-testable. Add tests goddammit! For Go, I’d align…

> The Go implementation has no tests. This is very unit-testable. Add tests goddammit!

Yep. The readme asks people to provide other implementations. Having a test suite would be good for third-party code.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#123
post #4

Unrelated, but this links to "Crockford's alphabet", https://www.crockford.com/base32.html , which is a base-32 system that includes all alphanumeric characters except I and L (which are confusable with 1), O (which is confusable with 0), and U (????). The page says the reason for excluding U is "accidental obscenity'. What the heck is it talking about?

> The page says the reason for excluding U is "accidental obscenity'. What the heck is it talking about?

Because he’s an American?

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#124

Earlier quoted context omitted.

If I and O are already excluded and you also exclude U that removes a lot of potential rude looking three letter combinations like *** and *** and *** and also the four letter ones like **** and **** and the dreaded ****. Of course because you have A then **** is still a possibility but very very unlikely

Wow I didn't know HN even had obscenity filters, and I've been here for many years. Guess that's a credit to the general civility of the community. EDIT: It appears that other people in this thread are freely using profanity, so either your comment was targeted by automation due to the unusual density of banned words, or it's a joke that went over my head :)

[deleted]

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#125
post #81

Earlier quoted context omitted.

The latest standard for v7 does not meaningfully describe how to interpret the last segment. It says they could be pseudorandom and non-monotonic. Or it could be monotonic and non-random. These are completely disjoint cases! "X or not X" is tautological. And there is no way to determine which (e.g. there could be a flag that indicates this mode, but there is not). To be clear, the standard should be amended to resolv…

I think the purpose of the standard is so that different software implementations work the same way, so that once you've picked a standard, you can use it everywhere and know that keys are assigned the same way regardless of which software stack is generating a particular key. Its not so that systems can "interpret" it. Obviously they are your bytes to use however you want if you are rolling your own generator.

> you can use it everywhere and know that keys are assigned the same way regardless of which software stack is generating a particular key.

But even if you follow the standard to a tee, you cannot infer anything about how the last 62 bits were assigned. That is my point!

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#126

Earlier quoted context omitted.

You could argue that U can be confused with V.

A vaguely related historical tangent is that V and U used to be just two ways of writing the same letter in Early Modern English. Which I imagine is why W is named as "double U" in speaking.

This is also interesting since in French (and I think Spanish?) W is (correctly) called "double V"

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#127
post #63

Earlier quoted context omitted.

We maintain a couple of popular ksuid libraries[1][2] and use it, so we definitely like ksuid. Though one big issue with ksuid is that being 160bit means that it doesn't fit into native uuid types in databases (e.g. postgres), which means that they come with a performance penalty. 1: https://github.com/svix/rust-ksuid 2: https://github.com/svix/python-ksuid

I'm curious, why do you not store these as binary data or do you and you're saying that the UUID operations are better optimized than sorts on binary data?

Exactly what the sibling said, and the same applies to database operations (when they have a uuid type).

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#128
post #81

Earlier quoted context omitted.

The latest standard for v7 does not meaningfully describe how to interpret the last segment. It says they could be pseudorandom and non-monotonic. Or it could be monotonic and non-random. These are completely disjoint cases! "X or not X" is tautological. And there is no way to determine which (e.g. there could be a flag that indicates this mode, but there is not). To be clear, the standard should be amended to resolv…

Postgresql doesn't care, it's not going to "interpret" those bits, it is just a 128-bit integer.

And I'm glad for it, because I could implement this without needing an extension or update to PostgreSQL.

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#129
post #120

A couple of suggestions: Lock down the prefix string now before it’s too late and document it. I see in Go that it’s lowercase ascii, which seems fine except for compound types (like “article-comment”). May be worth looking at allowing a single separator given that many complex projects (and ORMs) can’t avoid them. The Go implementation has no tests. This is very unit-testable. Add tests goddammit! For Go, I’d align…

> Add tests goddammit!

Hey, you’re pretty smart. How about you add them?

Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs

#130

I didn't get the "type-safe" part. How would it work in Go? Let's say I have structs: type User struct { ID TypeID } type Post struct { ID TypeID } How can I ensure the correct type is used in each of the structs?

It’s stringly-typed type-safety: check if the value has the expected prefix.
Post reply on HN