3 ms·
v7 is really helpful for meaningful UX improvements. ex. I'm loading your documents on startup. Eventually, we're going to display them as a list on your home
by refulgentis 2y ago
v7 is really helpful for meaningful UX improvements.
ex. I'm loading your documents on startup.
Eventually, we're going to display them as a list on your home screen, newest to oldest.
Now, instead of having to parse the entire document to get the modified date, or wait for the file system, I can just sort by the UUID v7 thats in the filename.
Is it perfect? No, ex. we could have a really old doc thats the most recently modified, and the doc ID is a proxy for the creation date.
But its much better than the status quo of "we're parsing 1000+ docs at ~random at startup, please wait 5 seconds for the list to stop updating over and over."
- canadiantim 2y agoTho presumably the uuid would give you the creation date but not the modified date. Still very useful.
- sedatk 2y agoOr just use the file date.
- refulgentis 2y agoThis is fine-ish till O(10^3)
- JadeNB 2y ago> Or just use the file date. Your parent says they don't want to wait for the file system: > Now, instead of having to parse the entire document to get the modified date, or wait for the file system, I can just sort by the UUID v7 thats in the filename.
- sedatk 2y ago> Your parent says they don't want to wait for the file system: That information comes for free when you're iterating files in a directory. There's no extra waiting than the file name itself because file dates are kept in the same structure that keeps the file names.
- nemothekid 2y agoThis doesn't seem to be true in the standard directory implementations for iterating a directory in Python or Rust.
- sedatk 2y agoYou're right. It's free on Windows, but isn't on Unix apparently. https://doc.rust-lang.org/std/fs/struct.DirEntry.html#method.metadata https://doc.rust-lang.org/std/fs/struct.DirEntry.html#method... Still, I find that justification to rely on certain binary format of an ID format weird. Just use the dates in filenames if you truly need such a mechanism.
- refulgentis 2y agoWhat if I need an ID in the filename and I get the date sorting for free? You know, like described in the OP. Is it okay if thats useful?
- sedatk 2y agoYes. I agree with the sentiment that UUIDv7 being chronological can be useful. But, in this specific example, I think it’s a design smell to design your feature around the format of the filename and UUID generation algortihm. I’d say, wait for the FS if you have to instead of creating failure-prone dependencies like that.
- refulgentis 2y agoWhat part is failure prone? What is it being relied upon for? Alternatively, more explicitly, lets look at it from this angle: Let's follow exactly what you're recommending: parse it from the file. Then add a fault-tolerant layer in front that parses a UUID-v7 from the filename. What do you think of that?
- sedatk 2y ago