December 2009 Archive

Polyglot Writing

December 30th, 2009

Prof. Argüelles critizes the term “polyglot” for its sound and often misleading implications. While I personally like the pronunciation (but I have been a fan of harsh, guttural languages ever since, with a special fondness for /k/), I never really got the rest of his criticism until today. I mean, polyglottery is really only about learning 4+ languages. You only do what everyone else does to learn your second language, then do the same thing a few more times. At best, you use a few techniques to organize the whole effort, but fundamentally, it’s just more of the same.

But when I looked at my notebook (the paper one, that is), I realized what he really meant. The languages start to merge and the families and cultures start to develop new patterns. It’s the difference between a single switch and millions of them that make up a computer. You begin to understand people not in one particular mindset that your first language (and its culture) imposed on you, but soon develop alternatives (the second or third language) and then begin to see general patterns. You go from the perspective of the Romans, who realized that Greek had something to do with Latin, but they couldn’t quite figure out what exactly, to a more general view that understands the development of the Indo-European language as a whole, to maybe a global perspective.

Anyway, enough “make me one with everything”, I actually just realized I used German (using both the modern and old German Kurrent writing), English, Japanese, Ouwi and some ad-hoc pictograms on the same page in a coherent manner. You know you are a polyglot once you run out of space for all the languages to use.

Meditation on Xmonad

December 15th, 2009

Ignorance is the root of all suffering – ignorance about reality, about what is. By holding wrong assumptions, we create false expectations and false needs. [0]

I will not reflect on large parts of reality, but only a small one: window managers (WM). [1]

The most basic ignorance about WMs is the ignorance about their existence. The computer does not just show data to us, but it can show it to us in any way we want. It is this basic understanding that leads to the first conclusion: If the way data is shown to us is lacking, it is not our fault, but the computer is not doing it’s job properly. Furthermore, if we have to spend a lot of time just telling the computer how we would like to see something, we are actually doing someone (or rather, something) else’s work.

Therefore, tiling WMs. If you arrange your own windows, why are you using a WM at all? Wouldn’t it be more honest, instead of saying “I’m running Windows / KDE / OS X to show my windows”, to admit “Windows / KDE / OS X is running me to show it’s windows.”? Sure, the computer can not read your mind and some occassional hints might be necessary, but the less work you do, the better.

Desire creates suffering. This is maybe the most misunderstood of Buddhist truthes. People hear “desire creates suffering” and think “What? Is this going to be a moral how material possesions are bad for me? Money, cars, houses and so on lead to greed, obsession, and so on. I get it.”. This is not what this is about. The problem with desire is not the desire itself. It is not a problem that we want to be happy, to be rich and so on. The problem is, instead, that what we want is impossible. Our desires fail us. We are mistaken about the nature of reality and expect the wrong things. We think that money could make us happier, so we want more of it, but it ultimately won’t. From wrong assumptions you can only get bad results.

In retrospect, I can see this clearly now on my journey to a better window manager. It was my unwillingness to let go of old habits, my wrong ideas about what I really need or want, that made adopting a new WM hard. So I went first to WMs that offered great configuralibity and many features. “You can do anything you want!” But this lead to useless features and distractions. It is only now that most WMs fail me because my hardware setup is a bit tricky, that I can understand. Only now when I understand better what my brain really needs, do I grow tired of those full of bad design.

Xmonad, in a way, is peace for me. It is mathematical in nature. The fact that it is written in Haskell might seem like a gimmick at first, but the connection is in fact very deep. I understand now that it could not have been written in anything else. Xmonad exemplifies the idea of purely functional programming. “Normal” programming is almost always imperative – the programmer tells the computer how to do something. But in functional programming, the hacker instead tells the computer what something is. This is a profound difference.[3]

In any other customizable WM I have ever used, I would create a complex configuration to tell it exactly what I wanted it to do in some case or another. I would do the bulk of the lifting, so to speak, either by constantly adjusting the windows the WM handled wrong or by writing elaborate procedures to automate this work. But with Xmonad, this is different. It is not my job to figure out how to arrange windows, so I should never have to tell my WM anything about this. The only thing I ever have to tell it is about what is. I should never write something like “to go to the next tag, you read in all tags, sort them, filter some out, find the current one and then shift to the next in the list”. I instead write: “I want the next non-empty, non-visible tag now”. I give Xmonad a few simple hints and that is it. “If it’s name is in this list, I want it floating. If I’m currently out of space here, try a different screen. There is a status bar I’m running, so be careful not to overlap it.”

