5 ms·
Objective-C's niche: it's the core of two popular operating systems. A lot of strange programming languages survive because of inertia. Emacs Lisp exists beca
by jrockway 16y ago
Objective-C's niche: it's the core of two popular operating systems.
A lot of strange programming languages survive because of inertia. Emacs Lisp exists because Emacs was written by Lisp hackers. It survives because Emacs ships with a few million lines of Lisp. Replacing it would take hundreds of man-years.
Objective-C survives for the same reason; Cocoa was expensive to write and rewriting it would serve no purpose. So it remains. Is anyone using Objective-C for some reason other than writing OS X or iOS apps?
- _3u10 16y agoNo, and if there was an easy way to bind UIKit with out Obj-C I'd use it in a heartbeat. I'm seriously considering WAX for LUA. Obj-C has the flexibility of C with the speed of small talk.
- boucher 16y agoThat strikes me as a pretty indefensible statement. Objective-C has an incredibly powerful runtime, which is nearly as flexible as the ruby runtime. It's also much much faster than ruby, and probably every other popular dynamic language.
- fleitz 16y agoI'm sure the runtime is great, unfortunately the syntax sucks, there is no GC (on iOS) and it can't curry functions, and you can't put an NSInteger into an NSDictionary with out line noise that would do java proud, it doesn't support passing or currying functions. Sorry, but passing a selector and an object is atrocious, even MS can figure out how to pass a delegate that can figure out whether it needs to pass a this pointer before passing the rest of the arguments. It's lambda syntax is also attrocious [[ ^ (int x, int x) { return x+y; } copy] autorelease] , wtf is that garbage? In ruby I don't need to touch 2 different files and put code in 3 places just to define a property, nor do I have to do this in C# or F#. I doubt it's much faster than C# or F#, especially if it ever involves something simple like putting an integer in a hashtable. I'd hardly call a language dynamically typed when it will fuck up adding a long and an int. Seriously, define a type that takes an int, pass it a long and see what happens. This is exactly what I mean by the flexibility of C (attrocious type system) and the speed of small talk (incurring a call to objc_msg_send anytime you do anything)
- aaronbrethorst 16y agoI spend my days writing an iOS front end and its Ruby backend, and could not agree with you more.
- rubyrescue 16y agoI absolutely agree but just responding to one point - i've played with Lua Wax and the lack of debugging and the fact that any Lua script error causes a segfault makes coding with Lua not worth the pain of losing the XCode editor and debugger and statement completion, etc. If you're putting in a scripting engine for a game that's one thing. If you want an easier way to write cellForRowAtIndexPath, I don't recommend it...
- koko775 16y ago* Syntax sucks: I think Objective-C is actually pretty beautiful. Maybe I'm crazy. * NSInvocation should serve the same purpose in most cases. * I find the block syntax atrocious if compared to Lisp lambdas. It's not that bad. Blocks are objects, so you're creating an object, with all the same predictable retain/release semantics. Maybe a few gotchas if you're not reading the documentation and realize you should avoid retain loops. Hardly different from Java, only it's easier to miss it in Java, because you never release, anywhere.
- deleted 16y ago[deleted]
- mattgreenrocks 16y agoThe lack of namespaces seems silly to me: NSThis, NSThat. It isn't that Obj. C is a bad language, it's just it doesn't feel like a more modern language, and yet it gets used because of the possibility of $$$. I do understand that you can come to love a language after a period of using (and understanding) it. And I do think a systems-level language should be used for apps on mobile devices, but we don't have to continue to be mired in implementation details that were an artifact of a language from the seventies. I need to play with it more to get a better feel for it.
- ryannielsen 16y ago
- leon_ 16y ago> Obj-C has the flexibility of C So I guess you implemented duck typing with some void-pointer acrobatics in C?
- koko775 16y agoI would if Foundation/{App,UI}Kit were open-source. I personally think it's fantastic. The thing is, I actually take offense to people who call a language ugly. Just because it doesn't prioritize the kind of expressiveness you desire doesn't mean whining about it makes you cool or a better programmer. What everyone here who says 'Objective-C is ugly and outdated' should be decrying is the relative lack of choice of implementation language for iOS. I like Objective-C, because I look at it from the point of view of C. It's a systems language with support for OOP that I find completely satisfactory, which prioritizes flexibility, predictability, and maintainability over raw speed and constraints. On the other hand, I love that Java and similar languages in its family can reason a great deal about classes and their interactions, and I love that Python and Ruby step out of the programmer's way when you just want to make something -- -- But to write software for an embedded platform that can be natively fast when needed (the C part of ObjC), but offer a solid OOP abstraction, and to reconcile these two needs as well as expose some of the lower-level workings of the OOP system to the developer when they really know what they're doing and need it? I think Objective-C is hard to beat there. It's a language fitting for projects from small-medium size to very large. It's not the only language that I feel can scale like this, but again; that's a problem (availability of alternatives), not a reflection on Objective-C's language. The language combines the low-level with the high-level, and is many things for many needs, yet is without the rigidity of a Java-style type system, yet is also without the inability or difficulty to deeply reason about high-level language structures as in some more dynamic languages, Objective-C manages to allow sufficient and sloppy "it just works" implementations, for when you just need to bang out code that works well enough, as well as encourages polished and well-engineered APIs (such as Cocoa's). I think Objective-C balances these concerns - small or big, dynamic or inflexible, as well as the reality of mobile devices' limited memory capacity, particularly well. I would make a more cogent argument were I more awake and if I did not have a splitting headache, but I think it's extremely unfair to call (or imply it) Objective-C strange, or that it survives merely because Cocoa would not be supported if another language were to replace it. Although I may be in the minority (at least amongst those who are posting here in this thread), I think it is a fantastic language.
- stephth 16y agoNo, but I'd love to hear about it. I see a lot of c++ devs complaining about how after 20 years they still haven't found a common ground on how to properly use c++ [1], its complicated memory management or its poor support for strings [2], things that are taken for granted with objc and Core Foundation. On one side I see an incredible amount of developers dealing with high amounts of complexity with C++, and on the other hand this low-level dynamic language with a powerful [3] open-source standard library [4] that is sadly only commonly used to build Cocoa apps. I'd love to hear about objc+CF for things like game development on other platforms than iOS or OSX, or an explanation to why it's not happening. I really really don't mean to instigate a flame war here -- I'd just love to hear more about this topic. [1] http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml http://google-styleguide.googlecode.com/svn/trunk/cppguide.x... [2] http://benjamin.smedbergs.us/blog/2007-11-05/what-if/ http://benjamin.smedbergs.us/blog/2007-11-05/what-if/ [3] http://ridiculousfish.com/blog/archives/2005/12/23/array/ http://ridiculousfish.com/blog/archives/2005/12/23/array/ [4] http://en.wikipedia.org/wiki/Core_Foundation http://en.wikipedia.org/wiki/Core_Foundation
- blub 16y agoYour references don't support the points that you are trying to make. [1] is just a link to Google's C++ style guide, a specific guide that makes sense for the very large C++ projects inside Google. Projects should create their own guides based on their requirements. The common ground is already there, you can read about it in C++ Coding Standards by Sutter and Alexandrescu. [2] is someone wondering whether they should replace C++ with a mostly-C++-compatible language for Firefox. First of all, they are complaining about memory safety, not management which plagues Obj-C just as much or even more, given the fact that it doesn't improve over C's safety like C++ does. Second of all, there are several libraries that can talk to the STL and effectively solve the UTF8 problem. [3] This can easily be done by the STL, which besides having an open source implementations is also an ISO standard.
- stephth 16y agoI can't tell if you're saying that examples are not enough to back my points or if those examples just don't back my points at all. If it's the latter: [1] is an example that illustrates the complexity of C++. Show me a style guide or debates about how to use the core of the language in objc. [2] is an example of someone unsatisfied with memory management and string support in c++. There are tons of those out there. Show me one for objc. Admittedly memory management is a matter of taste, but I retain/release/autorelease quite simple to use and I haven't found anything quite on a par with that mechanism in c++. [3] what do you mean "it can easily be done"? There's nothing being done there, the author is just observing how the implementation of arrays changes based on the size of the dataset; it's an example of the details behind CF. Are you saying STL automatically optimizes as well?
- leon_ 16y ago> Is anyone using Objective-C for some reason other than writing OS X or iOS apps? I'd love to. I played with GNUstep but ... it's just light years behind Apple's runtime. Obj-C is a pretty nice language if you like smalltalk OO.