I noticed this morning that some entrepreneurial soul did a quick rewrite of the _CShims package target in swift-foundation into Rust. I was really impressed by how this PR was handled - thanks for being kind, it reflects well on the ecosystem.
This PR got me thinking, though: is there a goal to rewrite these lower-level dependencies into Swift? It looks like it's primarily being used for UUID generation and some lower-level string comparison functions.
More importantly, UUIDv4 (which Foundation and that implementation generate) is not necessarily the best things to use in all cases.
The new UUID v6/7/8 incorporate a temporal component, which means they have greater locality and are much friendlier for databases. They also allow the use of arrays (with lookup via binary search and very easy filtering of items within a given time range) rather than dictionaries, which can be much more space efficient. Many (most?) large-scale distributed systems these days generate IDs which incorporate both temporal and spatial uniqueness (such as Firebase push IDs).
I think a modern UUID API would provide both, as well as more parsing and formatting options.
More broadly, the most important reason for replacing C implementations is functional - in addition to the features listed above, only a Swift implementation can allow users to provide their own RandomNumberGenerator to be used in ID generation, or allow users to parse UUIDs from generic StringProtocols (i.e. including substrings).
The current set of functionality is just far too basic and needs a comprehensive rethink.
I do agree that other versions of UUID are very important, especially for the server ecosystem. Right now the focus on swift-foundation is to implement all the APIs in Swift that are set out in the README.
Afterwards, swift-foundation does user an evolution process to pitch new APIs. Not saying that variants of UUIDs are getting accepted but personally I would love to see a pitch for them. However, we do still have a couple of important types missing and a bunch of unknowns ahead of us.
The current set of functionality is just far too basic and needs a comprehensive rethink.
Yes, but modifying UUID in this way requires an evolution pitch. I'm only trying to reduce/remove the C shims from this project so that the implementation is all in Swift (and consistent with what is already there). This will hopefully make proposals like yours easier to implement if/when they're accepted.
Foundation’s backwards-compatibility constraints are even stronger than Swift’s. Imagine someone using a UUID in a path on a case-sensitive filesystem.