3 ms·
When we didn't have UUIDv7, ULID was great. But now that we have v7 it's the more widely supported alternative. And apart from v7 setting the UUID version bits
by wongarsu 2y ago
When we didn't have UUIDv7, ULID was great. But now that we have v7 it's the more widely supported alternative. And apart from v7 setting the UUID version bits and having a different default representation they are not that different.
- stavros 2y agoOh, I didn't realize v7 was newer than ULID, thanks.
- 6512398 2y agoBe careful if you're using python. The python uuid standard library doesn't have V7 yet, and there is a package called uuid7 which is unmaintained, and not in compliance with the latest standard. That's using nanosecond time precision rather than millisecond, which means the leading bits are larger than they are meant to be. If you use that unmaintained uuid7 package and later change to the correct implementation your uuid7 will go backwards, which is a breaking change considering that monotonicity is a key property of uuidv7.
- bruce511 2y agoI believe your concern, while valid, only affects systems which are currently adding records faster than 1 per nano-second on occasion. Also while technically true - it could technically break monotonicity (records added in the same nanosecond could be out of order) they'll still be all "near the end of the file, likely in the same page" such that performance implications are negligible. As a general rule I would avoid any program making any assumptions about a uuid. Programs should treat it as an opaque binary random value. Doing so avoids any future incompatibilities.
- eropple 2y agoULID's presentation format is probably better for humans, though. You can double-click-to-highlight a ULID; the standard UUID representation doesn't like this. (You can use ULID's presentational tools with UUIDv7, though.)
- wtetzner 2y ago> the standard UUID representation doesn't like this. Yeah, I've gotten in the habit of stripping hyphens from the string representation of UUIDs in a lot of the code I write for that reason.
- beart 2y agoIt doesn't help in other tools, but there is a css rule to help with this. https://developer.mozilla.org/en-US/docs/Web/CSS/user-select https://developer.mozilla.org/en-US/docs/Web/CSS/user-select
- Lammy 2y ago> You can double-click-to-highlight a ULID; the standard UUID representation doesn't like this. You can control this behavior in CSS with `user-select`. Peep my fiddle: https://jsfiddle.net/gLyph5km/ https://jsfiddle.net/gLyph5km/
- eropple 2y agoYup, in a browser you can. In my terminal or my text editor or Slack, I can't.
- Lammy 2y agoYou're right that there isn't a good standard way to configure this, but a lot of terminals should be able to do it. The magic phrase is “word characters”. I know Konsole, gnome-terminal, iTerm2, Terminal-dot-app at least have this setting.
- eropple 2y agoYep, I know about that (and WORDCHARS in zsh, for keyboard navigation). The thing is, though, UUIDs overload the dash character. I don't want dashes to be word characters except for a UUID. (ULID representations also are shorter because they use a wider character set, which is nice though not critical.)
- 2y ago