For the first time, I feel like my WM is actually intelligent and wants to help me. It is not my slave, not my servant who follows my orders. It does not look down on me, thinking itself smarter than me, only an obstactle to its flawless performance. Instead, Xmonad is my friend. It understands window handling and can take care of it. I only tell it some personal preferences. If it doesn’t think I need something, it is probably right.

It is astonishing how easily we pick up delusions. We see something once and think it should always be that way. Rarely do we question “Is this really necessary? Is there no other way?”

For me, those are some of the delusions that clouded my judgement about WMs.

“I need space! I want to see my desktop wallpaper!” What for? Have I not something better to do than to stare at pretty pictures?

“I want to tell my WM what window is in the foreground and what in the background.” The very concept is wrong. There is no “foreground” with focus – you either see something or you don’t. A window you can not read might as well not be there at all.

“I understand now, I use a tiling WM. But I want to control what window is where!” Why? The very idea of a tiling WM is that the WM figures out what to show you and how. You simply tell it what application has your focus right now and what other applications belong to it (by giving them all the same tag / workspace).

“Xmonad has no stacked layout like wmii! I can not easily put dozens of windows in one column!” Why would you do this in the first place? You certainly can not read them all. Let Xmonad only show you the ones that matter and search for other ones if you need them. Or think about grouping them better. Why open 20 PDFs in separate windows if your viewer can take care of that?

“Xmonad has no title bars.[4] I will miss those!” Are you sure? What do you use them for? The window content itself tells you what the window is. If the content is not visible, then a title bar will only waste space. If you need to find something, let the WM do it for you. If you want status reports, use notifications.

By embracing not complexity, but simplicity, confusion ends. The best solution to a problem is to make it obsolete – as Gordon Bells said, “The cheapest, fastest, and most reliable components are those that aren’t there.”. By concentrating not on “how”, but on “what”, false desires disappear. By letting go off false desires, suffering ends.

guru

[0] Yeah, I have been reading Buddhist philosophy and history again. Can you tell?
[1] The old monks have understood one thing: Truths about reality must be visible everywhere. There can not be any aspect of reality that is not permeated by them. Thus, we can improve our efforts by just focusing on one simple object. Traditionally, one’s breath, a candle or a rock have served this purpose. Some Zen traditions use 只管打坐 (shikantaza, “simply correct sitting”) for this. If you can’t understand reality just by sitting down and concentrating, then reality can’t be understood at all.  Therefore we must be able to see all those Buddhist observations in everything we use, including the most fundamental GUI software – our window manager.
[2] I will focus exclusively on *nix. There are tiling WMs for Windows, OS X etc., but they are all very lacking.
[3] The classical example to demonstrate this is Quicksort. If you have ever programmed something, Quicksort was probably among it, but just to help you remember, I’m gonna tell you again what Quicksort is. We define Quicksort recursively like so: An empty sort is always sorted. To sort a list with at least one element, we take the first element (called the pivot) in the list and then separate the rest into two lists, one containing all the elements that are smaller and one containing all that are larger than the pivot. Now, to get the sorted result, we simply sort the first list, than add the pivot and finally add the sorted second list. Think about how you would solve this in an imperative language. In C, it would go something like this:

void swap(int *a, int *b)
{
  int t=*a; *a=*b; *b=t;
}
void sort(int arr[], int beg, int end)
{
  if (end > beg + 1) {
    int piv = arr[beg], l = beg + 1, r = end;
    while (l < r) {
      if (arr[l] <= piv)
        l++;
      else
        swap(&arr[l], &arr[--r]);
    }
    swap(&arr[--l], &arr[beg]);
    sort(arr, beg, l);
    sort(arr, r, end);
  }
}

This is a typical example – we tell the computer exactly what to do to get the result we are interested in. But remember I said that in a functional language, we tell the computer what something is. I already told you what Quicksort is, so let’s write this down in Haskell:

