Live data from Hacker News

Plan 9: The way the future was

catb.org

11–20 of 86 posts

Re: Plan 9: The way the future was

#11

The impression I got was that the guys behind Unix were annoyed when their operating-systems research was stalled in the name of "API compatibility", so they started Plan 9 and actively resisted commercialisation for as long as possible (for example, they gave it the least marketable name they could think of). There's so many interesting ideas in Plan 9, I'm occasionally tempted to install it and try it out... but th…

The problem wasn't that the Plan 9 guys opposed commercialization, quite the contrary, the problem was that AT&T never let the system become open source. For some time it wasn't even available outside universities. That killed it.

Yes, acme doesn't have keyboard shortcuts, I use it every day.

Re: Plan 9: The way the future was

#12
Am I the only one who doesn't get excited about the idea of absolutely everything being a file?

People seem to like the idea of being able to say things like "cat file.wav > /dev/dsp". But a sound card is a complex thing that can be configured in umpteen different ways; what if the file has a different sample rate than the card is currently running at? Even if you gerry-rigged a kernel driver that could handle this case (by, for example, noticing when the file had been open()'d and expecting the next bytes to be a WAV header, which it uses to reconfigure the card), you're left with something that doesn't have even the most basic functionality that you'd expect from a sound player; for example, "pause."

So what has representing /dev/dsp as a file really bought you? It doesn't help you know what devices are available, because there's tons of crap in /dev that doesn't necessarily have a kernel driver loaded for it. It's not that useful as an end-user interface for selecting a sound card, because users don't want to choose between /dev/dsp and /dev/dsp2, they want to see nice names like "Internal Speaker" or "Apogee Duet."

Files give you a simple API for lots of common operations, which is nice, but the fact that all files are not created equal means that operations sometimes don't work like you expect. For example, how would you guess that "tail -f" is implemented? If you're like me, you would have expected that it works by calling poll/select/etc. and waiting for the file to become read-ready. But this approach doesn't actually work for monitoring growing files; the select() will just return immediately with read-ready even if you're at EOF. So what "tail -f" actually does is a loop that alternates between sleep() and fstat(). I'm serious! http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f...

Re: Plan 9: The way the future was

#13

Am I the only one who doesn't get excited about the idea of absolutely everything being a file? People seem to like the idea of being able to say things like "cat file.wav > /dev/dsp". But a sound card is a complex thing that can be configured in umpteen different ways; what if the file has a different sample rate than the card is currently running at? Even if you gerry-rigged a kernel driver that could handle this c…

You could configure it by doing something like

  echo "22050" > /dev/dsp/config/sample_rate_hz
  echo "lanczos" > /dev/dsp/config/resample_algorithm
You could then search for configs by using find, back them up by using tar, be able to easily replicate settings between computers using rsync etc.

The idea is not to have one unconfigurable binary reciever, but rather to expose the interface as a hierarchy of rw files instead of a number of C functions, because the C functions have no easy shell representation, and most command-line tools fail using them.

It's very reminiscent of REST.

Re: Plan 9: The way the future was

#14

Am I the only one who doesn't get excited about the idea of absolutely everything being a file? People seem to like the idea of being able to say things like "cat file.wav > /dev/dsp". But a sound card is a complex thing that can be configured in umpteen different ways; what if the file has a different sample rate than the card is currently running at? Even if you gerry-rigged a kernel driver that could handle this c…

http://plan9.bell-labs.com/magic/man2html/3/audio

Re: Plan 9: The way the future was

#15

Am I the only one who doesn't get excited about the idea of absolutely everything being a file? People seem to like the idea of being able to say things like "cat file.wav > /dev/dsp". But a sound card is a complex thing that can be configured in umpteen different ways; what if the file has a different sample rate than the card is currently running at? Even if you gerry-rigged a kernel driver that could handle this c…

Some files are different. So? Do you have the same qualms with stdin/stdout not being seekable because they are often connected to a terminal?

The "everything is a file" abstraction is mostly helpful and rarely gets in the way in practice; I don't know how plan9 exposes sound, but it is probably a directory, with multiple files - one you write to to set sampling rate; another gets data, and the third is stop/go/cancel.

The most useful feature, though, is network transparency that really works. You don't need Vnc/rdp; just mount the remote display in your file system. You don't need special ip forwarding - just mount the remote network in your local file system. You don't need a network aware server for anything - it all is.

That's the reason to get excited.

Re: Plan 9: The way the future was

#16

    > There is a lesson here for ambitious system architects: the 
    > most dangerous enemy of a better solution is an existing
    > codebase that is just good enough.
Isn't this concept applicable to every system once it incorporates programmability?

Re: Plan 9: The way the future was

#17
post #6

Unsurprisingly given the common pedigree, a number of ideas from Plan 9 have made their way into Go. E.g., compare http://golang.org/pkg/net/#Dial and http://plan9.bell-labs.com/magic/man2html/2/dial . Go's approach to concurrency is familiar in the Plan 9 world from Alef ( http://en.wikipedia.org/wiki/Alef_(programming_language) , http://swtch.com/~rsc/thread/alef.pdf ) and Limbo ( http://www.vitanuova.com/inferno/p…

Cool. I wasn't sure if it was common knowledge that Ken Thompson and Rob Pike created Go. The Go compiler toolchain is from Plan 9, too: http://golang.org/cmd/.

Re: Plan 9: The way the future was

#18

Am I the only one who doesn't get excited about the idea of absolutely everything being a file? People seem to like the idea of being able to say things like "cat file.wav > /dev/dsp". But a sound card is a complex thing that can be configured in umpteen different ways; what if the file has a different sample rate than the card is currently running at? Even if you gerry-rigged a kernel driver that could handle this c…

You can do cat file.au >/dev/audio on a lot of Unix-y OS's. For wav, the problems you mention are solved with "sox" which converts the wav file to raw data with suitable options.

All of the problems you mention are problems of the interfaces exposed by the files, not problems with the "everything as a file" idea in itself.

Look at /proc on linux. /proc/[pid] represents a running process, but it's a directory, not a file, all the information about that process are inside.

A hypothetical filesystem API for audio designed to be friendly might expose a /proc/sound/[device]/name file containing a user friendly description and a /proc/sound/[device]/output file that a converter gets mounted at that you can just copy files to, and a /proc/sound/[device]/control that accepts commands like "pause" or "play".

You also seem to also be assuming that these interfaces are meant for ordinary end-users. While some of the functionality does make it easier for end-users to interact directly with the lower levels of the system, nothing precludes friendlier interfaces being put on top of it.

What it gives you is an interface that has a bunch of standard tools you can use to operate on them, either because they're simple enough to use directly, or to make building the user friendly interfaces more easily, and that which is at the same time reasonably explorable if it's well designed. /proc is a good example of this - you can poke around in it and learn a lot about your system with just a standard shell without having the faintest idea about how it's structured initially. Meanwhile, the non-file-related system calls require you to write code to test them out - they're far more opaque.

> But this approach doesn't actually work for monitoring growing files; the select() will just return immediately with read-ready even if you're at EOF.

This really shouldn't be surprising. select() specifically tells you if the filedescriptor is read for read. A filedescriptor is ready to read from if there is more data or you're at the end of the stream. The behavior is entirely consistent. Perhaps a way of requesting notification only if there is more data to read, rather than if there's more data or end of the stream, would be useful, but that is not what select() provides. It illustrates some of the flaws in the Unix system calls, not an inherent problem with a filesystem interface.

Re: Plan 9: The way the future was

#19
I've often thought that Plan 9's everything-is-a-file system with a consistent API for access is the missing link between Unix's everything-is-a-file and REST's consistent interface constraint. I think it's certainly arguable that Plan 9 shares many features with RESTful architectures.

Re: Plan 9: The way the future was

#20
post #14

Am I the only one who doesn't get excited about the idea of absolutely everything being a file? People seem to like the idea of being able to say things like "cat file.wav > /dev/dsp". But a sound card is a complex thing that can be configured in umpteen different ways; what if the file has a different sample rate than the card is currently running at? Even if you gerry-rigged a kernel driver that could handle this c…

http://plan9.bell-labs.com/magic/man2html/3/audio

I'm not sure that really contradicts his point, that's a terribly limited API. Stereo only, no way to specify channel layout, 16bit only, no way to change the device buffer sizes, no way to tell if the device is in use, no way to tell the device latency, seemingly no way to examine what sample rates or bit depths the device supports, seemingly no way to subscribe to any kind of notification when the device has actually changed sample rate (or other properties) or when playback has stopped etc, no ability to lock the device to prevent other processes changing the sample rate or other properties, no ability to get device time or determine if the device is synchronised with system time.

Some of these missing things can be added fairly easily to the existing API of course, but I don't know enough about plan9 to suggest how, for example, notifications for device property changes could be added.

As it stands this interface is almost useless even for casual home users who just want to play back audio: multiple channel support is a basic requirement these days. Serious audio work is not even possible at all.

Post reply on HN