21 September 2009

Opt out of Omniture Tracking

Omniture is a major web tracking company, which is being bought by Adobe. They use the domain “2o7.net” which some people consider pretty sneaky (in particular, because in this font it looks a lot like “207.net” — they use two-oh-seven but it looks like two-zero-seven). If you don’t like the idea of being tracked, follow the link at the end of their Privacy page to set a cookie.

14 September 2009

NSUserDefaults Is Picky

If you’re not programming Mac or iPhone, you might want to skip this post…

I’m saving some state in an array, to be saved via NSUserDefaults. I know that NSArray can’t contain a nil value, but you can instead use [NSNull null]. BUT, property lists save only a limited number of classes, and NSNull is not one of them.

The confusing thing was that NSUserDefaults silently rejected an entire NSDictionary containing an NSArray containing an NSNull, while saving all the other changes I was making. So my testing showed that saving and restoring worked. And worked. And worked. Until the one case where there happened to be a nil. And then loading used the previous state.

So I had to come up with another way to save and restore a C array that can contain a nil. (In this case I was able to use a string.)

12 September 2009

Jukebox in the Sky

For as long as I recall, RealNetworks has called its Rhapsody service a “jukebox in the sky.” These days it’s probably trendy to say it’s your music library in the cloud. The idea is that you pay a monthly fee, and have access to any music you want, wherever you go.

Now that there’s Rhapsody for iPhone, this is finally coming true.

Since I have a Rhapsody account from work, I downloaded the app as soon as it was available, and tried using it to replace the iPod feature of my iPhone 3GS. Searching was straightforward, so I queued up a bunch of music and headed towards the bus stop. That meant I was leaving WiFi for a 3G signal and the song stopped and restarted. And stopped and didn’t restart. Then Rhapsody crashed.

But later attempts worked totally fine. There was one momentary pause, but then the music resumed. And I was able to search and queue up more music while on the bus.

There are still some issues with the software. Rhapsody gave me a “My Music” list that is not my music at all (maybe new accounts don’t get saddled with this). Queuing music is awkward (be sure to press rather than tap if want to actually queue — which I always do — rather than play instantly). And Rhapsody can’t access some hardware features (like the extremely important pause button on the remote) or play in the background.

Is the jukebox in the sky worth $13/month (plus tax), given you’re renting music and have nothing if you end the subscription? I certainly think it’s more worthwhile now that you’re not tethered to a computer, or have to pre-load a crappy player like a Sansa. A touch device with no remote is a pretty crappy player too, though it makes a big difference to be able to manage things on the fly. And it was very cool to pick a song I’d never heard and immediately get to listen to it.

So I think it’s finally worth trying — you can get a 14 day free trial, and the iPhone app is free.

08 September 2009

The Real Difference Between Mac and Windows Programmers

It’s obviously the color of their tools. Leon Bambrick points out that Windows tools are orange. But mine are blue. (OK, you could argue Interface Builder has a little orange. At least there’s an X in Xcode, which I constantly have open…)

(Thanks to Raymond Chen for the link.)

07 September 2009

Clang Is Fast

As I’ve written, the developer tools in Snow Leopard are a great reason to upgrade.

Snow Leopard includes a new compiler, clang. Much of my work involves C++, which clang can’t handle. Which is a bummer, as the static analysis is so useful. But Opal is an Objective-C application, so I tried switching from GCC 4.2. I had to tweak a few things (clang doesn’t like the GCC -Wunreachable-code option), but mostly it gave a few different warnings.

And it’s about twice as fast. On my MacBook Air 2.13 GHz, it took GCC about 58 seconds to build Opal (with its plugins). Clang took about 32 seconds. (This isn’t all compile time — it also includes copying files into the bundle.) I built twice each time in case caching made a difference.

Opal isn’t very compute-bound, so I didn’t notice any speed differences from using the LLVM backend. As for code size, the bundle is 4,463,702 bytes, compared to 4,328,838 from GCC 4.2 and 4,349,342 from GCC 4.0. In many cases, bigger code runs slower, but Apple claims that LLVM generates better code. They pay a lot of attention to performance, so I’m going to believe them on this.

So I’m planning on using clang for the next Opal update.

06 September 2009

How Did Economists Get It So Wrong?

Interesting article by Paul Krugman in the New York Times. But the icing on the cake (and why I’m mentioning it) is that it’s illustrated by Jason Lutes, who did a lot of pencil work on King of Dragon Pass!

Seattle Public Library in CardStar

One of my favorite iPhone apps is CardStar, which lets you put the cards for all those loyalty programs (like the local supermarket) in your phone rather than have to carry around bits of plastic. It displays the barcodes, and the store can scan them. (Most of the time with the hand scanner they use for large items, though you can hand them your phone to pass over the surface scanner.)

It also works with library cards. For the Seattle Public Library, use Codabar AA.