Posts Tagged ‘iPhone’

Open Source and Amazon: concrete examples of empowerment for iPhone apps

I’ve posted exactly zero times in the last two months because I’m head-down like a mad man, working with my team to get our very first iPhone app ready for shipping. Fingers are crossed that this will happen in about a month or so, and I have to say that so far 2010 has been a whirlwind education in the creation of iPhone software and the server backends who love it. That means that so far I’ve had no time to learn about the wonders of Rails 3, or to pontificate at length on the healthcare bill, or to beat Mass Effect 2.

But I have had time to be impressed, once again, at the awesome power of open source and the game-changing nature of Amazon Web Services.

Open Source — HTTPriot and delayed_job

Without going into too much detail, the iPhone app I’m working on (codenamed “Pedro”) records audio files and uploads them to a server. Naturally I’m using Rails for the backend, so I needed something to help me communicate easily with the server. After trying both an ASIHTTPrequest with TinyXML solution and Objective Resource, I eventually settled on HTTPriot. HTTPriot is a Goldilocks solution. ASI/Tiny are just too cumbersome since you end up having to write parsing methods yourself (and really, who the hell wants to do that when the entire point of structured serialization formats is that something should be able to turn them into native data structures (hashes/dictionaries) for you?), and ObjectiveResource seemed to do just a little too much and to rely on Objective-C categories a bit much for my comfort.

HTTPriot sits right between these solutions and is just right (had to complete the Goldilocks thought) for talking to REST services IMO. You serialize something out as an NSDictionary and POST or PUT it to the server, and you get back a response you can treat as a dictionary. GET requests are a one-liner (though to do it right you need a few methods so you can have a ViewController delegate handle the eventual response). The only drawback I’ve found so far to HTTPriot is that it requires you to cram all your processing logic for any given resource into a single method, as one and only one delegate method handles a successful server response. But that’s a small gripe. Using this excellent library, I was able to re-write the entire ASI/Tiny solution in a few hours. That’s versus a few days getting it set up in the first place. If you need to talk to a REST service with an iPhone, I highly recommend HTTPriot. As a bonus, the inimitable Geoffrey Grossenbach (@topfunky) uses it in one of Peepcode’s iPhone screencasts, enabling you to get both a step-by-step tutorial on creating a non-trivial working application with HTTPriot, and a good bit of explanation on how the library ought to be used.

When HTTPriot is done pushing an audio file to my app server, a Ruby library called delayed_job does the background processing required to send it to Amazon S3, where it will live and respond to GET requests via Amazon Cloudfront. delayed_job was created by the redoubtable Rubyists behind Shopify, the coolest turnkey e-commerce solution I’ve found so far. I’ve made a site or two for clients using Shopify, so I was excited to discover that they’d opened up the library they wrote to do background processing. delayed_job is a database-backed persistent job queue that runs in its own process and makes backgrounding a task dead simple. You can do all sorts of fancy things with prioritization and whatnot, but the thing that made me fall in love (even though my use cases eventually got a bit too complex to use it very much) is the fact that you can run any method with send_later — as in:

1
foo_object.send_later(:process_that_takes_awhile, @argument)

That one-liner will bop it into the queue, and delayed_job will handle it as it can. It’s really that easy. I’m using dj for sending emails and pushing binary files to Amazon, but I might start using it for other things as well. EngineYard (where we’re hosting this opus) supports it for production, and for development, you get a nice Rake task to help you manage it and keep an eye on the tasks as they happen.

The point of all this exposition is to say that I feel fortunate to have come up as a code dunce during a time in which open source software is mature enough to be able to provide even a relative n00b like me with documented, real-world-tested, helpful stuff that does exactly what I need it to — whether on the server side or on the client side. It’s worth mentioning as well that both of these things are arguably direct offshoots of the Rails community (delayed_job is in Ruby and was built to serve a Rails app, and HTTPriot was built with REST interactions in mind, which Rails has done a lot to help popularize), which continues to astound me in its breadth, creativity, and helpfulness.

AWS – cheaper than dirt, more valuable than gold

Have you ever seen anything as cheap as the stuff offered by Amazon Web Services? I don’t think I have. Or to put it more directly, AWS are the cheapest things I’ve ever seen someone try to put a price tag on:

- S3, Amazon’s storage service, charges $.015 per GB for the first 10 TB of transfer bandwidth you use in a month. And the prices go down from there. Get out your calculator and do the math to see how much data you have to be moving around before this starts to cost you more than you have in your change jar, and you’ll likely spend 20 minutes or so cackling to yourself about just how inexpensive mind-blowing web power is these days.

