Mobile dev trade-offs: emulator vs simulator

Along with other projects at StatusNet, I’ve been poking at the mobile version of our open-source client reference implementation (still in pre-alpha but getting usable for desktop version). We’re building the client with Appcelerator Titanium, a JavaScript-based cross-platform toolset for development and packaging; the desktop version uses a WebKit-based HTML environment, while the mobile versions use a thin bridge between JS and native controls.

There are some differences between the JavaScript and native bridge implementations between the different target platforms, but cleanly-written backend code can be shared between all platforms, and we’re able to use a single codebase for the mobile UI on both iPhone and Android.

The fun part, though, is with testing and debugging. I’m doing most of the mobile development on my MacBook Pro since I can test both current mobile targets in their respective emulators or real devices from there.

The Android experience

There are several really nice things about the Android SDK setup. First off the download isn’t a bandwidth-shattering 2.3 gigabyte disk image. :) Once installed, I can create custom emulator images with particular combinations of screen resolution and API versions. And, of course, I don’t have to pay $99 and set up a bunch of code-signing keys just to run my test app on a real device!

Android’s SDK emulator is a real, honest-to-god emulator, built around the amazingly versatile QEMU. (I remember using QEMU to simulate an x86_64 system back before I could afford one! Oh the memories…) It runs a complete virtual ARM-based system, booting up a full Linux kernel and Android userland environment.

The good thing about this is that you’re going to be running the exact same real actual code that you’d load onto a real system.

The bad thing is that it takes fricking FOREVER to boot up. Even on a fast modern desktop CPU, emulation is a bit sluggish… booting and general UI actions feel much slower in the emulator than on my Nexus 1 with a 1GHz Snapdragon CPU. And if you accidentally close the emulator you have to wait for it to boot up before relaunching your app…

It’s actually faster in many cases to plug in an Android phone and launch it there. With USB debugging enabled, a native phone can be treated much like the emulator, and Titanium’s wrapper on the SDK can install and launch my app remotely just as quickly as on the emulator — but without waiting for it to boot.

The iPhone experience

Apple went another direction with their iPhone SDK, which has some pluses and minuses. Rather than a true system emulator, the SDK contains an “iPhone Simulator” application, which runs much of the iPhone OS userland as native Intel code on the host system.

The downsides are obvious: you have to compile separately for the simulator and the real, ARM-based devices. Subtle bugs can arise from differences between the systems at both high and low levels. Low-level optimizations such as assembler or vector code won’t even compile, much less run (though that at least isn’t an issue for our JS-based code! ;) An emulator wouldn’t have the same performance characteristics, but could help you confirm that  your math is right before sticking it on a real device.

But there are some upsides: most important to me, the simulator launches nearly instantly. This makes a big difference when you’re working in a rapid-development environment without a good debugging infrastructure; working in Titanium’s JavaScript involves a lot of ‘poke in this line of debug to find out wtf is going on, then fix it’ and I might have to restart the app over and over and over while working with it…

The thing that’s amusingly poor with the iPhone is launching the app  on a physical device. Thanks to Apple’s tight restrictions on app distribution, running your own program requires buying into Apple’s developer program ($99/year), setting up code-signing keys, an dropping a bunch of certs into iTunes so it’ll be willing to copy your stuff over. The Titanium developer tool can then recompile your app (this time for ARM) and shove it over to iTunes, which performs a sync of your phone to copy the app on. This is kind of annoying if you have a bunch of random crap on your phone and syncing takes forever!

What I’d like

Something in the middle might be nice… working with a real device is a lot easier without jumping through code-signing hoops, and the iTunes mediation seems like something that should be skippable if the toolchain’s better integrated, which could improve the iPhone experience.

Performance and boot time are the biggest issues with the Android emulator; making it boot within a couple seconds would be a huge improvement by itself. Cutting overhead by running a native i386 or x86_64 system image might be nice too, but might not be worth the trade-offs of being able to run native ARM code in the emulator.

The trading post: MacBook Air 1.86GHz/2GB/128GB

Hey there my San Francisco buddies, and farther-away buddies who might be willing to pay shipping!

It’s laptop shuffle time at the Vibber house… I’m replacing my MacBook Air as my mobile & webdev machine and am looking for a good home for it… For just US$1150, you can become this ultra-thin laptop’s sponsor. All it needs is a place to plug in and a good meal of electrons every day, and it’ll be your best travel buddy!

I’ve used the box for MediaWiki and StatusNet development, general web surfing, and a little light gaming. Memory and disk performance are a bit tight for a really hardcore workstation (I wouldn’t use it as a mobile video editing studio, that’s for sure!) but it’s perfect for mobile webdev/notes/surfing/skyping and beats the pants off any netbook I’ve tried.

