The bad news is, Apple needlessly slapped a "confidential" sign across the tech talk today, so nobody is allowed to write anything about it or post any pictures.

I think I can nevertheless write some thoughts I took away, without giving away anything about the content of the sessions. So what I write might have been inspired by the lectures, or by something completely unrelated, like surfing a web site or talking to people.

Some things to know first: I left early because I got bored, so I missed roughly the last two lectures. Also, I don't have an iPhone myself yet, and my friends would perhaps even describe me as an Apple hater. I really don't like Apple's restrictive policies, and I don't even like OS X, but that is a story for another post. The iPhone is nice enough to make me overlook the general flaws of Apple. For one thing, I gave up on mobile games development with Java because it became too tedious to support all the available devices. The iPhone is one device (OK, strictly speaking three: old iPhone, iPhone 3G and iPod touch) that has sold several million times, making it possible to develop useful applications targeted at one device only. And Apple really got a lot of things right, I don't think any other phone comes close in usability.

If I don't have an iPhone yet, it is because I don't like the conditions of the T-Mobile Germany contracts. Specifically the UMTS bandwidth limitation seems silly, since the iPhone makes it possible to surf normal web sites. So I would expect the T-Mobile bandwidth to be consumed rather quickly.

Without a doubt, a lot of fun can be had with the iPhone, and a lot of fun applications already exist.

What follows is mostly me venting my frustration about having to use Objective-C. I had to say it somewhere... It is not the only thing I took away from the tech talk, but it was a tech talk after all, so you can guess about the main topics. I had a nice idea for a possible iPhone app while dozing in the lecture, and I also met some nice people, so going there was not all in vain. Oh, and I got a T-Shirt, too.

Objective-C, the strange beast

My main gripe, however, is the programming language. Most people I talked to say that it is not so bad, but my programmer instincts make me shy away from Objective C for several reasons. Granted, most of them probably sound like nitpicking and my objections might make me seem petty. But I have become a programmer out of laziness, and so I absolutely can't stand it if a programming language is making me do stuff that isn't necessary.

Header files (Shudder!!!)

Objective-C seems to be a strange beast: on the one hand it apparently is "fully dynamic" (Apple speech), meaning among other things that methods are not statically linked at compile time. On the other hand it borrows from C and C++, with ugly pointers cluttering the code, but much, much worse, forcing you to write header files for your classes.

I am not a language designer, but for the life of me, I can not get these two aspects combined in my head (dynamic linking and header files) - either one feature seems to make the other one pointless. Dynamic means you can modify classes at runtime, so what is the point of the header files?

I have programmed in languages without header files for 10 years now, so I can confidently say that there is no excuse for header files. I think they only exists because of the laziness of the developer of the compiler. But then again, those guys had several years to improve their compiler. What is up with that?

For the non-programmers: a header file basically means that I have to program every object and method in my program twice. Once to tell the compiler that it exists, and once to actually implement it.

It is certainly not difficult, but just as certainly it is not fun. For someone with my condition it becomes very difficult to do because I generally have a very hard time doing things that I see no point in doing.

No garbage collection

Another gripe is that Objective-C for the iPhone does not have garbage collection, so the developer has to take care of erasing objects by himself. Curiously, many people I talked to seemed to agree that this makes sense for a mobile device, because resources are so limited. Well, it seems the recommended maximum memory consumption for an iPhone app is 25MB. I have developed games for mobile phones in Java that had only 800KB available as runtime memory, with garbage collection. No problem whatsoever. A slightly more plausible explanation: garbage collection usually runs in a background thread, and having that thread constantly running might consume more energy. But honestly, I don't believe it, that is just a weak excuse.

Also, you don't even manage memory directly in Objective-C, but you have to manually take care of the reference counters. This makes even less sense to me, because I don't think that is what makes garbage collection difficult. Rather, I would expect counting the references to be compiled into the executable. There might even be garbage collection going on in Objective-C, something still has to free the memory when the reference count has reached zero, after all. Again, this just reeks of laziness on behalf of the developers of the compiler.

Maybe inserting the reference counting into the executable would inflate the memory footprint marginally, but honestly, these days the size of the code is never the problem. Most memory is consumed by the data, for instance images that are being loaded by the application.

Hungarian Notation (Shudder!!!)

One more unbearable thing I have seen in code snippets from Apple: it seems it is customary in Objective-C to use the useless kind of hungarian notation. That means it is customary to call a widget UIWidget instead of Widget, because it belongs to the UI. Joel On Software has the ultimate essay on hungarian notation and how it should be done, mandatory reading for every programmer in my opinion.

Again, this might sound like a non-issue, but it makes me feel almost like the heroine of William Gibson's "Pattern Recognition" upon seeing the Michelin Man: it is almost as if I am psychologically allergic to this ugliness and extremely bad taste. It sounds innocent if you see just one line, but imagine thousands of lines of code littered with hungarian notation. It is unreadable, unless you train your brain to just not notice it. But why should I have to do this to my brain?

More ugliness

I have mentioned the pointers, something I also haven't seen in years. Going back to using pointers makes me feel like coding in the stoneage, and they also look ugly. In the same category as the header files fall the interfaces (forgot their real name, but they work exactly like the interfaces in Java). I see no need for them in a dynamic language, so please don't make me use them. At least possibly one really can get away with not using them, I don't know for sure.

Hope in the form of alternative programming languages?

Which brings me back to my original gripes with Apple. Is there hope of relief in the form of alternative programming languages coming to the iPhone eventually? Apple certainly hasn't leaked any plans, and worse, they officially outlaw interpreters of programming languages. The reason is clear: with an interpreter of another programming language (for example a Java virtual machine), people could circumvent the Apple AppStore and get applications from other sources.

This alone does not prevent other languages, though, at least I don't think it does. I think it would still be legal to use an interpreter just for one's own application, without exposing it to other applications. Or one could use another language that compiles to Objective-C. One such language seems to be Objective-J. Still, I think the rule against interpreted languages at least slowed development efforts for alternative programming languages for the iPhone.

There are rumors that there will be an adapted (=restricted) version of Flash eventually, but it is not yet clear if it will be possible to write iPhone applications with it, or if it will just enable web sites.

I have found a Lua bridge to Objective-C, but it doesn't sound as if the iPhone is supported so far.

Personally I still have some hopes for Javascript. There already is a Javascript interpreter in the iPhone, coming with Safari, that can also be instantiated from within an iPhone application. I don't know yet how much one can interface with the usual iPhone features from Javascript, and if it is possible to run Javascript without actually displaying the WebView (Safari/WebKit). Most people I talk to about this are of the opinion that one should write iPhone Apps in Objective-C to get to use all the fancy features, but I am not fully convinced yet. I hope at least for some apps on can get away with Javascript (obviously not if you are writing a 3d game), so it might be sufficient to get one's feet wet in iPhone development. Even just to be able to write some parts of the application in JavaScript would be a relief.

Meanwhile, I keep hopes for finding alternative languages for iPhone development. Please let me know if you find any. I probably won't use Objective-J, though, because it seems too proprietary for my taste. If I learn a new programming language, I want it to be as universally useful as possible.

Ultimately it is the end product that matters, of course. I have programmed in the Linden Scripting Language for Second Life before, which is the crappiest language I have ever seen. Nevertheless it was fun, because the things you could achieve with it were so much fun. Probably it will be the same with iPhone development. Once I really get started and get to see results on the phone, Objective-C won't feel so painful anymore. Still, I wish there were other options. Options makes me remember: I have also heard people say that XCode is not all that great either, and apparently it is not so easy to use alternatives. Too bad.