Hacker News new | ask | show | jobs
by zokier 2580 days ago
> People like Unix's “everything is a file” approach because what it really means is “everything is exposed to the same nexus”. It means you need only ssh to a system and you have all the power to reshape all aspects of that system with a single interface, the command line, using a common set of highly composable tools

But at least in Linux there are ton of files that are not exposed to the "same nexus", i.e. filesystem. The most common example would be network sockets. They are files, but do not exist anywhere in filesystem. In Linux file is more of an object handle.

https://yarchive.net/comp/linux/everything_is_file.html

http://events17.linuxfoundation.org/sites/events/files/slide...

3 comments

Whenever somebody talks about a "Unix philosophy" they are almost certainly alluding to some revisionist history or whitewashing of the truth. The only real "philosophy" of Unix that is grounded in reality is the "worse is better" idea.

One generation throws some shit at the wall, some of it sticks. Time passes and a few elders talk up their achievements in grandiose terms. With time, people begin to forget the truth and view the artifacts from the past as products of pure enlightenment. Shit-throwers are retconned into being master architects. The just-world fallacy kicks in and people mistake 'passing the test of time' for proof of quality, then they spin legends to fill that narrative.

See PipesFS: Fast Linux I/O in the Unix Tradition [1]

"PipesFS replaces socket-specific data access calls (like send and recvmsg) with basic reading from and writing to pipes, whereby the location of the pipe identifies the socket. The actual path for sockets is long, consisting of 8 filters for the reception end, but users are easily shielded from this com- plexity through symbolic links"

[1] https://ts.data61.csiro.au/publications/papers/deBruijn_Bos_...

Yes, people call it the "Unix philosophy" not the "Linux philosophy." And the Plan 9 folks (nee Unix folks) also thought everything in Unix should be a file and not everything was.

[edited for clarity]

It is not the "Linux Philosophy", socket api originated from BSD and it is considered Unix. Based on my experience noone in the plan9 community would call it unix.
Socket API was bolted onto Unix as a port from TOPS-20. It might have become accepted part of Unix, but so was XTI which in retrospect was probably better.
Instead of calling everything a "file", you might as well call everything an "object" then. It also seems more correct.
Calling it object would mean you have different methods of accessing it. But files have a fixed set of methods/properties.
Not sure what you mean, because e.g. ioctl() call has many functions which are not sensible for regular files.

In any case, the article has 17 occurrences for "file(s)" versus 28 for "object(s)", so the author seems to agree with me :)

Not every file respond to ioctl() and that's not what people mean when they say "unix philosophy". Yes, in a sense ioctl() does model the object nature, but they aren't discoverable and rather adhoc, as the article points to powershell and capability for reflection for how a OOP based resource access would look like.
What's the difference?

Perhaps a file never meant just something you have in a directory, rather "a stream of bytes", and the bigger thing was always unifying the difference whether those bytes are read from a magnetic tape or received wirelessly over the internet.

A file is just an object with a name in a namespace. Without a name, it's not really very much of a file.
In Unix, some files even don't have names. See for instance the pipe() call.