My hovercraft is full of eels

I really liked this article about XCode and Objective C. OS/X is a fantastic operating system and its development environment has a lot to offer — but as with all systems there are pros and cons.

Seven days later, I’m in pain. I’m hurting. I’m surrounded by square brackets. I have a hard time keeping track of my memory (maybe it’s alzheimer’s?). I wish I new what was wrong with me but even the good Dr. GCC seems to have a heck of a time diagnosing my condition. I have a sneaking suspicion it’s a form of jet-lag – I feel as though I’ve travelled back in time (about 15 years to be precise) but I’m not sure.

I understand. I’ve been doing Java work for the past decade for the most part. No longer worrying about memory management has its benefits, but there is a cost in performance. I’ve had a few problems where garbage collection actually got in the way, causes intermittent and unacceptable “pauses” in program execution while memory was reclaimed. Personally, I’m on the fence on this one — on the one hand, if I can’t write a -free call for every -alloc I’m a pretty sad programmer; on the other hand, it was nice not having to worry about it.

The Objective C syntax though, I rather like it. It reminds me of Smalltalk and I love being able to intersperse the method with the parameters, such as [myRectangle setWidth:100 setHeight:200]. But really, this is personal preference — some people love it, some don’t.

I do like the Smalltalk like features such as dynamic binding and the calling syntax is quite simialr too. I don’t care much for the use of square brackets – though I’m not sure I could come up with anything much better for a language that is (or at least was) essentially a pre-processor for a C compiler. The fact that I have to use pointers all over the place is particularly irritating too.

Arguably the most useful feature in Java is the lack of pointers. Going back to pointers is hard to get used to, but I find that the use of pointers is rapidly buried deep within objects. Almost all programming beyond those first few foundation classes is pointer-free, unless you like to type your objects and that is optional. Using id myRectangle was the standard Objective C method once upon a time and is perfectly acceptable, although it can be argued that Rectangle * myRectangle is a better practice.

…and an overall environment that let me compile and run something that, on subsequent inspection, didn’t even seem to be valid code – more likely a “feature” of Xcode than any underlying problem with GCC or the language itself.

I’ve got to take exception with this last comment, though. I don’t believe you can compile invalid code in the XCode environment. I can believe that you could compile potentially dynamic code that does not evaluate correctly during runtime — and yes, that is a feature of Objective C. It is, in my opinion, a more purely object oriented language and as such opens itself up to more dynamism, late binding, and of course, runtime errors if you send the wrong method to the right class. But taken in whole this is a wonderful feature and makes it possible to do a few very elegant things that are harder to accomplish in Java.

So, let’s see. Yes, I miss some of the dynamic things Eclipse does — such as the on-the-fly compiler checking, and the extensive “hinting” about best practices it can give you. But then, XCode offers some things that Eclipse doesn’t: I find the round-trip engineering to class diagrams and the tight integration with Core Data (database modeling) an invaluable tool. I think those are more valuable, actually, because they provide tools that help me solve a bigger design problem — while Eclipse is really helping me forget how to be a good programmer.

I really love Objective C. Even though it is, I agree, a little bit more of a “manual” language — I still think it is more flexible than Java, and definitely faster than Java. The OS/X API layers (such as Core Data and Cocoa) are hands-down better than Swing and JDBC. Yes I have to work a little bit harder but the end product is, I believe, better and faster… so I’m happy.

I do wish XCode would adopt a few of these “missing” Eclipse features. On-the-fly compiler checking and best practice hinting are the two things I miss. And really, I think those are about the only two things I miss… for now.