4 ms·
Is there any compelling reason that we know of for Apple using Objective-C in their development tools? In all seriousness, as a programming language, what does
by angersock 14y ago
Is there any compelling reason that we know of for Apple using Objective-C in their development tools? In all seriousness, as a programming language, what does it bring to the table that C, C++, or some scripting language do not?
(I ask this in good faith--not trying to troll. I am genuinely curious.)
- kryptiskt 14y agoBoring answer: NextStep bet on Objective-C and OSX is built on that, and iOS is derived from OSX.
- chc 14y agoAmazing that this isn't voted higher. Regardless of Objective-C's virtues, this the real reason. The decision was made back in the late '80s for NeXTStep, and it just hasn't been changed since then. Apple was kinda moving toward Java in the early days of Mac OS X — WebObjects was ported to it, and it was a peer language for Cocoa up to Mac OS X 10.4 or something — but Mac users hated Java, as it was dog slow at the time, so Objective-C won by inertia.
- asolove 14y agoObjective-C has the dynamic properties of a language like Smalltalk, but you can also drop down to C and write fast imperative code. Besides the raw capabilities of the language, the community of Objective-C developers fit very well with the language. Where Ruby would use an abbreviation, ObjC prefers long explicit names. And the interleaved method name/arguments makes the code readable in a very specific and refined aesthetic. It isn't obvious to everyone, and it isn't a natural way to write some kinds of programs. But for writing fast and highly-interactive UIs, it remains a high water mark. The best advice is: try going through one of the books by Aaron Hillegass to get a sense of the serenity of writing proper Objective-C/Cocoa code.
- wonderzombie 14y agoLook up Smalltalk for some hints. I'm not an expert on Obj-C or Smalltalk but Obj-C borrowed pretty heavily in some respects, as I understand it. It is object-oriented, but it is a substantially different paradigm from the C++/Java family. As another hint, Ruby was pretty heavily influenced by Smalltalk as well. Think about stuff like responds_to? and whatnot, where you're sending messages to objects and objects can actually intercept and react to those messages. The comparison to C++ is pretty illustrative, if only as a point of contrast; C++ is certainly not the only possible approach to OO in a C-like language. Alan Kay, the guy who did Smalltalk and OO, doesn't particularly approve of the C++ approach to OO. In practical terms, though, I think it's somewhat historical, to the extent that any programming language's usage is or is not historical. :)
- sswezey 14y agoIf C and Smalltalk were to have a baby, Obj-C would be it. You can see both of the influences in the language quite heavily.
- chrisdevereux 14y agoIf you're going to expose an OO API then you'll need an object system of some kind (see also: COM and GObject). Objective-C is really just an object system, along with a minimal amount of syntactic sugar added to C to simplify its use.
- rplacd 14y agoI agree - learning about the C Runtime is an "ahah!" moment that usually comes too late. (It also makes interop trivial!).
- rbarooah 14y agoObviously people can argue for ever over the merits of one design decision over another but as someone who has programmed in Java for more than a decade, and has used Scala and Clojure commercially, I'd say that Objective-C does have some attractive qualities: 1. The object model is similar in complexity to Java (i.e. no multiple inheritance, templates, etc. that fill C++ with corner cases). 2. It is C but with an object oriented message passing layer on-top. You can think of an Objective-C program as a bunch of C programs that have a more loose coupled way of talking to each other. This gives it a balance between the abstraction of a high-level language and the performance and control of C that is different from Java and most scripting languages where you need to use a native-API to talk to C. Whether this is objectively good or not is debatable but it certainly supports Apple's strategy. Personally I find it liberating. 3. The dynamism and looseness of the language make code transformation tools much harder to write - which is why XCode is only now starting to approach Eclipse on refactorings and completion. The upside is the dynamism enables a bunch of things whose equivalents require bytecode manipulation in java - e.g. property observers, Core Data synthesized accessors, Undo proxies etc. Java is evolving slowly to make these kinds of thing easier, and Objective-C is evolving slowly to a tighter language that's more amenable to automated transformation. These are just a few reasons. I think it's also fair to say that Objective-C was pretty crude and was 'behind' even as recently as 2007, but the rate of improvement since then has been high and has brought it up to date. (Declared properties, blocks, ARC, GCD, are pretty major steps into the modern era) There are definitely a lot of rough edges that still remain and there's a lot more to learn than say a scripting language, plus a very different philosophy to get to grips with by comparison with the java family but once you do know it, it's a powerful language with some great strengths. I'm very interested to see what happens to it over the next few years.
- primitur 14y agoC pretty much still Rules the System Layer. Its never going to go away for as long as its easy, and efficient, to write very good C code which performs well. In spite of the hate, there is a lot of really good C code out there still running, still working, still burning up the market. I'm pretty sure there's nary a system image which doesn't, eventually, get itself operating per the rules of C, for the most part, somewhere .. That said, for all your very valid points about Objective-C, the same (essentially) can be said of Lua, and the Lua VM, for example. As a mobile developer, I'm no longer interested in Objective-C - its only an Apple Language. But I can take the Lua VM and put it on all the other machines, host-wise/parasitically, and create my own internally ordered Framework which runs on all Platforms, and still gain a lot of the benefits of a re-evaluation of 'language simplicity' versus programmer effectiveness. After 4 years of Mobile development on iOS and Android, where multiple projects have blossomed organically into unwieldy godawful trees of complexity which prove, every day, even more difficult to turn over to other programmers, themselves creating massive WordSpaceCollections: ofCode.to_BeMaintained((Some*)Way) || Other { NSLog("grr..", &etc} ; On a Drama Scale, it goes like this: "Oh, Android NDK/SDK, how you have blossomed to being something I regret I am not putting into the trash in the early days. XCode, you %(#@&% Asshole piece of software, Why I Gotta Download CMDLineTools just to get work done" .. "SublimeText2, factory settings .. Open Folder->".lua files", build and distribute for MacOSX, Linux, Windows, iOS, Android, and still only need to maintain one codebase. tl;dr - You can't do that with Objective-C.
- fleitz 14y agoWhy it's used by Apple is inertia, what it brings to the table that C and C++ don't is balance. Obj-C tends to bring the best of both worlds, while making slight tradeoffs. It brings the benefits of compile time type checking, while retaining dynamic typing at runtime. Try adding methods at runtime to a C++ object. Obj-C is reasonably good at a number of things and integrates very cleanly with C++ and C.