March 15th, 2009

Notes from the "iPhone development for experienced web developers" SxSW Interactive panel

Quick and dirty notes on an excellent panel.

Joshua Siler, babcock jenkins VP of Tech, web developer Jordon Lev, senior developer

[I know some of this stuff already, comments from me are in brackets]

They do relationship marketing for sun, linkedin, intel, IBM, business to business in general. They are interested in metrics and so on

So they did an iPhone app related to that

I am surrounded by netbooks

"web developers are mad for power." Because we're used to insanely lazy tools that can casually abuse database servers and application servers and the desktop CPU and it all works anyway. The iPhone does not work that way.

400mhz processor, 128mb RAM, 10 to 100 times slower than a powermac G5. "Premature optimization" is not so bad in this environment. You can't process 5 megs of XML and turn them into a graphics display on the fly. [This is why Objective C is more appropriate than JavaScript and Canvas if you want any speed]

People expect immediacy on iPhones. The latency of web pages is something people are conditioned to only for web pages. Also the browser displays that it is still loading stuff in multiple ways. iPhone app developers are responsible for doing that on their own.

Slow stuff should be asynchronous where possible (but remember that this can lead to a lot of confusion if it's poorly done).

Objective C is not in the top 20 programming languages based on search results. It's all the way down at #2, behind COBOL and FoxPro and Ada etc. It's just barely more widely discussed than Scratch or Haskell.

Objective C means you're dealing with pointers and memory management (without garbage collection- it's up to you to free things you don't need anymore, and not free them twice). Multithreaded code is common (PHP doesn't have threads). As for the syntax... he refers to it as "syntactic saltiness" rather than "syntactic sugar."

[Why can't Java source, or almost-Java source, be compiled to Objective C source and so on? Could a subset of PHP be compiled to Objective C, creating a new audience of programmers? Did I sign away the right to even try to create something like that?]

Xcode is the development environment, practically speaking, period the end. You could edit your source in Textmate and switch back and forth maybe.

Cocoa, on the other hand, is modern and nifty and generally not an experience you'll hate. High end UI controls can be dragged and dropped into the application' UI and they will scroll and bounce and do all that stuff on their own. You populate them with data and go on with your life.

iPhone 3.0 OS will of course make all of this obsolete next week... well not very... but the preview means it'll be a more serious change perhaps than previously

[Apparently I'm legal if I seek to create a compiler from something friendlier to Objective C. Interpreters are forbidden.]

Data connection is flaky. [What does that mean? Lost packets in the middle of documents = not normally possible with TCP, it just dies outright. I assume they mean connections dying halfway etc., which is possible in TCP]

REST, with JSON responses from the server, is vastly more efficient than SOAP and other heavy XML stuff and they like it for devices like the iPhone. And it just so happens I made exactly the same choice for pkMediaPlugin's API because of the simplicity of it all.

What are they using to parse JSON in Objective C?

Cocoa is big on events and delegates... message passing is used to communicate between objects. Rather than calling something and waiting for completion, you are more likely to receive a message when the work is done.

Interface Builder places text boxes, buttons, etc. on the screen in a friendly way, but the code to make them do anything is up to you.

You can create multiple "views" (distinct screens / pages of the application's interface) and use buttons to swap between them.

The app delegate class is the "main function" or "master controller" of your application.

We use @synthesize rather than `new'.

The RootViewController corresponds to the default view, you can add more views and you often build your app out of a few views

[Not sure why "model" and "view" classes have names like "WebsitesDataController" and "SettingsViewController". Is this their own private convention? It's weird.]

[Here's a json library for objective c: json-framework ]

They used SBJSON instead.

return [jsonParser objectWithString:jsonString error:NULL];

Why didn't they do this as an iphone-safari web application? Response time (JavaScript is certainly slower than Objective C)?

Their answer: users like apps. [Also an app ought to be faster because compilation/interpretation of JS and HTML and CSS is not required.]

[UIAlertView openURLAlert = [[UIALertView alloc] initWithTitle:@"Connection Error"... ] [openURLAlert show]; /* Forgetting this would be Bad; we have to manage stuff ourselves */ [openURLAlert release];

You write a cellForRowAtIndexPath method for your table view and bam, Cocoa starts calling that to get content for that cell when it's visible etc.

[Ask them to elaborate on "autoreleasing" things... I did, see the end]

// alloc allocates a raw object, init is what we think of as a constructor // settingsController is a pointer SettingsDataController = *settingsController = [[SettingsDataController alloc] init];

// Now we give those resources back

[settingsController release]

* * *

They like:

Exciting platform Standardized hardware Cocoa and MVC Bare metal programming is kind of exciting for a change

They don't like:

Objective C Refactoring is hard. Objective C just doesn't accommodate DRY very well

(of course, PHP is not totally great that way either, he's used to Ruby) Lots of assumed knowledge and undocumented stuff Xcode is crude App deployment is a pain Flaky connectivity Apple controls the universe

[These guys are not the most experienced iphone developers in the world, but they are smart and successful and have a valuable perspective similar to our own... very similar to what ours would be minus my past C/C++ experience]

[I asked about autorelease and memory pools as an alternative to alloc/release. They don't really know the answer to that one. However:

http://www.cocoadev.com/index.pl?AutoRelease ]
Check out another article
March 13th, 2009
To Have And To Hold
March 11th, 2009
Active Intersection
March 11th, 2009
SXSW!