8 versions of UUID and when to use them (www.ntietz.com)
from otter@lemmy.ca to programming@programming.dev on 30 Jun 2024 05:16
https://lemmy.ca/post/24110505

#programming

threaded - newest

abbadon420@lemm.ee on 30 Jun 2024 06:12 next collapse

I didn’t even know it was an ietf standard. Let aline there were versions. Apparently it’s only since may this year that there are 8 versions. Before it were only 5.

thanks_shakey_snake@lemmy.ca on 30 Jun 2024 06:18 next collapse

They should make the versions UUIDs instead of integers so that we don’t make assumptions about their ordinal relationships.

kibiz0r@midwest.social on 30 Jun 2024 16:33 next collapse

Or maybe an abbreviated hash of the text of their specifications?

RonSijm@programming.dev on 01 Jul 2024 15:27 collapse

Yea, should have been V-00000000-0000-0000-0000-000000000008 instead

darkghosthunter@lemmy.ml on 01 Jul 2024 23:12 collapse

Yes and no. They had to put the version identifier somewhere to avoid sorting problems or parsing problems, so I think that putting somewhat in the middle is a good tradeoff.

Zikeji@programming.dev on 30 Jun 2024 06:41 next collapse

Reject UUID embrace ULID.

GammaGames@beehaw.org on 30 Jun 2024 07:15 next collapse

Interesting 👀 github.com/ulid/spec

ChairmanMeow@programming.dev on 30 Jun 2024 07:55 next collapse

At the company I work at we use UUIDv7 but base63 encoded I believe. This gives you fairly short ids (16 chars iirc, it includes lowercase letters) that are also sortable.

shotgun_crab@lemmy.world on 30 Jun 2024 21:29 next collapse

I’ll be borrowing that little trick

ChairmanMeow@programming.dev on 30 Jun 2024 22:17 collapse

github.com/TheArchitectDev/Architect.Identities

Here’s the package one of our former developers created. It has some advantages and some drawbacks, but overall it’s been quite a treat to work with!

RonSijm@programming.dev on 02 Jul 2024 17:15 collapse

base63? I’d guess you’d mean base64?

Anyways, doesn’t that fuck with performance?

I’m using this in production: RT.Comb - That still generates GUIDs, but generates them sequential over time. Gives you both the benefits of sequential ids, and also the benefits of sequential keys. I haven’t had any issues or collisions with that

ChairmanMeow@programming.dev on 02 Jul 2024 20:26 collapse

It’s Base62 actually, misremembered that. It’s to avoid some special characters iirc. And no, performance is fine.

We’re using this: github.com/TheArchitectDev/Architect.Identities

Aux@lemmy.world on 30 Jun 2024 21:36 next collapse

I vote for nanoid.

bitfucker@programming.dev on 30 Jun 2024 23:39 collapse

I prefer CUID

Just to clarify: Yes, I do know not all use cases are appropriate for CUID. But in general when generating ID, I’d use CUID2

talkingpumpkin@lemmy.world on 30 Jun 2024 09:35 next collapse

Personally, I always regarded UUID as one of those overcomplicated and frankly unneded “enterprisey” standards (similar to SOAP and XSD, XSLT and various other XML techonologies). After reading this article my opinion didn’t change.

Also… do they even know what “version” means? That they choose that word over “type” or any other alternative says it all.

UUID Version 7 (v7) is generated from a timestamp and random data.

Use v7 if you’re using the ID in a context where you want to be able to sort. For example, consider using v7 if you are using UUIDs as database keys.

Please, do NOT rely on that and just add to your tables a field with the actual timestamp.

Mihies@programming.dev on 30 Jun 2024 10:23 next collapse

Uhum, why not?

breakingcups@lemmy.world on 30 Jun 2024 11:22 next collapse

You don’t quite understand. One of the major drawbacks of UUIDs over monotonically increasing id’s is the lack of ability to sort them. Not just for manual querying, but for index operations, caching, data locality etc.

It’s very handy and is a big part of the reason why Twitter developed Snowflake IDs, which are basically like UUIDs v6 and v7.

