The Incredible Expressiveness of Objective-C
Friday, May 28th, 2010I've been messing with getting my latest ObjC code going again today and I have to say that once again, ObjC simply brings a smile to my face. It's so incredibly expressive that I just can't get over it. Sure, I can do a lot of the same things in C, C++ and Java, but there's a lot I can't do simply because they don't have the ObjC runtime. I appreciate that I can send nil any message I want, and it's not going to error. That means I don't have to check every single step in the processing or worry that some bad data will blow me up.
In C, C++ and Java, I have to do this checking. It's not horrible but it does make the implementation (not the language itself) much uglier than the equivalent implementation in ObjC.
Sure, I have looked at things like Python and Clojure, and there are languages that allow the more flexible method invocation, but it's not the same as really understanding that there's a nil object, and it's OK to deal with it as a valid instance of anything. It's really pretty sweet.
I'm porting code from C to ObjC for this project, and while the C code was about as clean and nice as I could have ever written, the ObjC code is just fifty times cleaner and easier to understand. Sure, a lot of this is the objects and message passing, and another big chunk is the Cocoa objects, but even in Java, it would not have been as clean.
I love that I can drop into C code when I need to, and that I've got retain/release memory management as opposed to the reference counting and garbage collecting. I just really hate that about Java. It's always something that comes back to bite me in terms of efficiency of storage.
I had an interview once with a company that I've since realized I'm glad I didn't get the position, but at the time, I was really ready to leave where I was. The guy I was talking to realized that I had been somewhat of a mistake in that my interests were not at all in line with the position - typical recruiter move, but we had a nice talk anyway. In the end, when talking about the language, he said "Any reasonably expressive language is pretty much the same." and at the time I was thinking of Java vs. C#, and tended to agree with him.
Horrible statement by him, and horrible memory fault by me.
There's nothing like ObjC. Nothing.