12 ms·
Paths Aren't Strings (2014)
- rektide 5y agosooo much Ruby. so little real inquest into what the real OS-scale alternatives are!!! i'm sure there's other worthy topics. but to me, opendir(3)[1] is basically your 101 level "path's aren't strings". it's the way to do things fast/effectively & smartly. there are no paths, there are just directories (each with a number), made of directory entries (which are just other numbered things). a path is an abstract walking of .. (parent directory) up and up. if you do just want to think of paths as strings but fancy, there's some JS concepts about too to parallel this reading too: Node has it's "path" utility/helper library/built-in-module[1] for manipulating path strings. I'm partial to having a better modelled abstractions, for example, Gulp, a once popular build tool for Node, is built upon Vinyl[2], a simple virtual file abstraction. And now the Web platform is getting a File abstraction (and implementation), which again describes a similar-ish FileSystemHandle and FileSystemDirectoryHandle[3], that again provide a reifiable abstraction for files and directories. Ruby's path's ultimately do fall fairly close to a full file-system abstraction. Because they can read the fs and tell you things. 'path.directory?' means a Ruby path isn't an abstract thing, it's really a file-system tool, asking the fs about directories and paths. Worth noting that for a while Node's aforementioned "path" module had some similar sort of file-system related operations, but eventually all of those capabilities were deprecated, replaced by "file" module operations: the path library became for the abstract objective of working with paths, while file library took care of all actual interactions with a filesystem. [1] https://man7.org/linux/man-pages/man3/opendir.3.html https://man7.org/linux/man-pages/man3/opendir.3.html [2] https://nodejs.org/api/path.html https://nodejs.org/api/path.html [3] https://github.com/gulpjs/vinyl https://github.com/gulpjs/vinyl https://gulpjs.com/docs/en/api/vinyl/ https://gulpjs.com/docs/en/api/vinyl/ [4] https://wicg.github.io/file-system-access/#api-filesystemhandle https://wicg.github.io/file-system-access/#api-filesystemhan... https://wicg.github.io/file-system-access/#api-filesystemdirectoryhandle https://wicg.github.io/file-system-access/#api-filesystemdir...