This machine has been to such exotic locales as:

  • San Francisco!
  • Orlando!
  • Paris!
  • Montreal!
  • Los Angeles!
  • Seattle!
  • Berlin!

Purchased from Apple as a refurb in September 2009 with 1 year “like new” warranty — it’s still eligible for purchase of a 2-year AppleCare warranty extension, if that sort of thing floats your boat. Apple still lists this model (full specs) at the refurb price of $1349 that I paid; specs are about the same as the current $1499 base-model MacBook Air but with the 128GB SSD drive.

Machine shipped with Mac OS X 10.5 and a 10.6 install disc; I’ve wiped the drive and put on a fresh install of 10.6. Accessories included: 45W power brick, US 2-prong plug and 3-prong plug w/ extension cord; USB ethernet adapter. Note that VGA and DVI adapters are not included; like other current Apple models it has a native Mini DisplayPort connector and needs an adapter for pretty much any external monitor.

Why I’d recommend it: compared to a netbook, the Air is much more powerful and has a keyboard that won’t hurt your hands. Compared to an iPad, the Air actually can run arbitrary programs and be used for software development. Compared to other full-size laptops, it’s delightfully thin and light, which your shoulders and back will appreciate if you need to travel regularly or cart it to the office on public transit.

Why I’m replacing it: I’ve picked up a MacBook Pro 13″ (same form factor & screen size, but 1kg heavier) primarily for the huge increases in battery life in the last couple product generations. I prefer the lighter weight, but I have a lot of long-distance travel this year and a battery that can actually last me through a cross-country flight or a full day of conferencing is going to serve me better right now… I just have to be really hardcore about keeping extra crap out of my bag!

The good: thin, light, and beautiful! At just 3 pounds, this thing is a joy to carry around when traveling; it really does make a difference to my back. CPU/gfx performance are decent enough for light webdev and a little gaming.

The bad: SSD disk performance is relatively sluggish, which may be painful if you do a lot of compiling. Running heavy CPU for a while can lead to the machine slowing itself down to stay cool. Battery life is similar to the previous generation of MacBooks (theoretically 4-5 hours; I get 2-3 hours of real usage).

The annoying: 2GB RAM is adequate for most needs but cannot be upgraded; folks working with virtual machines will find this awkward. Single USB port can be overly confining when traveling, especially if you need to use the USB ethernet dongle at the same time as anything else. No built-in CD/DVD drive may be a problem for some uses (remote disc is supported if you have another Windows or Mac machine with a CD drive, but has limitations. External USB drives will work, but be warned that Apple’s $99 Air-branded external drive does not work with USB hubs — it must be plugged directly into the Air’s single USB port, leaving you unable to use a USB keyboard, mouse, hard drive, Ethernet adaptor, or iPod.)

If interested, drop me a line. If there’s no excitement it’ll end up on eBay.

We are all dual-booters

Today’s personal computers basically run two distinct operating systems: the native host OS (Windows/Mac/Linux or iPhone/Android/etc) and the web.

Web apps have solved all kinds of problems that are still poorly handled by most native systems: apps automatically update every time you use them, they manage their own library dependencies, there’s a security sandbox that lets you run pretty much anything without concern that it’s going to eat your system (unless your browser is buggy!)

Let’s face it: most of us probably spend a lot of our time in the web, and even if they’re not doing everything that’s where a lot of action is. Some folks have used this as a sort of excuse for the extreme control some platforms exercise over software publishers – “don’t like the rules? Make a web app, you can do anything!” 

But web apps are still much more limited in some areas. Access to hardware is rare (cameras, audio recording, scanners, attached storage). Communication between apps is greatly complicated by that sandbox, and shared data on the host machine like contact lists and photo archives may be completely inaccessible without a host-specific shim. (Most impressive thing I’ve seen is a bank web site that did deposit via scanned check image, using a signed Java applet to hook into native scanner support. It only worked on Windows, alas.) Background processing is very limited, and most web apps give up on directly notifying you of new activity and just send you email, hoping you’ve got something else that’ll tell you there’s new mail.

There’s a lot of great activity going on in and around HTML5 these days that’s getting better graphics support, faster code execution, etc. But the things that really bring the web native are going to be about access to shared hardware and data resources.

Some good things have been coming in such as touch and orientation events in Mobile Safari, but there’s a long way to go. My pet peeve: I find it pretty surprising that HTML file upload controls don’t trigger something useful like the camera roll on the iPhone/iPad or the Android browser. I can’t believe nobody has thought of this, so I’ll assume for now that the various browser folks just ain’t gotten to it yet… Anybody feel like starting on patches for Android’s Browser and the mobile branch of Firefox? :)

Game review: Myst for iPhone

