I am learning to be very fond of Cocoa, and Objective-C has been fun to program in, at least for the small things I’ve done so far. But I’m still trying to decide how to develop the personal project I’ve written about in previous entries, and for that purpose I’m noticing some weaknesses that Objective-C has, at least as compared to Java. (It certainly has strengths relative to Java, too. But I already knew about those. I’m just realizing the weaknesses now.)
The large amount of metadata that is stored in Java bytecode files is a huge advantage for Java. One of the things that annoys me about Objective-C is the fact that a class definition is split between a header (interface) file and an implementation file. My assumption is that header files are necessary because the object files don’t have sufficient metadata; you need the header in order to compile code that uses the class. But this solution is less than ideal. It forces a lot of duplication of information (method signatures, for example). And one of the terrific things about Java is that you can use any third-party libraries you have access to, even if you only have the object code. (Documentation is helpful, of course, but frequently not necessary, and the class files contain all the information that the compiler needs.)
Memory management in Objective-C is much better and easier than C or C++, and it does have a few advantages over Java. But overall, I’ve concluded that the Java mechanism is much better for application robustness. It’s certainly easier to program with.
Finally: Objective-C, by including all of C as a subset, suffers from C’s lack of rigor and discipline at the level of the type system. That is, the Objective-C type system can always be subverted by C code. Why is this important? Apart from the obvious safety and robustness issues, there’s another point that I’ve just become aware of. I’ve just been playing with IntelliJ IDEA as a development environment, and I’ve been very impressed by its thorough and easy refactoring support. Not only does nothing like that exist (so far as I know) for Objective-C, I believe it would be very difficult—if not impossible—to do a similarly thorough job for Objective-C.
I may well be wrong, and I’d be delighted to be wrong. But for the moment, I’m leaning strongly toward buying an IDEA license and developing my application in Java.