Android vs. iPhone: Day One Development

5. November 2010

These are exciting times! As an assignment at school, we are writing an iPhone game. It's a simple number guessing game. You know how it goes... Generate a random number, get the user's guess at the number, tell them "too high" or "too low." When the user guesses it right, you tell them how many guesses it took. It's actually one of the most boring games you can play, but it's a great beginning for learning a framework (and in the iPhone's case, a language, too). It has all the great aspects of a first app: input from the user, output to the user, and simple processing with a nice added bonus of learning how to randomly generate a number. I worked hard to do things right. I wanted it to rotate properly, stay centered, respond well to all input, the usual goals. I wanted a market worthy app, even though it'll never make it to the App Store or the Android Marketplace. All the specifications my teacher inparted on us for the iPhone app, I continued to uphold for my own Android project. I'm going to do my best to explain my experiences with both platforms. I have the same experience with both of them. About a month ago I wrote a Hello World app for each of them. School got in the way of looking into either of them deeper, until this assignment. I may seem pre-determined to be better at Android considering my Java history, but I'm accounting for it by saying that I haven't worked in java for years and that I'm currently getting three hours a week being taught iPhone dev and Obj-C. It evens out enough for me! This article will not be as much a walkthrough as it will be a comparison between my two experiences.

To clarify on the requirements of the application: It's a number guessing game, as I said. There would be a label (Status), a textbox (UserGuess), and a button (PlayAgain). The PlayAgain button remains hidden until the user guesses the correct number, at which it becomes visible and the UserGuess textbox becomes hidden. Upon pressing the PlayAgain button, the visibilities swap again and a new game begins. Throughout the duration of the user making his/her guesses in the UserGuess textbox, the software keyboard is to remain up and the numbers are submitted as a guess upon pressing Enter on the keyboard. We were also required to implement it using the MVC pattern such that we have a game class (the model) that handled the state of the game: the number of guesses and the number the user is trying to guess.

I started with the iPhone app. This was the only thing actually due for the assignment so I made sure to have it done before class. Let me start by saying that I'm not a fan of Obj-C. It's like the basterdized, drunken mistake of a child between Lisp and C++. It is so unnecessarily different than most popular programming languages. Anyway, after creating the GuessingGame model class of the project, I began doing all the IBOutlets and IBActions to link controls to their variable names and events. With a Java/C#.Net background, this was a rather bizarre separation to me; separating the view from the code at such a level. As I started to get my head around MVC on the level that, it did eventually make sense. The Interface Builder was a rather easy experience. Properties, Delegates and general states of the UI elements were easily laid out, what you were looking for was easy to find, and all in all very easy to use without having to be told how to use it. No tutorial needed, just explore for awhile and everything is really clear and simplistic. Ten minutes, and all the UI wiring was done. Minus the language being as "unique" as it is, the experience was not so bad.

After turning in my project, I quickly changed gears, jumped on my Windows partition and dove into Eclipse. I did things by the book as far as the SDK installation goes and I set up the Android Virtual Machine to use 1.6 (my current android version). This took a lot more setup than XCode and the Interface Builder took, but these extra steps are accomodating for the freedom of the platform and the devices that your projects will run on. Not to mention it was pretty effortless. I sat down to Eclipse and I felt at home. It had been three years since I last touched Java, but it's like riding a platform-independent bike. The architecture of Android offers some important differences to the iPhone. Most (if not all) resources are in XML files, from strings to the control layout. Building the UI has a few quirks, and was not as intuitive as the iPhone's Interface Builder. Although not as intuitive, it wasn't a pain to deal with either. A few minutes of teaching myself what different attributes do on different controls and I was in business to make this simple app. I followed all the limitations that my professor had enforced on us for the iPhone portion of the app. I matched every piece and, to some extent, added my own requirements such as being able to rotate into landscape and having the controls positioned correctly. I did have to resort to Android documentation and a few tutorial sites to figure out intricacies about phone orientation and what how to position controls relative to each other. One of the best things I discovered about Android development I discovered by mistake. I had my phone plugged in to charge and when I built and ran the program, it installed on my phone and let me debug it directly on the device. I'm unsure if XCode allows for direct device debugging like this, but Android and Eclipse made it very simple by automatically finding my phone and installing/running the app on it without me having to jump through loops about setting it up. Of course, I also had fun with the emulator. My only complaint is the initial boot time taking as long as it does, but that's by no means a deal breaker.

Should these platforms be fighting for my love and attention, I would have to say that Android has taken the cake. Although iPhone development is not as painful as I first thought it would be, Android won me over with it's openness, choice of programming language, and the fact I have an Android device (I have an iTouch, but it's 1st Gen and just an iTouch). I do plan to continue developing for both platforms, before too long I may start releasing stuff to the marketplace or app store.

Advice, Android, Case Study, Development, iPhone , , , , ,

blog comments powered by Disqus