Instant messaging on Android

I've been using a Nexus One as my primary phone for the last few months now, and I quite like it! Upon reflection, the thing I most like about it, however, is not something I had anticipated at all when I got the phone.

Being able to search the web, read email, run apps, look at maps, and listen to podcasts are all very convenient. Though, there is not much to say about those things: I use those tools in more or less the same way I would use them if I had a laptop with me.

However, being able to send and receive IMs from my phone has been one of a small number of applications that has led to a qualitative change in the way I do things. I'm using IM a lot more now, at the expense of pretty much every other form of communication. And that's because instant messaging is the only mode of communication that actually feels convenient.

You can write and reply whenever you want, not just when it's convenient for the other person (unlike phone calls). You can have rapid back-and-forth conversations (unlike e-mail and voice mail). You can write messages of whatever length you want (unlike SMS). You can communicate unobtrusively, e.g. in a library (unlike phone calls and voice mail). You can read messages without going through an absurd interface (unlike voice mail). Your messages reach you on whatever device you're using— desktop, laptop, or phone (unlike phone calls and SMS). It doesn't cost an exorbitant amount of money (unlike SMS). (As for video calling, it has pretty much all the disadvantages and restrictions of voice calls, plus some more. It's a cool tech demo, but not something I expect to use on a day-to-day basis.)

If you think about where and when and how you can use each mode of communication, IM matches or surpasses pretty much everything else on most axes. Sometimes you need the phone or email for a high-bandwidth conversation or to deliver a large payload. But those occasions are getting to be few and far between.

Part of it is just the medium— IM is as synchronous or as asynchronous as you want it to be— but a good part of the goodness here is thanks to Android's implementation. You can dictate messages with your voice; for short common messages (e.g. "call me when you get home") it works quite well, so you can dash off quick messages using whatever modality is more convenient, keyboard or voice. And the Android notification system notifies you of new messages and lets you bring up conversations easily— but discreetly, without interrupting whatever else you are doing on the phone.

For me, IM is the killer app for carrying a smartphone in my pocket, ranking significantly above "browsing the web" and a fair amount above "making phone calls".

(Incidentally, the words "phone" and "smartphone" seem so inadequate after you have come to fathom this super-communications capability you have on your hands.)

Zeya 0.5

I'm pleased to announce the release of Zeya 0.5 (also— Hello, Reddit!).

Major changes since Zeya 0.4:

  • Playlist support. The 'rhythmbox' and 'dir' backends detect playlists you've saved (in Rhythmbox or as M3U/PLS files, respectively) and let you choose from among them (using the dropdown in the upper left corner).
  • PLS format playlists are now supported by the 'playlist' backend. The format of the playlist (M3U or PLS) is guessed automatically based on the extension. (Amit Saha)
  • Support for decoding m4a files. (Rainer Hahnekamp)
  • Bind Zeya to a single interface only with the new --bind_address flag. See the cookbook for more info. (Björn Lohrmann)
  • More UI.
  • Bug fixes. Zeya now "just works" under a wider variety of circumstances. (Samson Yeung and others)

Known issues:

  • The 'dir' backend doesn't work with Python 2.5. A fix has been checked in at git HEAD.

See http://web.psung.name/zeya/ for more information about Zeya, installation, getting started, and reporting bugs.

Thank you, Ubuntu

Ubuntu 10.10, the Maverick Meerkat, will be released in just a couple of weeks. That got me reflecting on the fact that I have been a happy user of Ubuntu for what must be over 5 years now. That's a long time!

The GNU/Linux variants are the only OSes I've used where I really have the flexibility to define my own workflow (example). So they are a pleasure to use (ok, most of the time). I use a computer for many, many hours a day nearly every day. And the time spent customizing software and learning it is a drop in the bucket when it's amortized over the months and years I'm going to spend using it. Sure, Windows and Mac OS are a bit more learnable and easier to get started with— but they are much less usable. And for me, and most other people who sit at a computer for a living, that is precisely the wrong optimization to make.

