Salzenberg's Law of Pretense: Trying to simplify technology by pretending a thing is something else always fails, because the pretense is itself a complication. Putting a mask on a thing does not remove the thing, it adds the mask. It thus requires new technologies to create the mask, identify it, remove it, and see behind it.
Examples: Unix symlinks, Unix device files, Unix pipes -- basically everything in Unix that uses an fd but isn't a local file; DNS CNAME records; and, most recently, making the Perl regex /ss/ match "ß".
Utility Corollary: If simplicity is not your primary goal, then adding a mask may work great.
Examples: same list. Except for that /ss/ thing.
I disagree with your view about UNIX unification of interfaces as fd.
I think of that as a object-oriented approach to the problem. All of those concepts use fd's to share the common most basic operations (open, read, write, close) with a well defined and common interface.
Then you can introspect the real type of the generic file with stat(), for each type a set of extra operations is available, just like you would with a subclass.
Best regards,
Posted by: www.simplicidade.org | September 07, 2011 at 10:21 PM
I did say that fds fall under the Utility Corollary. If you could know that every fd was a plain file, would your fd-manipulating code be simpler? Of course. So that's the Pretense Rule at work. But for the sake of utility Unix (and even more Plan 9) extended fds to cover lots of non-file things. The loss of simplicity is acceptable.
Posted by: Chip Salzenberg | September 08, 2011 at 03:37 PM