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.

05 September 2009

Snow Leopard Notes

I’ve been using Snow Leopard (Mac OS X 10.6) since official release. See John Siracusa for a very thorough and technical review. I just want to post a few random notes.

I forgot to be scientific about measuring the disk space savings, but I think I got 5 GB back (and I had never installed all the printer drivers). That’s a pretty valuable upgrade right there!

While people have noted it’s a plus that you can now show the date in the menu bar, in fact you don’t get to choose the date format, so it’s not very useful.

It’s pretty cool that Cisco VPN is now built in — the client from Cisco was pretty unreliable. Unfortunately, we use a shared secret that’s only distributed via a .pcf file, in encrypted form. Luckily, there’s a security hole and it’s possible to retrieve the plaintext password. Armed with this, I can use the Snow Leopard client.

I haven’t seen mention of a change in Time Machine: if you back up to a Time Capsule, you’re no longer saving to the top level of the volume but rather using your own account. (The screen shot shows the new approach above the old.) This should make things a little more secure, but it also means your old backup is ignored, and things start from scratch. (I couldn’t really verify Apple’s claims that the initial backup is a lot faster — it still seemed awfully slow over USB Ethernet.) On the other hand, I had to restart the initial backup since I didn’t have enough space for an entire new backup. Once I freed up space, the initial scan was pretty much instant.

So far, most of my software has been compatible (including those I wrote: Addressix and Opal). I was using an older version of Parallels Desktop, which for some reason was not moved to an “Incompatible” folder but won’t launch (with a message that it’s incompatible). I think I’ll be switching to VMWare Fusion.

While there are some features that I appreciate (minimizing windows to the application icon instead of cluttering the Dock), for the most part it’s the same Mac, slightly improved.

Except as a development machine. The new version of Xcode offers some significant improvements for developers, ranging from better Subversion support to new compilers. I’m still in the process of using clang and the updated Instruments to track down subtle issues.

At the same time, one of the most annoying bugs is in the new developer tools: we can no longer use distcc to compile on 8 different machines simultaneously. Apple is aware of the problem.

As a user, it’s not a whizzy update, but I think still worth it. As a developer, I’m really happy to be using the new tools. I’m also hoping that this becomes the new baseline — it would be great to develop for 10.6+ rather than 10.4+.