3 ms·
Yes! There are a lot of benefits to the 'everything is a file' philosophy, but files aren't very good APIs for a structured data. The perfect example is the stu
by mjb 3y ago
Yes! There are a lot of benefits to the 'everything is a file' philosophy, but files aren't very good APIs for a structured data. The perfect example is the stuff in /proc and /sys. Making it all 'just a file' is super nice and flexible at first, but either makes stuff very difficult to change (the file becomes a poorly-specified inconvenient ad-hoc API), or makes it very hard to build applications that work in the long term (because the application has to write a change-tolerant parser). It makes a very cool demo (look, I can do stuff to TCP sockets using bash!), and really convenient for ad-hoc stuff, but is inferior to a real API for applications that need to keep working year after year after year while still being able to patch the rest of the system.
- duped 3y agoThe file tree is just a way of discovering endpoints to the API. You still need an encoding to read/write to those endpoints. The same is true over a "real" API with one big difference: there's not a small set of syscalls to access the endpoints and read/write binary data to them. Thats more stable than any FFI or encoding scheme. I'll take "everything is a file" over "everything is an object that has a special mechanism for querying interfaces and dispatching to handlers" or "everything is RPC" or "everything is REST" because it has the smallest surface area.
- charcircuit 3y ago>The same is true over a "real" API with one big difference: there's not a small set of syscalls to access the endpoints and read/write binary data to them. What do you mean? Binder from Android uses just the ioctl syscall. >because it has the smallest surface area. I assure you the 1 syscalls for using binder (unless you count open and close of /dev/binder) is less syscalls than what it takes when everything is a file (read, write, ioctl, lseek, lstat, etc).
- DonHopkins 3y agoIt's the job of the operating system to provide a stable foreign function interface, and dynamically linked libraries to access common operating system apis that aren't covered by system calls. Smallest surface area??! There's no excuse for Unix forcing you to use the fractally complex sucking chest wound of ioctl and brittle binary raw pointerless C structures in memory, instead of simply calling functions and passing normal parameters and pointers and results in and out. Computers are great at and have a long history of calling functions, so why not just support that, huh? "Everything is a file" is pointlessly performative but hopelessly incomplete Bauhaus Minimalism that fails to reduce but instead multiplies and relocates all the complexity to the Brutalist Rawness of ioctl's uncanny leaky abstraction of a kitchen sink, which undermines the entire Unix presumptuous philosophy of simplicity and consistency.