There's plenty more to love about Ubuntu: for starters, that it runs on every piece of hardware you throw at it; how with a modest amount of effort, you can make all the computers you use behave exactly the same; and how great apt is (really, it takes the fear and hassle out of installing software, and it's an experience that no proprietary desktop OS comes close to).

Ubuntu is far from perfect, but it is pretty marvelous, and all the GNU/Linux operating systems have come a long way in the last 5 years. When I step back, I'm a bit astonished that Ubuntu or anything like it even exists at all. It works, it's powerful, it's free of charge, and, with small carve-outs, all of it is free for anyone to do anything they wish with it.

One thing I rarely stop thinking about is how technology can be made to be an instrument of empowerment. And I believe that one necessary step in that direction is ensuring that you are the master of all these amazing devices you carry around with you all the time: that they serve you and carry out your will, and not the other way around. Ubuntu has this vast collection of software you can use as the substrate for doing anything, and the question isn't "Will the creators of this software give you permission to do this?" but rather "Who the hell is going to stop you?".

I find this an incredibly heartening idea, almost a cousin of the concept of Turing's universal machine— the possibility, realizable in software, that you are limited by nothing other than your imagination. Unfettered computation is really a magical thing. And Ubuntu is a wonderful demonstration of that assertion, though by no means the only one.

So, to everyone that helped to make this possible (Canonical; the Ubuntu community; Debian developers; kernel developers; upstream maintainers and contributors of all stripes; and yes, even the folks working on other downstreams, like RH/Fedora— your code makes its way into Ubuntu too):

You have truly helped to make something wonderful, and it's a real gift to humanity. Thank you.

Guava

A public service announcement for Java programmers.

Google has released as Free software a bunch of convenience libraries used internally in Google Java code. The project is (very cleverly) called Guava.

The libraries span a huge range of functionality, but I think that in general they help to promote a more functional programming style and they paper over some of Java's warts.

Here are three of my favorite things from Guava, but if you read the Javadocs you will undoubtedly find more cool stuff. Looking at all of this, you might decide that it's all simple stuff that you could implement yourself in about five minutes. Of course you could (in some cases, anyway), but why would you?

Immutable collections

Create an immutable list (as you might recall, every Java array is mutable, which can be a huge source of pain):

List<String> answers = ImmutableList.of("yes", "no", "maybe");

There's also a Builder pattern for more complex constructions, and analogous classes Immutable{Map,Multimap,Set,SortedMap,SortedSet}.

Collection factory methods

Here's some standard Java code to instantiate a collection:

List<Foo> foos = new ArrayList<Foo>()

Using the Lists class, you can rewrite that as the following:

List<Foo> foos = Lists.newArrayList()

Usually factory methods are a way for you to give the callee the flexibility of returning different classes at runtime. That's not the case here— Lists.newArrayList will always return an ArrayList (unsurprisingly). But Java does type inference for a call of this type, so you save the hassle of having to repeat yourself by writing the generic type Foo on both sides of the assignment, every time you create a new collection.

There are analogous classes Maps and Sets, which also contain other useful utilities in addition to these factory methods.

Splitter

Some simple illustrative examples for splitting a string using Guava's Splitter class:

Splitter.on(",").split("foo,bar,baz");
// ==> an iterable containing "foo", "bar", "baz"

Splitter.on(",")
    .trimResults()
    .omitEmptyStrings()
    .split("foo,bar , baz,,,");
// ==> an iterable containing "foo", "bar", "baz"

But wait, doesn't Java already do string splitting? Yes! Yes, it does. And this is how (emphasis mine):

String.split

public String[] split(String regex, int limit)

Splits this string around matches of the given regular expression.

The array returned by this method contains each substring of this string that is terminated by another substring that matches the given expression or is terminated by the end of the string. The substrings in the array are in the order in which they occur in this string. If the expression does not match any part of the input then the resulting array has just one element, namely this string.

The limit parameter controls the number of times the pattern is applied and therefore affects the length of the resulting array. If the limit n is greater than zero then the pattern will be applied at most n - 1 times, the array's length will be no greater than n, and the array's last entry will contain all input beyond the last matched delimiter. If n is non-positive then the pattern will be applied as many times as possible and the array can have any length. If n is zero then the pattern will be applied as many times as possible, the array can have any length, and trailing empty strings will be discarded.

This is a bizarre and unmemorable edge case in the API. I guarantee that upon finishing this paragraph, you will promptly forget about it until about two hours into debugging a failure caused by it. You can save yourself some grief if you just use Splitter. Stay away from String.split.

Thinkpad TrackPoint Scrolling in Ubuntu Maverick/10.10

Update: these steps seem to work on Ubuntu Natty/11.04 for me, as well.

My fellow citizens, our long national nightmare of having to use bad pointing devices is over.

Starting with Ubuntu Maverick/10.10, configuring scrolling with the middle button and the TrackPoint is now really easy:

  • Install gpointing-device-settings (sudo aptitude install gpointing-device-settings)
  • Run gpointing-device-settings &, enable the Use wheel emulation using button 2, and enable both vertical and horizontal scrolling.

(gpointing-device-settings is not new but Maverick is the first time it has really worked well for me.)

Update: some people are reporting that g-d-s settings are lost after suspend. If you run into this, you might try these alternative instructions.

Designing for colorblindness

Public service announcement: some 8% of men have some form of colorblindness.

A couple of people have pointed me to this nice article on colorblind-friendly design, by Masataka Okabe and Kei Ito. Useful reading for anyone who designs for print, presentations, or UIs.

It's a good overview of the underlying theory/physiology of colorblindness and gives many tips for conveying information through channels other than color.

The authors also provide this handy colorblind-friendly color palette:

Backups and rdiff-backup

I always thought nearlyfreespeech.net's advice on backups was good advice:

You should adopt a backup policy that assumes we are storing crates of sweaty dynamite on top of the servers that hold your important data. (Even though we aren't.) [NFSN FAQs]

If you only have one copy of something, stop what you are doing, obtain a disk, and replicate it.

Here are some brief notes on my backup setup, including some things I've learned since I last wrote about backups. (I had a disk failure last December and restored everything from backup. No tears, no sweat. In fact the exact same thing seems to happen about once every year, which I suppose is a good testimonial. I'm probably due for a disk failure real soon now.)

  • My first line of defense is backing up to a secondary HDD in my machine. I mostly use rdiff-backup now (and only rsync for huge files, like disk images). This system seems to work well. rdiff-backup creates reverse diffs on each backup so you can retrieve old versions. All the diffs go in the rdiff-backup-data subdir; if you remove that you just get a plain mirror, like what rsync would do.
  • I wrote a FUSE filesystem, rdiff-snapshot-fs, that displays rdiff's repository format as a series of mirrors in order to make it easier to browse historical snapshots. Doing a restore of individual files from time to time is key to ensuring your system is working when you really need it.
  • Rather than scheduling backups with cron and having to leave my computer on at night or, alternatively, having backups happen while I'm working, I bound a hotkey to a script that backs up and then puts the computer into suspend. I run it when I leave the computer for the day, every day.
  • I also rsync to other backup backup locations, including a portable HDD that stays in a safe place when I'm not using it.
  • When restoring from a mirror, the -c flag to rsync is useful. It makes rsync compare the checksum of the data being copied back with the checksum of the original. Then if you have multiple backups of the same stuff you can easily identify and reconcile any differences between them.
  • I did try rsnapshot. Unfortunately it caused my system load average to shoot through the roof, making the system unresponsive while backups were being made. I have no idea why this is but a few other people have reported the same thing.