Quick thoughts on writing Objective C
Playing with my new Mac, this is my first time writing Objective C code in 15 years, and C or C++ code in nearly 10. Some quick thoughts after finishing Your First Mac Application.
- Header files? In 2011? That require forward declarations of classes? Ugh.
- Objective C properties are handy syntactic sugar. I have no idea what “synthesize” really does, but I like the result.
- Static typing is awkward. I’m prefering dot style for properties
self.track.volume = sender.floatValue;
But if the type of “sender” is id that doesn’t work. I have to fall back to
self.track.volume = [sender floatValue]
and rely on Objective C magically not type checking method names on id. Objective C has duck typing, sorta, but not everywhere. - Manual memory management continues to suck. Apple has papered over it in various ways, with retained properties and autorelease and now ARC. But the fact that the programmer is even aware of reference counts is a serious flaw in the language. Seriously, every other OO language for 20 years has had garbage collection. Hell, even C languages have had automatic garbage collection via a conservative collector like the Boehm collector. WTF is wrong with Apple that their development language requires manual memory management?
- Xcode 4.1 is a pretty solid IDE. I could drop into it with just a basic tutorial and understand most of what was going on quickly. The Interface Builder stuff so far seems OK, although we’ll see how it works with real code. I’m impressed with how one can do complex user interface constraints entirely graphically.