A Newbie's Perspective on Plan9

September 28, 2023

Hey Internet.

For the past few days, I've been participating in SDF's Plan9 bootcamp. I had attempted this bootcamp last year, but hit a couple snags early on that I just didn't have the bandwidth to deal with at the time. One of the big hinderances was the lack of a three-button mouse, which it turns out is rather important (more on this later). Anyhow, I'm giving it a proper go this year, and I have to admit, I've been pretty impressed by what I've found so far. These are my preliminary impressions. To spice things up, instead of using Emacs to write this blog post as I normally would, I'm using the acme editor from within my SDF Plan9 account.

Before I get started, I should give a disclaimer: I am essentially a total newbie to Plan9 (in case that wasn't obvious from the title of this post). As a consequence, this blog post may contain rookie mistakes and inaccuracies. Don't look to me for any kind of expert advice; doing so may well end in tears. With that out of the way, I welcome you to join me on this adventure.

So the first thing I noticed when I got my account set up and logged in is how much it looks like X11 did back in the 90s: very minimalistic, no window decorations (not even title bars), no taskbar, launcher, widgets... no nonsense. There was a small status monitor window in the upper-left corner of the screen that I still don't quite know how to read, and a terminal window. That's it... though I'm pretty sure the initial configuration of your workspace can be changed by editing the $home/lib/profile file. It quickly became apparent that even the terminal window was unfamiliar. Instead of only being able to input text at the cursor, the terminal works more like a text editor. You can select text with the mouse and edit it. This applies to any text in the terminal. It reminds me a bit of Emacs (if it were primarily mouse driven rather than relying on cryptic keyboard commands).

The window manager itself also takes some getting used to. At first, the UI felt very clumsy, but as I got used to it, I realized it was rather powerful as well. As I mentioned before, a three-button mouse is very much a must for Plan9. There are workarounds for two-button mice, but the experience definitely suffers for it. Rather than referring to the mouse buttons as left, centre, and right, they're referred to as buttons 1, 2, and 3, respectively. For the sake of consistency, I'll refer to them as such here.

Button 1 works basically the way you'd expect. You use it to select text, click on buttons, that sort of thing. Buttons 2 and 3 typically bring up context-sensitive menus based on where you click. You hold the button to pull up the menu, hover the pointer over the option you want to select and then release the mouse button. The menu brought up by button 2 tends to involve editing options: cut, copy (or "snarf"), paste... that sort of thing. Button 3 tends to be window management stuff: creating, destroying, resizing, and otherwise manipulating the windows themselves. To open the netsurf browser for instance, you can create a new window from the button 3 menu, and draw out the outline of where to place it. This gives you a terminal window into which you simply enter the netsurf command. The window is then magically transformed into a browser window.

Anyhow, I don't want to turn this into a "how to use Plan9" blog post. Instead, I want to highlight the things that I think are interesting about it. So far, the thing that stands out the most to me is the concept of namespaces. It's actually a feature that I really find myself wishing the Linux kernel supported. It basically allows you to re-map the filesystem on a per-process basis. This makes it trivial to sandbox a process for example. Since Plan9 subscribes to the everything-is-a-file philosophy, you can just map over directories and files that a given process should not have access to. It also allows a program to provide an API by creating a virtual filesystem that can be read from and written to by simple shell scripts. A good example of this is acme, the text editor I'm using right now. It can be greatly extended using this technique. There's a good tutorial on YouTube for acme here that gives a general idea of how powerful this concept is, among other things.

Another interesting aspect of Plan9 is the way it does file transfers between systems. It's a feature that's kind of brilliant in its simplicity. To explain this, I need to take a step back. Because I don't own a machine that runs Plan9 natively, I have to remote connect using the drawterm program. Drawterm is to Plan9 as SSH is to more traditional *NIX systems... though it's arguably quite different because it runs the kernel on the local machine, and downloads and executes remote code locally instead of just piping the output, but I digress. If you call drawterm with the -r <path/to/local-dir> argument, it'll use the aforementioned namespace system to map the files in that local directory into the remote /mnt/term path. When I connected this session, I was able to mount the directory that has the local copy of my website in this way so that I could work on it through acme. From the user's perspective, it's all completely seamless.

Overall, Plan9 is a weird hybrid that combines the best features of a point-and-click GUI and the raw power of a plain text terminal. Is it the most intuitive thing I've ever seen? I want to say no, but I also have to admit that my definition of "intuitive" is probably heavily influenced by the user interfaces that I've used for the past two to three decades... which haven't really changed a great deal in all that time. Also, despite having a somewhat steep learning curve, it makes up for this by having excellent documentation. If you want to try something new, I highly recommend giving Plan9 a whirl.

Have a good one.

P.S.: I haven't figured out how to do spellchecking in acme yet, so I just have to rely on using my human eyeballs to proofread. Hopefully I haven't missed any embarrassing typos.