4 ms·
I find it surprising that there are so many people bashing Objective-C here in the comments. I have been programming in Objective-C for living since the iPhone
by zoul 16y ago
I find it surprising that there are so many people bashing Objective-C here in the comments. I have been programming in Objective-C for living since the iPhone SDK came public and I came to love both the language and the libraries.
I think that many people who despise Objective-C syntax are simply not programming long enough in the language to overcome the initial knee-jerk reaction. Mostly the issue seems to be the message passing syntax, which I find very readable and self-documenting. What else should matter if not this?
Then there’s comments about speed. I have written two action games for the first-generation iPhones and I have never encountered a performance problem caused by the runtime. Over 99% of the time I could stick to high-level code without resorting to C to gain speed. That says a lot about performance for regular applications.
Block syntax could be better, I can’t use closures with such ease as in Perl (for example). But this is one of the things that have to do with Objective-C being a relatively thin layer atop of C. And that I see as a huge win, because you can very easily and naturally mix higher-level Objective-C code with plain C APIs that are very common on most systems. And if you want some lower-level bit-twiddling trickery for performance reasons, you are free to go. For me, C is a very elegant language and Objective-C takes out most of its rough corners.
Saying that Objective-C could be replaced by something “smarter” like Lisp or Haskell is simply ignoring the reality. Objective-C has very low language complexity, both the building blocks and their interactions are simple and there are few surprises. This is a huge advantage both for the newcomers and for programmers that deal with the stack most of their working hours.
The manual memory management first seemed like a chore to me after coming to Objective-C from Java, but the rules are dead simple and after a few weeks you don’t think about the memory management any more.
Yes, Objective-C is not hip. So what? It’s a pragmatic and reasonably expressive language that gets the job done. I don’t think that replacing it would serve any real purpose – and that’s a very good reason to survive.
- tomjen3 16y agoMy biggest beef with Objective C is that it takes the most retarded feature of C++ -- that you have to write both a header and a implementation file (why oh why can't the compiler compile one?) -- and removes the really nice ability to allocate your object on the stack (which means memory allocation is really, really, cheap and you know when the object is deallocated).
- zoul 16y agoAs for the header/implementation split, I might have been brainwashed by the language, but I like it :) I take it as a nice division between the public interface and private implementation. And now that we have purely synthesized properties in the modern runtimes, we can keep the header file really clean: https://gist.github.com/766381 https://gist.github.com/766381 I have never missed allocating objects on the stack, I am mostly happy with autorelease pools. They are slower and “less deterministic” than stack-based objects, but I don’t mind.
- leon_ 16y agoWell, call me weird but I like the .h/.c split. Header files are awesome for a quick lookup. Big implementation files are not. About the stack ... well if you care about performance to this degree in your Obj-C code chances are you should implement the stuff in C/C++.
- blub 16y agoLet's give credit where it's due - the header/source split is a particularity of C, borrowed both by C++ and Objective-C for compatbility.
- bonch 16y ago> I find it surprising that there are so many people bashing Objective-C here in the comments. I have been programming in Objective-C for living since the iPhone SDK came public and I came to love both the language and the libraries. Brackets. People see the brackets and are immediately biased against the language. Yes, many programmers really are that lazy and superficial.
- forkandwait 16y agoMost of the silliness about Objective is (I think) based on an unwillingness to admit that GUI's written in one's favorite scripting language or Java are still too slow. I think Obj C add just the right amount of sugar to plain C for GUI and OOP, while its cousin C++ has WAY too much sugar (insulin shock!); both of these are screamingly fast after compilation. So saying "I would rather write it in Ruby/Python/Perl/Lua/Java/blah/blah/blah" is just ridiculous, at least with today's tech. Sure -- I would rather write an SS7 switch in Bash, but that just doesn't matter. Oh -- and the fact that small minded programmers freak out when something is different (brackets, as an OP says, or 0 versus 1 indexing, etc) (Note -- if you want to max programmer speed (in Lines of Code) for GUI's, you want to use a language even uncooler than Obj C: Tcl/Tk...)