- Cloudfront, Amazon’s CDN charges $.01 for every 10,000 GET requests. Do the calculator thing on that one (realizing that it’s basically an add-on to the above), and you’ll be laughing even longer.

- We buy EC2, Amazon’s scalable-on-demand computing service, through a reseller (EngineYard) who really doesn’t add all that much to the $0.085/hour cost that Amazon themselves charge. EngineYard is able to offer hosting solutions optimized for Rails based on EC2, along with monitoring and Rails-oriented deployment and management tools, for so little extra on top of what Amazon themselves charge that for the first few weeks you’ll feel like you’re getting away with a crime.

Without the open source libraries I mentioned above, Pedro would take much, much longer to build and would be necessarily a bit less stable, simply because my team and I would be building everything from scratch. But without Amazon Web Services, there’s no way we could even entertain the notion of making this app. Pedro is a game: a funny, 99-cent App Store novelty that we hope will go viral and make us some cash. Apple gives us a great way to distribute the app, but without Amazon, we’d have show-stopping cost barriers to actually building a backend capable of meeting rapid, viral demand. A few years ago, just standing up unused production infrastructure to handle these use cases would’ve cost us thousands of dollars a month in rents, to say nothing of what it would cost in time and/or people-hours to have a qualified sysadmin lurking on our payroll. Now because of Amazon, those barriers are gone — replaced by a giggle-inducing cost structure for computing resources that back one of the most powerful retailer/supply chains on Earth.

With the preponderance of open source libraries and the rise of commoditized enterprise-scale computing, the utopia really is now — the only things holding anyone back are time, creativity, and will.

Speaking of which, I need to dive back down my code hole. See you in a month or so.

Tags: ,

iPhone 3G – first week

I got my iPhone 3g one week ago, and so I thought I’d blog a bit about my experience so far.

3G

I’m not sure if it’s just where I live, but the 3G service has been unexceptional so far. Or maybe I should just go ahead and call it “lousy.” I’m almost always auto-switched to the Edge band by the device itself when I’m at home, simply because I’m getting no bars of 3G. I had thought that AT&T had blanketed our nation’s capitol w/ helpful 3G service, but it appears not to be the case in my neck of the woods. Unfortunately, my office is also in a place with no decent coverage. Annapolis, MD isn’t on AT&T’s list of cities covered in Maryland, but it gets some residual 3G I guess from being close to Baltimore and DC.

GPS

This has been seriously cool for the most part, although it seems to work best with the 3G turned on, which I frequently don’t have — either for battery life or service reasons. I can see why it’s not “turn-by-turn” ready, but if you have a destination/route mapped out and you’re just trying to follow it, this works pretty well. It’s generally been just a few seconds behind my actual location.

Bigger Capacity

I bought the 16GB, and after my year of having the 4GB model, this extra capacity is sort of boggling my mind. I need to start adding some videos just to fill it out.

Case

I sort of feel like I liked the heavier metal version of the phone a little bit better, but the curved case is going a long way toward making me a believer in the new form factor. It does seem a bit more cheaply made though — I suppose that’s only natural when you drop the price point and ramp production up enough to have 40 million before the end of the year. I can see tiny inconsistencies in the way the light comes off the metal on the edges. I’m thinking of it as sort of a “brush blemish.”

App Store

Nothing out of here has really blown my mind yet, but I appreciate all the stuff that I’ve used so far. OmniFocus for the iPhone has been pretty disappointing on both this device and the old one, but they’re still working on it, so I’m going to give it some time before I start really dissing the experience.

I’m a fan so far of:

  • New York Times reader
  • Trism
  • Break
  • Twitterific
  • Bank of America Mobile Banking

Jury’s out on:

Apple needs to get hip to the fact that the AppStore is something that people need to like and trust. Pulling apps from the store with no explanation isn’t going to endear you to iPhone users, nor is the inclusion of a “kill switch.” The more people use the store, the more they’re going to expect that Apple act like the the benevolent, permissive distribution mechanism that Jobs’ promised at WWDC 2008.

Hacking/Jailbraking/Pwnage

I decided to wait on implementing the Pwnage tool for a little while. Until AppInstaller is ready for the 2.01 firmware, what you’ve mostly got available is a bunch of developer tools that I really don’t care about right now.

Summary

I like the thing a lot. I had been thinking that it wasn’t as cool as the last one, btu then I realized that the novelty factor w/ the first gen release simply wasn’t going to be topped; no subsequent iPhone experience was ever going to live up to the thrill of having/using one for the very first time. It was unfair to expect that level of cool from what was for me, basically an upgrade.

Tags: ,