qsort [] = []
qsort (x:xs) = qsort lesser ++ [x] ++ qsort greater
     where lesser  = [y | y <- xs, y < x]
           greater = [y | y <- xs, y >= x]

And that’s it.
[4]Technically, you can add them, but they are not normally there.

Anti-Buddhism

December 12th, 2009

Today, I’m an anti-buddhist. You know, like an anti-christ, i.e. someone who perverts all christian ideals? Specifically, I have perverted the 4 Noble Truths and broken all 8 principles of the Noble Eightfold Path. How so?

The 4 Noble Truths teach us about suffering and how to overcome it. In short, suffering is caused by our attachement to the world. By wanting things, we suffer because it is fundamentally impossible to fulfill this desire. I have perverted this, for I craved for a bigger desktop. I have assembled 3 monitors where I previously had only 1. I suffered for this, so much is true. (I have suffered a lot. Linux is my own personal hell. I am repenting for very grave sins, it seems.) But, I have overcome this suffering without letting go. I have achieved my goal – I have 3 working monitors. But to do this, I had to break everything on the Noble Eightfold Path.

All my sins are:

  1. Right View – I have forsaken the path of the Console and The One True Display. I have merged 2 monitors into one (via TwinView) and added a third one to watch blasphemous movies while working.
  2. Right Intention – I wanted more screen and more windows. I did not want a simpler, easier display, but visual bloat instead.
  3. Right Speech – I have cursed, of course, but I have also lied. I still lie, for every single application I start is a lie – a lie to my xorg-server. It still thinks the monstrosity, the 2-monitors-into-1 is just one screen, but I run a hacked libXinerama instead that tells every application the truth. The server doesn’t know this, it is completely unaware. Only my conspiring GUIs do. [0]
  4. Right Action – I have broken the holiest of rules – I have downgraded. (I now run X.org 1.6 instead of 1.7.3.)
  5. Right Livelihood – I am a slave in the worst of professions – I maintain my own libraries, ignoring all advice from my package manager.
  6. Right Energy – I have spent a whole 3 days setting this up. Do I need to say more?
  7. Right Mindfulness – I have forgotten the pain of changing my xorg.conf and ignored the past. I will forget today’s lesson and, at some point, patch again.
  8. Right Concentration – I have drunken caffeine a-plenty and spent 2 days fiddling with emacs. I was never focused on my ultimate goal, only ever jumping from idea to idea.

Yet, everything works. (Well, except the actual window manager, but this requires patches that are trivial in comparison.) This whole endeavour must have gotten me massive amounts of negative karma.

[0] http://ktown.kde.org/~seli/fakexinerama/ pure awesome-sauce (my modified version: Xinerama.c)

EMACS 2.0

December 10th, 2009

*sigh*

I’m back-paddling on this. I feel I gave emacs a fair chance. I spent a good 3 days getting used to it, setting it all up and I still can’t get it to do what I want.

I’m going back to vim.

There were many things I really liked about emacs. It provides many great features to make coding easier. Integration of other processes, particularly gdb. A better window and buffer handling. Nicer copy&paste (yank cycling ftw!). All those cute modes, like which-function mode (shows the current function you’re in), glasses-mode (pseudo-converts camelCase into proper_names) and so on.

But, just as often, it stands in my way. I don’t want tabs and I’d like emacs to only use spaces, 4 spaces specificially. I spent 3 hours setting this up and it still doesn’t work nicely. Scrolling is fucked up. Visual editing, i.e. being able to move the cursor anywhere in the file, is not possible. And so on and on. About 2/3 of my config right now consists of disabling some GNU feature I don’t want.

I’ve had it, I won’t put up with this any more. Instead, I’ll port all those cool features over to vim. Well, that was pointless…

Of course, this means I don’t need Control and Meta anymore, so I’m back to my old layout. Yadda yadda yadda.

Escape Meta Alt Control Shift

December 6th, 2009

For the last 4 years, I’ve been a vim user. My vim config is hundreds of lines long, my plugin folder is overflowing. For the last year, I’ve been using wmii as my window manager (before that, awesome), its config is similarly a work of art. I’m using my own keyboard layout, with some additional tools to complement it.

