Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Plus I could easily represent UUID in base64, such as JlEt5BSYe0enwB7nxl5V6g, which makes it shorter if I need that.


Maybe use a smaller alphabet though, base64’s can be quite hard to read / spell out / reproduce as it includes confusing pairs.

While somewhat less dense, base58 or rfc 4648 base32 mitigate these issues.


And for UUIDs, Base58 and Base64 both require 22 characters, so no density loss! Even Base32 only takes you up to 26 characters.


Some alphabets have the disadvantage of generating swears, which might be a problem for your use. Applying filters is a difficult approach. Hex has the advantage there.


> You can't find the product sir? Try typing into the search bar DEADBEEF


If you think of the worse ID you can spell with the full alphabet next, please don't write it here :)


Base32 or Base36 have the advantage of using single case which is easier to read out. And no symbols.


The official Base32 doesn't work for encoding UUID7, which is time-ordered, because its symbols for 0-31 are not in ascending ASCII order.

My own preferred format for UUID7 is one I call "id25". It's really Base35 because alphabets of 35 and 36 characters both need 25 characters to represent the 128 bits in a UUID. So I can start with Base36 and take out one of the next most ambiguous character pairs. The result looks something like '0pydgw5pifvapk5zyhmpso5tx'.

The two other advantages of using this id25 format rather than UUID7 are:

- The id25 format is quite distinct from UUID4. So if you have UUID7s being generated distributedly (rather than centrally) and the UUID7 time-ordering feature is important, it's nice to have a format that a trivial "if '-' in uuid_string..." check will spot.

- Because there are no hyphens or symbols, the whole id25 uuid can be selected in web page with a double click. Whereas a uuid will need a mouse movement to get all 5 parts.


Do many use cases need lexical ordering for the encoding of the UUID? (The UUIDs themself would still be ordered; it's just the human/URL/wire encoding that isn't.)

Most of the use cases I can think of where I'd want an ordered UUID, I probably wouldn't need to lexically compare the encoding of multiple such IDs (where I can see plenty of utility in the ability to compare the underlying IDs).


For sure yes! There are tons of situations where you need to use the string form of an ID, e.g. filenames, and you definitely want the lexical ordering of files in a directory to be correct.


I've always seen the human encoding as the main point, so you can infer things about them while working with them. A database, for example, would have a datetime column that can be used instead most of the time.


Crockford base32 works, doesn't it?


The hazard of base64 is the use of '+', '/', and '=' characters, which most HTTP engines treat as special.


Luckily the spec provides for a url safe variant (sometimes called base64url): https://datatracker.ietf.org/doc/html/rfc4648#section-5


It exists, but I wouldn’t call that “lucky”, or a selling point.


or ascii85:

    -;cAU'UX5;VnaA:`a2[1


I can't even get people to distinguish between a forward and backslash... :-(


Yikes! I wouldn't want to provide that as a shell argument.


Try and communicate that to someone over the phone.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: