Jan 01

In mid November, our contract with AT&T (formerly Cingular) expired. We switched to T-Mobile and got BlackBerry Curve phones.

I was a BlackBerry skeptic for a long time. I didn’t think I wanted a phone with a full QWERTY keyboard. This changed when we looked at the phones available. It turned out that the Curve was only marginally wider than the average phone, perhaps a centimeter or so. It’s otherwise comparable to mid-range phones in size. It ends up being pretty much as portable as our Sony Ericsson Z520a phones.

The BlackBerry UI is best described as “retro”. The icons look like 1990s Windows, the text fonts look like 1980s Atari ST, and the general method of navigation most resembles Palm OS. This is both a good thing and a bad thing. Starting with the good, the UI is clearly designed from first principles to work well on a handheld device. The central trackball handles scrolling, pointing and clicking. It sits easily and naturally under the thumb. You can do pretty much everything with one hand, including browsing the web and checking e-mail.

This is in marked contrast to the iPhone, which pretty much requires two-handed operation. Windows Mobile devices suffer from having a desktop UI squeezed into a handheld form factor, and also require two hands, and often a stylus. Symbian is designed for phones, but the UIQ interface for smartphones uses a stylus. Overall, then, the BlackBerry works better than other phones I’ve tried when you’re standing in an airport with a coffee in one hand.

On the downside, it’s hard to find the icon you want in a hurry, because of their visual clutter. Perhaps a replacement UI theme would help; I’m a little tempted to grab the theme designer and start working on one, but it’s Windows only. The fonts were initially problematic too; nowhere near as nice as Apple’s, and they took some getting used to.

But when it comes time to reply to an e-mail, niggling issues with fonts were forgotten as I got to grips with the keyboard. Yes, it requires both hands, or more accurately both thumbs. It’s not as fast as a full size keyboard, but it’s faster than Palm Graffiti or Windows Mobile pen input, and much faster and less frustratingly error-prone than I found the iPhone’s on-screen keyboard to be. Unless Steve relents and allows a Son of Newton to use the Newton’s non-cursive text recognition, I can’t see it being bettered.

Textual messaging is where the BlackBerry really shines. It’s quite possible to thumb out fairly lengthy e-mail responses, or even update your web site. As far as IM, there’s support for Google Talk and AIM built in, as well as Yahoo Messenger, Windows Live Messenger and ICQ if you know anyone who still uses only those. There are third party clients for non-Google Jabber and other protocols, and in addition, there’s BlackBerry’s own BlackBerry Messenger, previously called PIN messaging.

If you have a friend who also has a BlackBerry, PIN messaging is definitely the way to go. The manual doesn’t cover its benefits, so I’ll digress a little here. Unlike other IM systems, PIN messaging is tied to the BlackBerry device by a unique ID. You connect with another person initially by sending them an invite via their BlackBerry-specific e-mail address, or any other address they access via BlackBerry e-mail. When they reply, their device records the device ID you sent, and sends you theirs.

The primary benefit of PIN messaging is that it’s push-based. The recipient doesn’t need to be logged in. If their phone is switched off, the message will be queued until they log on.

The second benefit of PIN messaging is that it’s reliable. Unlike SMS, messages don’t get randomly dropped. In addition, you get delivery confirmation automatically for every message: when you hit enter, the line you typed appears in the transcript with a small icon next to it indicating that the message is going out over the network. When your device receives positive confirmation that the recipient’s device has displayed the line you sent, the icon changes.

If that’s not enough, there’s a third benefit over IM or SMS: there’s a separate “ping” option. So you can set up your regular notification to be something discreet, and know that your spouse can ping you to set off something more noticeable if necessary.

Other than that, PIN messaging has the usual file transfer, allows you to send voice memos, and looks and behaves like regular IM. For us, it has completely replaced SMS, not least because it doesn’t cost 15¢ a message.

One interesting feature of the BlackBerry is that as well as individual icons for each messaging system, there’s also a unified inbox that shows IM, SMS and e-mail in one place. This makes sense, as they all have pretty much the same UI on the Curve; the protocol is almost an irrelevant detail. I believe that if you attempt to send pictures via SMS, the phone automatically uses MMS, but I haven’t tried it.

Web browsing is a mixed bag. The built in BlackBerry browser has two modes, mobile mode and “desktop” mode. Although there are references to WAP, the browser copes with both, the mode just determines how the page is formatted for display. In mobile mode it works like a typical phone browser, in desktop mode it tries to deal with things like tables, CSS and JavaScript. Overall it makes for a pretty good browsing experience, as phones go. (If you haven’t tried browsing from a phone, the main issue isn’t usually layout–it’s latency. Each page request takes a ridiculously long time to send, compared to a desktop system. I assume this is something to do with the mobile network.)

An alternative is Opera Mini, which takes the “thumbnail of page with moveable active area” approach to web browsing. It works surprisingly well with sites that the built-in browser can’t cope with, like zagat.com. (Yeah, good move, make a web site of restaurant reviews that doesn’t work with a phone browser.)

Maps are another strong point. There’s a map application supplied, but I downloaded Google Maps for BlackBerry, which is free and offers pseudo-GPS location by correlating your active cell to its geographical location. Accuracy can be as little as 50m or so in cities, up to 1km in the countryside. The Google Mail application also works well once downloaded.

The BlackBerry OS appears to be Java based, and is pretty solid. It’s more reliable than a Palm; I’ve only managed to crash it once, which is comparable to Linux on the N800 in solidity. Initial bootup (after inserting a battery) is horrendously slow, but once running it seems to use a soft power off which doesn’t require a full boot. The UI is generally responsive at all times, unlike some Sony Ericsson phones. You can put the phone into standby mode by holding down the power switch. In standby the screen and keyboard deactivate, but you can still receive messages and calls. The same hold-down-button action brings the phone out of standby instantly.

The one bug I’ve found so far is in the BlackBerry web browser. After a while the cache gets full and slows browsing down tremendously. The workaround is to empty the cache once a week.

The phone shows a lot of attention to the details of how a mobile device should best operate. For example, an ambient light sensor behind the notification LED turns the screen brightness down in dark areas, and automatically turns on the keyboard backlight. The LED itself has behavior customizable through the notification options; each event (phone call, IM, SMS) can have any or all of a user-chosen sound, vibration, and LED flashes. You can even set different messaging systems to have different notification; for example, I have IM just flash the LED a few times, unless it’s a PIN message from the spouse.

Mac sync is a bit of a sore point. There’s a package called PocketMac that BlackBerry purchased and now give away for free. It worked for me, more or less, but had some annoying bugs. (For example, syncing with a subset of address book records didn’t work, and editing records on the BlackBerry resulted in duplicates.) The solution is simple enough: Mark/Space have a Missing Sync for BlackBerry, which makes everything work, and even syncs user pictures so you can see the face of the person calling you if you’ve given them a picture in OS X.

Overall, it’s the best mobile phone I’ve used. Whether it’s good for you will of course depend on your use cases. If you’re someone who likes to talk to people or use voicemail rather than IM or e-mail, or if you have little patience for customizing software, the iPhone is probably a better bet. It certainly look prettier. But if you prefer text to voice and prefer functionality to prettiness, the Curve beats the iPhone hands down. This may change once they stop crippling the iPhone and open it up to third party applications; we’ll see. For now, I’d pick the Curve again, even if the iPhone wasn’t tied to AT&T.

Update: Oh yeah, the Curve is also a quad band phone. That’s de rigeur, so I didn’t even think it was worth mentioning.

Oct 23

One of the things I found confusing about bash was its startup scripts: there were so many of them. Eventually I snapped and sat down with a terminal and the man pages, and worked out how it actually behaves. Here’s a summary.

Interactive
login
Interactive
non-login
Non-interactive Remote shell
/etc/profile A      
/etc/bash.bashrc   A†    
~/.bashrc   B   A
~/.bash_profile B2      
~/.bash_login B3      
~/.profile B4      
~/.bash_logout C      
BASH_ENV     A  

On startup, bash executes any script labeled A in the table above, followed by the first script B it finds. On exit, it executes any script labeled C above.

Let’s look at the column headings in a little more detail.

  • An interactive login shell is a shell that you are typing into, that is the first such shell you execute on the machine. Typically you will have had to log in immediately before the shell starts. For example, when you SSH to a remote system and type commands to that system, you are typing into an interactive login shell.
  • An interactive non-login shell is a new shell started once you have already logged in; one which doesn’t require that you log in again.For example, if you open a new terminal window in your graphical user interface and get a shell prompt, that’s an interactive non-login shell. Another example of an interactive non-login shell would be a sub-shell started from inside a text editor; for example, typing :sh in vi.
  • A non-interactive shell is a shell which doesn’t prompt you; it just runs a program and then exits. The most common example of this is any program written in shell script, such as a configure script, a startup script in /etc/init.d, or any other file marked as executable that has #!/bin/bash on the first line.
  • A remote shell is a shell started by a program such as SSH or rsh in order to run a command on a remote machine.For example, the rsync and scp commands use SSH remote shells in order to copy files between machines.

So looking at the second column, an interactive login shell will execute /etc/profile always. It then looks for ~/.bash_profile, ~/.bash_login, and ~/.profile in turn, and executes the first of those it finds. On logout, it executes ~/.bash_logout.

The /etc/bash.bashrc A† item is special; whether bash searches for it is dependent on a compile-time option.

BASH_ENV is an environment variable which allows you to make non-interactive non-login shells (such as shell scripts) execute a startup script. Set BASH_ENV to the filename of a script and then invoke a sub-shell, and the script will be executed when the sub-shell starts up.

Problems with bash’s behavior

Given the above table, the short summary is:

  • If you want something executed only when you first log in, put it in ~/.bash_profile
  • If you want something executed only for additional shells (such as OS X terminal windows and xterms), put it in ~/.bashrc

But there are a couple of problems with this arrangement, problems which suggest that bash’s startup behavior wasn’t really thought out with users in mind.

Firstly, if you are anything like me, most of the things you want to put in shell startup scripts are things you always want executed. Command aliases, for example; or environment variables that tell pieces of software where to find their bits (JAVA_HOME, ECLIPSE_HOME).

You could put those in both .bashrc and .bash_login, but that represents a maintenance problem: if you change something, you have to remember to change it in both places. So, you might set up a third file for global stuff, and use the shell command source to read it in from both .bashrc and .bash_login. I’ve seen some Linux distributions set this up as the default. I don’t like it, however, because it means you now have 3 different startup files floating around, and when you want to change something you have to remember which file it’s in (or sit and work it out).

The second issue with bash startup scripts is that the distinction between login shell and non-login shell isn’t a very useful one these days. Most of us use graphical user interfaces, so we never see a login shell on the machine we’re using. (For example, any terminal window you open on OS X is a non-login one.) Even when I use SSH to shell into a remote system, I don’t generally want that first login to behave differently to any other shell I start (such as shells inside screen).

What I do care about, on the other hand, is whether the shell is interactive. I don’t want my reminder program printing stuff when rsync is trying to connect and transfer files. I don’t want all my custom commands and aliases getting in the way when running scripts to configure or build software. And I don’t want to slow things down loading cdargs unless I’m actually going to be maneuvering around the directory structure by typing.

So what I want is to have a single customization script, and be able to split it into stuff that is always run, and stuff that is only run when I’m using the shell session interactively. Here’s how to do that.

Simple all-purpose bash initialization script

Start off by moving all your current bash startup scripts into a temporary directory, so you have a clean slate. Then, create a skeleton ~/.bashrc that looks like this:

### Start of universal section ###
# Commands in this section will be executed by both interactive and
# non-interactive shells.
# Commands here must produce no output, or they will break commands
# like scp and rsync.

### End of universal section ###
[ -z "$PS1" ] && return
### Start of interactive section ###
# Commands in this section will be executed only by interactive shells.

### End of interactive section ###

Next, cd ~ if you’re not already in your home directory, then ln -s .bashrc .bash_login

Now you have a single customization file for all your shell sessions, called ~/.bashrc. You can copy in each command from your old customization files, placing them in the appropriate section according to whether you need them all the time, or just in shells that you’re typing in to.

If you really care about login shells

If for some reason you do want to have login shells behave differently from non-login, that’s pretty simple too. Instead of the ln -s command above, create the following ~/.bash_login file:

if [ -f ~/.bashrc ]; then
  source ~/.bashrc
fi
# Commands for login shells only go under here

Now you have two places customization commands may be placed, but you get the option of having login-specific stuff.

Dealing with multiple systems

Another trick I use is to examine the host name of the machine. This lets me use the same .bashrc everywhere; my Mac’s .bashrc is the same as the one I use on my Linux box and the System z mainframe at work. Here’s the code:

if [ "$HOSTNAME" = "T41p" ]; then
  # Customizations specific to the ThinkPad laptop go in here
fi

You can use code like this in either the interactive or non-interactive section of the .bashrc above.

Aug 05

In a few years, cameras will all have single chip GPS units in them. They’ll tag their photos with the location where you took them as a matter of course, like they already tag the time and date.

Some of us are unwilling to wait a few years. I’m sure you, like me, have sat down with a map and a stack of holiday photos and thought “OK, where on earth was that building?”. My current project of scanning and annotating hundreds of old family photos would be so much easier if I could have some clue as to at least the location and the year.

Which is probably why Sony have just launched a rather neat keychain GPS. No display, not many controls, you just clip it to your bag and forget about it. At the end of the day you connect it to the computer, run some software, and your photos are annotated with location information.

However, you don’t need a special Sony GPS for that. There’s a handy Mac application called GPSPhotoLinker that will download the automatic track data from a Garmin or Magellan GPS, cross-reference it with the timestamps on a bunch of photos, and re-write their EXIF information to add longitude, latitude, city, state and country.

We tried it out in Austin on Wednesday. It seems to work quite well, so we’ll take the GPS with us when we go to Germany.

As well as embedded EXIF tags, known as geocoding, there’s also the cruder hack of geotagging, where you add the latitude and longitude as Flickr tags. While this avoids the problem of dumb software stripping EXIF information, it messes up your Flickr tags page and relies on Flickr, so I’m not keen on it. I want my metadata in the file with the image, where it belongs.

Jun 06

It wasn’t much fun following Apple during the 90s. The transition from mono to color was painful, as it involved whole new chunks of OS and a different processor. The transition from Motorola 680×0 to PowerPC was also ugly and painful, and a lot of software simply stopped working and was never fixed. Those of us who had 680×0-based Macs quickly found them made forcibly obsolete long before they would normally have become unusable. Then came OS X, and a bunch more machines were forcibly obsoleted, more software broke, and more developers gave up.

Things have been looking pretty good in the Apple world recently, though. The technically adept have been flocking to switch to the Mac, the OS keeps getting faster and better rather than bigger and flakier, and open source and Java software now runs better on OS X than on Windows.

And now, here we go again. Except that this time, it’s going to be much worse. Whereas PowerPC processors were able to emulate 680×0 at acceptable speed, it’s going to be a lot tougher to try and emulate a 3GHz PowerPC G5 on any kind of Intel chip, even the kind shipping next year. Everyone who uses Metrowerks CodeWarrior for their Mac development (i.e. all those big old legacy Carbon applications from the 68K days) is going to be out of luck, as they’ll first have to drag their entire codebase over to Xcode, and then spend weeks (according to Jobs) fixing up the code. So one thing’s for sure–we’ll be waiting years for another release of Quark XPress this time, too.

The core problem is that the x86 is a lot less like the PowerPC than the PowerPC is like the 680×0. For starters, the x86 stores all its numbers half backwards and half forwards–the least significant bytes are stored first, but within a byte the most significant bits are stored first. (That kind of ugliness is fairly typical of Intel designs, which are legendarily unpleasant to program for at low level.) Any program that does bit or byte manipulation is likely to break. The PowerPC also has a lot more registers than the x86, which means that emulation is tough.

Ultimately, though, the fact that the x86 is a hideously ugly design doesn’t matter too much, because hardly anyone touches machine code these days.

Still, will Apple be able to pull off this kind of screwing around with their developer and user communities again? I don’t know. The more interesting question is why they are willing to risk it. With Nintendo, Sony and Microsoft all using PowerPC cores in their next-generation console systems, it really seems like a strange time to switch to Intel CPUs. Plus, if you want an x86 with PC-crushing performance and price, why not choose AMD rather than Intel?

One possible reason is that Apple is strongest in laptops, and IBM has singularly failed to deliver a G5 that can be stuck inside a laptop. AMD isn’t all that in laptops either, which would explain why Intel. But then again, there’s no reason why laptops can’t continue to use the G4, save for the perception that the G4 is “obsolete”, a perception which Apple itself has to take the blame for. Jobs says that there are no plans for improvements to PowerPC for the next few years. I don’t know whether that’s true or not; we’ll see.

Then there’s the intriguing possibility that Apple would like users to be able to run WINE. On the one hand, people could then switch to a Mac and still run their Windows software on it, for free. On the other hand, who would bother to develop Mac software if everyone could run Windows software? One possible answer might be to bring back Yellow Box for x86, which allowed Cocoa (NeXTStep) software to run on Windows. Still, even without WINE, software developers might just say “Hey, you want to run our software on your Mac? Just dual-boot into Windows!” (Jobs has already said that they’re not going to do anything to stop people running Windows on the Mac.)

So WINE on the Mac and Intel CPUs in the Mac could either be a colossal disaster that will kill the platform, or the best thing to ever happen to the Mac. I’m not going to pretend I know which is the case. I do know one thing, though: I’m sure as hell not going to buy a new Mac now, and I had been hoping to upgrade some time during the next year. No, I’m going to sit quiet and see what happens. I’ll want to see all my core applications available in native x86 versions, and an x86 based Mac that blows the doors off the G5, before I spend more money on Apple hardware. And as with the last round of turmoil (the switch to OS X), if it all goes disastrously wrong I’ll just switch to Linux everywhere.

Nov 03

People often wonder if they should turn their computer off, or leave it on but put it into “sleep mode”. I decided to do some analysis a while back, here are the results.

If you look up the specs, a Sawtooth Power Mac G4 in deep sleep uses about 4 watts of electricity. In MA you pay $0.04823 per kWh, so it costs 4 / 1000 kW * 24 hours * 365 days * $0.04823 = $1.68 per year to leave a Mac sleeping instead of turning it off. So, it’s not going to break the bank.

Heat-wise, conservation of energy tells us that no more than 4W of heat is being emitted by the machine. Compare that to the average human body, which radiates 50-100W (estimates vary, Google if you feel the need to check). So, the G4 isn’t going to heat up the room significantly when it’s asleep either.

What about the environment? Well, let’s assume the worst possible case, that your electricity is all coal-generated. That means emissions are around 0.43kg per kWh of electricity used by the consumer. So in a year of sleep, your Mac would cause the emission of 15kg of CO2. Sounds pretty bad, doesn’t it? Well, according to space research you produce 1kg of CO2 per day by breathing, or a massive 365kg per year. So the Mac is 20x better for the environment when asleep than you are.

What about the hardware? Well, in deep sleep almost all the hardware is powered down exactly as if the machine was turned off. The hard drive, which is the piece most likely to wear out, is powered down. The CPU and RAM are incredibly unlikely to wear out even if you run them 24×7 for the next ten years, at which point the machine will be so obsolete it’s worthless. So turning the Mac off won’t make it last any longer or protect your ‘investment’.

So, I conclude that there is absolutely no economic or environmental need to turn your Mac off. If you have a UPS, you may as well leave the Mac asleep when you’re not using it.

Of course, if your computer is a PC which doesn’t have an Energy Star “deep sleep” mode, the above calculation may be off by a factor of 10 or more. However, most PCs are now Energy Star.

Sep 15

Spent most of Sunday afternoon hacking on ElectricSheep to try and get it working on OS X again. One of the developers had e-mailed me asking if I could help. It turns out that the OS X version was developed as a ground-up reimplementation, which isn’t exactly ideal from a maintenance point of view. I’m trying to improve that a bit.

Dec 12

I’m submitting SnowSaver to Info-Mac. That should hopefully get it mirrored all over the globe within the next day or so.

Jul 19

Q: Will the new for-pay .mac service be more reliable?
A: No.

Q: Will there be a phone number to call for technical support?
A: No.

Q: Will there be an e-mail address to report outages?
A: No.

Q: Will there, in fact, be any support at all?
A: No.

Q: Will the 100MB of storage come with an increased bandwidth limit for web sites?
A: No.

Q: Will you be telling us what the bandwidth limits are?
A: No.

Q: Will you support CGI, servlets, JSP, or anything else beyond static HTML files?
A: No.

Q: Will I be able to get access to my web logs?
A: No.

Q: What about backup—our files are safe if we back them up to iDisk, right?
A: No. Apple does not guarantee the integrity of any files on iDisk, even if placed there by the Apple Backup software.

Q: Well, we can at least use the Backup software to back up our computers to CD-R, right?
A: No, not if you have any files bigger than 650MB.

Q: What about using my external tape drive, DVD drive or Firewire hard drive?
A: No, Backup only works with Apple-supplied internal drives. And only if you’re a .mac member.

Q: So the backup software doesn’t back up from my local hard disk to my local CD burner, unless I have a .Mac membership and an active net connection?
A: Correct.

Q: OK. The service also includes anti-virus software. Are there any Mac OS X viruses at all?
A: No.

Q: If I don’t use Microsoft Office, do I need to worry about macro viruses?
A: No.

Q: Umm… OK. So how much for this invaluable service?
A: $99 a year. Plus tax. In advance.

Q: Can I get two accounts, for me and my wife?
A: Sure, that’ll be $198 plus tax. In advance.

Q: No, I mean can I get a second account cheap if I buy one?
A: Oh, alright then, quit whining. You can get a second account for $10 a year if you buy one full account.

Q: And it’ll have the backup, anti-virus, and web functionality?
A: No, only an e-mail address.

Q: Ah… but at least it’ll be a full e-mail account, right?
A: No, you’ll only get 5MB of space. But that’s nearly enough to hold five days’ spam.

Q: Is there a satisfaction guarantee?
A: Yes. Apple reserves the right to terminate your access to the online services and the software, without cause, without notice and without refunding your money, if it’s not satisfied with your behavior.

Q: What kinds of things am I not allowed to post on my web site?
A: Anything “lewd” or “vulgar”, anything “embarrassing” to anyone, or anything that counts as advertising for any product or service.

Q: So you want $99 a year for an e-mail address, useless backup software, anti-virus software I could buy for $50, and web space limited to inoffensive pictures of fluffy kittens? $99 even if I only want to keep the lifetime e-mail address that you previously said was free?
A: Yes. Pay up now, in three weeks we’ll delete your files and bounce your mail.

Q: I have one more question… What exactly are you smoking out there in Cupertino?
A: I think it’s crack.

May 10

The iMac appears perfect. No dead pixels that I can see, no loose screen arm, no problem powering up…

Sometimes reading Macintouch I think that there must be another Apple Computer releasing completely different products. Like a version of OS X that’s unbearably slow, and a DVD player that won’t play DVDs.

May 08

My iMac just shipped…

…from Taiwan?!