So while fiddling around with the iPad I picked up for testing, I thought “hey self, this would be a great platform for an exploration/adventure game like the classic 1993 CD-ROM game Myst!”

To my great pleasure, i discovered that Cyan released a iPhone/iPod Touch version of the original Myst last year, which also runs quite nicely on the newer iPad.

The game features a richly detailed CG-rendered environment (all pre-rendered graphics thanks to 1993’s paltry CPU horsepower), where you wander around trying to piece together the history of a family power struggle that has trapped the denizens of a world where writing can literally create new universes.

Back in the 90s, the graphics, videos, and music filled an entire CD to the brim; the iPhone version weighs in at a similar 540 megabytes or so, which by today’s standards is a reasonable download. :)

The still graphics have been slightly rescaled from the Mac SE-friendly 512×384 or so down to 480×320, but appear to be from true color originals rather than the dithered 256-color versions of yore. Some screens have been further zoomed in to make small touch targets more accessible, but I still find it a bit awkward on an iPhone.

In pixel-doubled mode on the iPad, everything looks great and navigating by touch is a joy; the cleaner true color images outweigh the slight resolution loss for me, and it’s just the right size to go pushing things on.

My one big wish might be for an integrated note-taking feature. (Some of the later games in the series actually added a screen-shot feature, presented in-game as a camera!) On a 1990s desktop computer I could easily keep my notes on paper, but a portable tablet cries out for taking the notes on the tablet too, so they’re with me whenever I feel like poking at the game for a few minutes. Fortunately the game is great about saving and restoring state automatically, and starts up in just a couple seconds, so switching between the game and Notes or Photos isn’t too unpleasant. (Better multitasking on the system could help here too by keeping state live while you’re away in your notes.)

I would really love to see Myst’s sequels brought to tablets like the iPad natively; the higher-resolution graphics in Riven would look *fantastic*, and the iPad should have enough horsepower to handle the fancier video and panoramic effects in Mysts III and IV. I still need to finish IV and play V though… ;)

Probably the biggest obstacle to the later games is storage space. Pre-rendering graphics from every possible view position and direction let them have visuals years ahead of their time, but at a huge cost in disk space. Riven should be tractable, but full downloads could run many gigabytes for the later games, which spanned multiple DVDs!


  • Game:Myst for iPhone
  • Genre: graphical adventure/exploration/puzzle
  • Platform: iPhone OS (low resolution)
  • Cost: $4.99
  • Awesome factor: pretty awesome
  • Nostalgia factor: pretty big but not overwhelming the awesome
  • Recommend? yes!

Note: typing html tags manually on the iPad keyboard is pretty awful, as letters, slash, and angle brackets are all on different screens. I’d really appreciate working rich text editing in Mobile Safari!

More AT&T games

Good news 1: AT&T is exchanging their ‘unlimited’ $30/month iPhone data plan for a $15 200 MB/month and $25 2GB/month plan, with relatively sane overage handling.

This is good because AT&T’s been blaming a lot of its woes on out-of-control data usage by iPhone users exceeding their network capacity in the most crowded markets. If they’re actually charging based on usage, the incentive structure changes from them wanting to minimize our data usage [pushing costs down] to wanting to make it as attractive as possible to actually use the network [pushing revenue up, rewarding infrastructure buildout].

That means AT&T is more likely to give people things they want, and I can’t say a bad thing about that.

Good news 2: AT&T will finally start offering iPhone tethering (11 months behind schedule) for an extra $20/month on top of the 2 GB/month plan.

Adding tethering is a must for AT&T as the US exclusive iPhone carrier to compete with Android phones, which can already tether on any network without jailbreaking and will soon have the feature officially in the OS.

These exclusive carrier agreements are horrible for consumers; it took this long for a competing phone to catch up enough to actually push AT&T into action. If we’d instead had an open phone market, so you could buy any phone and use it on any network, we’d have had somebody offering official consumer-friendly tethering the second the iPhone 3Gs was announced.

Bad news: That $20/month doesn’t actually get you anything real — you have the same 2 GB limit that you’re already paying for, but you’re more likely to reach or exceed the limit. If the issue is data limits, why do I need to pay extra to NOT get a bigger limit? This is particularly silly if customers can tether for free on any other network, or on the same network with any other phone, or on the same network with the same phone if they jailbreak the software. Hello?

But let’s give AT&T props for baby steps — they’ve already been offering similar smartphone tethering plans that don’t add anything to your data caps for their other smartphones, so that’s what they know.

What it probably does for me is to make me feel less guilty about considering getting the poorly-advertised unlimited international smartphone data plan ‘without tethering’ and then using tethering anyway on my Android-based Nexus One. It’s enough money that I’d feel like I’m paying for my US tethering during the months that I don’t have any international travel. :P