Thanks for all the work and research on this topic @tecosaur. I don’t want to derail this conversation too much with legacy conversations, but a few important decisions and challenges with FilePaths(Base).jl were:
(1) Paths are not strings
I think there’s consensus on this, but path types should not be a subtype of abstract string. Yes, paths can implement some of the string interface, but it won’t make sense to implement all of it and subtyping abstract string makes debugging that much harder for end users.
(2) /
vs *
As has been noted, I don’t think there’s an issue with using the /
in filepath code, but it shouldn’t be the default, since it represents division globally. In FilePathsBase.jl, you need to explicitly import /
within the context you’re using it. I’d also argue against using *
since it’s very handy to do directory / filename * “.csv”.
(3) Interfaces vs Types
Most implementations have tradeoffs between flexibility, readability, performance, strictness, etc. For example, the Tuple{Vararg{String}}
vs String
/Substring
implementations, as you mentioned. However, as an end user, I often don’t care as long as the behavior is consistent. I just want to know that I can call joinpath
, get a consistent result, and pass that to another function. There have been multiple conversations on adding interfaces / protocols to Julia, so you can specify that an argument implements some set of functions/interfaces (e.g., joinpath
, mkdir
, write
, status
). The way we worked around this was to have FilePathBase.jl mirror the Filesystem API. That way, if you simply loosened the type restrictions for your library then the code would just work without explicitly depending on string, path types, etc.
(4) Non-local paths
This has it’s own set of challenges, but there are multiple remote storage solutions that could support a subset of the filesystem interface. For example, S3Path in AWSS3.jl was really handy for our applications which often saved data to S3 in specific contexts. Some things that didn’t make sense in retrospect though (e.g., directory ops, status). Again, interfaces or duck typing might be a good solution in these cases.
Anyways, I’m glad this is something the community is still interested and keep up the good work