3 ms·
Imagine if Unix was invented after the invention of things like networking and GUIs. Basically, take the core concepts of Unix, like "everything is a file" and
by tadfisher 9y ago
Imagine if Unix was invented after the invention of things like networking and GUIs. Basically, take the core concepts of Unix, like "everything is a file" and "the only protocol is bytes", and make an operating system which religiously sticks to those principles while supporting modern, difficult-to-abstract systems.
For example, on Linux you'd load a web page by instructing a program to open an (AF_INET, SOCK_STREAM) socket, tell the kernel to connect() to some destination, send some bytes, read some bytes, and render those bytes as a page on your screen using another set of userspace libraries and system calls.
Whereas, on plan9, you might mount a remote server to a local namespace, look for the page you want, then pipe that file through an HTML renderer and the output to a display server. Or you might echo "connect 192.168.0.1!80" into /net/tcp/0/ctl, and read the result from /net/tcp/0/data.
Linux has borrowed several things from plan9, including /proc and /net, and you can even set up your system so you can pipe things to /dev/tcp. The single abstraction of files is a pretty good one for exposing all sorts of functionality to userspace, so you can get pretty good at doing just about anything without needing to drop into C or otherwise asking the kernel directly.
Disclaimer: I'm not a plan9 user, and I'm not saying that files are the best userspace abstraction.
- schoen 9y ago> and you can even set up your system so you can pipe things to /dev/tcp The bash shell supports /dev/tcp by default for file descriptor redirections (so people who are using bash can already do this!).
- bitwize 9y agoBut it doesn't generalize outside of bash -- and where do you think bash got the idea from?
- schoen 9y agoI'm sure bash got the idea from Plan 9, although I didn't know that until recently.
- dredmorbius 9y agoAs noted, that's a shell-specific artefact, which makes me shudder thinking of DOS's command-specific globbing. And not all bashes support this -- Debian (and I suspect Ubuntu, Mint, etc., based on it) disables this option at build time. You can get something fairly close via netcat, though IMO that also shows some of the weaknesses of the approach, which is that you're not interacting with a web page, say, so much as you're talking http to a socket. Not that there aren't times when that isn't an entirely sensible thing to do, but if you just want to read stupid stuff on the Wobbly Wobbly Wibble, it's a bit too thinky. (All of which I'm sure schoen knows far better than I, though others might not.) The idea of talking protocol-based stuff through something that looks vaguely directory / file-ish, and which could do sensible things with HTML (or audio, video, data, messaging stuff, email stuff, crypto stuff) and through which utilities and utilities would have access without needing to be specifically adapted to handle the cases might be interesting.