The UUIDs specs are quite easy to understand and definitely not “enterprisey”.

They chose “version” because they are just that, versions. Improvements over the original design that benefit from new insights and technological improvements. We’re lucky they had the foresight to include a version number in the spec.

FizzyOrange@programming.dev on 30 Jun 2024 12:32 collapse

They chose “version” because they are just that, versions. Improvements over the original design that benefit from new insights and technological improvements. We’re lucky they had the foresight to include a version number in the spec.

No they aren’t. A higher version of UUID isn’t “newer and better”, like the word “version” implies. It’s just different. It’s like they called a car “vehicle version 1” and a motorbike “vehicle version 2”. The common use of “version” in the software world would mean that a motorbike is a newer and hopefully improved version of a car, which is not the case.

The talking pumpkin is 100% right that they should have used “type” or “mode” or “scheme” or something instead.

copygirl@lemmy.blahaj.zone on 30 Jun 2024 13:53 next collapse

Version 5 of a software, device, vehicle or such isn’t necessarily better than version 4, and no official definition of the word “version” require this, either. If I may make another anology: You may pick one of 5 different versions of an outfit to wear, and even though they were labeled in the order they were made, from 1 to 5, none are inherently, objectively better than any other. In the case of UUIDs there are versions that are meant to supercede others, but also simply alternatives for different use-cases. Anyone with access to some up-to-date information can learn what each version’s purpose is.

SmartmanApps@programming.dev on 30 Jun 2024 14:17 collapse

Version 5 of a software, device, vehicle or such isn’t necessarily better than version 4

Yep, I can attest to that! I used to play Minesweeper Adventure version. Then Microsoft decided to do a complete rewrite and literally ruined the game. It was way slower and way buggier, and on top of that they also lost all my progress. So, well done Microsoft - now instead of seeing more ads (which was undoubtedly why they did the rewrite) I now don’t see ANY ads (because the game is just horrible now and not worth playing anymore, even if it didn’t have any ads!).

efstajas@lemmy.world on 30 Jun 2024 14:00 collapse

“Version” is definitely used commonly to describe two different … versions of the same thing, without implying that one is better than the other or supercedes it. There are two versions of the PS5, one with and one without a disk drive. There are many different versions of Windows, like Home or Enterprise. You can get hardcover or paperback versions of many books. Etc. Etc.

FizzyOrange@programming.dev on 30 Jun 2024 21:30 collapse

In normal English, when not using a number, sure! But in software, with numbers versions it almost universally means chronological releases of something.

There are many different versions of Windows, like Home or Enterprise. You can get hardcover or paperback versions of many books.

Great examples! Those are both called “editions”, not versions. Thanks for proving my point 😄

lemmyvore@feddit.nl on 30 Jun 2024 19:54 collapse

He’s not suggesting to replace timestamps (nor database sequences). They’re unique identifiers, and they happen to include a timestamp.

icerunner_origin@startrek.website on 30 Jun 2024 10:25 next collapse

There is an IETF standard for UUIDs? Do we need an IETF standard for UUIDs? I’ve been coding since the '90s and never thought a UUID to be complicated or contentious enough to need a standard. I guess it makes for a pretty unique icebreaker to say you’ve contributed to an IETF standard, if you get invited to those sort of parties.

atzanteol@sh.itjust.works on 30 Jun 2024 13:37 collapse

If you’re generating UUIDs from different languages, libraries, etc. you want to be sure there doing it the same way.

icerunner_origin@startrek.website on 30 Jun 2024 15:52 collapse

My face, screaming in horror, but in words instead. I’ve only really worked with projects in homogenous languages on the application side, so hadn’t considered that. Thanks for taking the time to reply.

DeprecatedCompatV2@programming.dev on 01 Jul 2024 02:28 collapse

Look the issues with java.util.UUID and Postgres.

breakingcups@lemmy.world on 30 Jun 2024 11:15 collapse

A lot of people in this thread who don’t fully understand how UUIDs work…

atzanteol@sh.itjust.works on 30 Jun 2024 13:29 collapse

You’re not kidding.