This week, all this changed. At first, I changed my monitor setup, but by doing so I had to modify my window manager and long story short, I’m now using Xmonad and I had a big fight, my last one, with vim and I’m now an emacs user, too. But emacs was the straw that broke the camel’s back, so to speak – I have a meta key problem.

I have way to many of them. I have my normal ASCIIbet, then Shift for capitals, Mod3 for punctuation or programming characters, Mod4 for functions like cursor keys or Return, then Control and Alt for emacs, the Windoze key for my window manager and a special key for my IME. It’s too much! It has now become very cumbersome to type certain things and I have to fix this mess.

Design Principles

  1. Hands should move as little as possible and never leave home row. This is a pretty basic requirement, but it prevents me from moving some rarer combinations to the outside of the keyboard.
  2. I must not give up any functionality. Specificially, I must still be able to type in (among others) French, German and Japanese, be able to programm efficiently and have enough keys left to handle Xmonad.
  3. The computer should do as much work for me as possible. If I can let it figure out what I meant and safe a few keystrokes in the average case, I will do it.

Solutions

First, I use my IME more aggressively than before. I’m currently using scim (with anthy and tables) to input any normal text beyond ASCII. This is pretty normal for Japanese, were you type 黒い猫 (kuroi neko, black cat) by activating Japanese mode, then inputting “kuroineko<SPACE>” and the IME converts this first into syllables (くろいねこ, ku ro i ne ko) and then tries to guess the correct meaning. I have already started using this for German a while ago and now use it for all diacritics. For example, I switch to European mode and then input “Verschw”orung” to get “Verschwörung” (conspiracy). This works pretty well because all diacritics are rare anyway and justify the additional key stroke. Each language (family) has its own mode to keep them simple and because I almost never mix them anyway.

This frees up some keys, and thus, my old basic layout:

basic layout

basic layout (left normal keys, right with Mod3 = M3)

(A few keys are redundant because they started out in a bad position, then moved to a better one and I saw no need to leave the old one empty. As you can see, the Mod3 level has still quite some open positions.)

I can’t move the punctuation characters inside my IME, because I generally mix them with normal text (typing something like “$editor =~ s/vi[m]/emacs/g”) and the IME would slow this down a lot. Inputting something like “\s” for “$” isn’t that cool and breaks many hotkeys. But, as you can see, Mod3 is used twice and in 2 really good positions, forcing me to put at least some meta keys in the outer corners at the bottom, which sucks.

So instead I decided to group them tighter together and move all characters to the right. This way I only need one Mod3 key. The Mod4 key, formerly right of Space, moves to the right of Left Shift. I can still press it with my left pinky and use the keys on the left. This frees more keys and leads to the following layout:

new layout (normal, mod3, mod4)

new layout (normal, mod3, mod4)

This might be a little confusing because I used some lazy abbreviations. The Mod4 level on the left has Backspace, Up, Down, Escape at the top, then Left, Down, Right, Insert and finally, at the bottom, Page Up, Page Down, Return, Tab. On the left are the meta keys Mod3, Mod4 and Win. On the right are Control, Meta and the 漢字 key to activate my IME. All the other keys on the keyboard are unchanged, but I can’t reach them anyway, so I don’t use them (except for numbers).

This arrangement isn’t optimal in the sense that some combos have to be typed by one hand, like ^ as M3 + i, and not all good keys are fully exploited (the left home row is under-used), but this is the best compromise in my opinion. All punctuation on the left side is rare and all frequent ones (and combination, like :) or !=) are easy to reach.

I was also experimenting with separating opening and closing parentheses because emacs (or any other editor) can easily match those anyway, but this doesn’t really improve the setup and makes it a lot more illogical and harder to learn. If it were not for programming, I would actually switch to a pseudo-latin input were similar characters would be merged and the IME would tell them apart, e.g. I would put i, j and y on the same key “i” and let the IME decide which to use. This works all pretty well for normal text, but in virtually any programming language, most letters are used frequently and, as a group, more often than punctuation. Having different layouts for different contexts, however, only makes a big mess.

(You might have wondered why I chose this particular key arrangement. It was originally Neo, a (now broken, see my old rant) German layout. I moved the J, X and Y, and removed all those silly additional levels and German characters, though. If I had to start over, I’d choose something like Dvorak as a base.)