From AS3 to Objective-C: Flex vs iPhone development

Recently I’ve been given the opportunity to work full time on commercial iPhone development at EffectiveUI. The most intriguing thing about the platform for me is having access to non traditional user input mechanisms. When I was playing around with Wii remote integration on the desktop, the potential was exciting, but the ubiquity was limiting. In the same way that pc game companies develop for the keyboard and mouse first and then provide hooks for joysticks after the fact, I knew that serious Wii remote integration in a desktop app was limited. Knowing that I can write software for the iPhone that always has access to multitouch and accelerometer data from the outset really allows for unique gestures as a first class citizen within an app.

After working with some code and spending time with the SDK itself, I couldn’t help but naturally compare UI development on the iPhone with GUI frameworks like Flex or Swing, heres the things that stand out so far.

  1. I’m really spoiled by higher level languages. A good high level language like ECMAScript, Ruby, or Java rides the fine line of “Making things as simple as possible, but no simpler”. I’ve never felt constrained by the language features in these technologies, only by the apis exposed. Stepping *back* into Objective-C certainly provides more power and flexibility in the language, but there’s a loss in productivity for me that I just can’t shake. Some of this loss comes from Objective-C’s design itself, and some of it just comes from XCodes introspection ability. For instance, I’m not sure if I’ll ever get to the point where I can read these lines of Objective-C as effeciently as their ActionScript counterparts would probably look.
    NSString *aString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
    UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
  2. Closed source UI frameworks suck. Most of what I learned about custom UI development in Flex I learned by inspecting the source code for the bundled controls. Ripping open Containers to see how layout rules are determined, or Lists to see how delegates are passed around, or the Image control to see how different display types are handled provides invaluable gems about implementing Flash apis. It has also helped me optimize the interactions of an app knowing the intentions of the developer who created the UI controls. With the iPhone SDK, you’re given documentation for the visual components, but no source to help determine how they work.
  3. Core graphics and animation is really strong. Between Quartz and the OpenGL layer there’s alot of potential for getting easy access to some of the more complex visual hacks. Although I think 3D user interfaces are prone to usability issues, the iPhone is a much better device to explore them on then a standard keyboard and mouse interface.
  4. Data binding, event listeners, and mxml. The Flash Player and Flex model provide features on top of the ActionScript language that arguably optimize UI needs and keep development more declarative. Cocoa development could really benefit from a ‘gui compiler’ that takes Objective-C to a higher level and bakes in features that support common ui design patterns.
  5. Garbage Collection. Objective-C 2.0 provides a unique system that lets you create objects that will be automatically garbage collected, or you can continue to manually manage object allocation/deallocation yourself. The concept sounds cool, but I can imagine allowing both systems to be mixed within the same project is just begging for trouble.

So far I think that Objective-C has alot of power and some really awesome features that outclass GUI features in Flash, but compared to Flex development as a whole, I’d have to say that XCode and the included visual frameworks are not as sophisticated.

14 thoughts on “From AS3 to Objective-C: Flex vs iPhone development”

  1. There is no garbage collection available when developping for iPhone though. Apparently because of performance reasons.

  2. Have you tried using F-Script, the OS X SmallTalk language to help smooth out the transition to Objective-C and Cocoa? Java and AS3 are years behind Objective-C in terms of sophistication and abstraction. I just started using Objective-C two weeks ago and it just blows me away. I don’t know much, but I do know why Next Step was named that way — I’m reminded of it everytime I use Cocoa with all the classes beginning with “NS.”

  3. Great to hear from another AVM2 to iPhone OS developer. I have also had the chance to work full time on a commercial iPhone application, but have found that the main productivity slowdown is not coming from Object-C, but from the total lack of web tools provided in cocoa. libxml a c-library is your best choice for an xml parser. Parsing Xml in c is no fun. Loading an image from the internet is not as strait forward as it should be in cocoa. You need to make an NSURLConnection and then contaminate the bytes returned to create an NSData object which can later be transformed into an image that can then be displayed in a view. Not having the garbage collector is just an unavoidable detail of the limited hardware.

  4. Good to see im not the only Flex developers making the a leap into the land of Cocoa. Its an interesting mix but so far i’d have to agree with most of that you have said. Coming from C/C++ to flex 3 years ago i fell in love with the sophisticated UI design power and familiarities AS3 gave me. Now returning back its a little bit of a jungle.

    If anyone knows of a good C-Objective Primer for Flex coders could they email it to me perhaps?

  5. I am currently studying ActionScript 3.0, I find amazing that other people know 2 or more programing languages. I aspire to make iphone games using actionscript 3.

Comments are closed.