Is Objective-C only used for development on Mac OS/iPhone? [closed]

拥有回忆 提交于 2019-11-27 15:39:32

问题


I don't know Objective-C but to me it appears a nice language. But the only context I know it from is everything Apple. But Objective-C is even in the GNU Compiler Collection.

Is there something missing in the open ones? Or is there already a broader base for Objective-C? I'm interested if there are companies that chose Objective-C to develop their products.


回答1:


I think ObjC has been isolated to the Apple world through a quirk of history and the nature of proprietary systems.

First, you need to separate ObjC from Cocoa. ObjC is a very primitive language. I think it is a very elegant language, but it is extremely basic. You can implement ObjCv1 in a C pre-processor. C++ and ObjC were developed about the same time. C++ put a huge amount of infrastructure in place to bring a C-like syntax to what is basically a completely different language. ObjC brought a Smalltalk-like syntax to C, with almost nothing else. Even things like +alloc and -release aren't language elements of ObjC. They're fairly simple wrappers around malloc() and free().* Standing on its own, ObjC isn't really that interesting (elegant as I think it is). This is very similar to the nature of Smalltalk. Without its object libraries, there isn't much you can do with it. With its object libraries, it's incredibly powerful.

NeXT provided this entire framework on top of ObjC called NeXTSTEP. Since the NeXT computer was not a widespread commercial success, and NeXTSTEP was proprietary, not many people learned the framework or the underlying language. When Apple bought it, and morphed it into Cocoa, it continued to be a proprietary system.

GNUStep is out there, but they never developed anything interesting enough to bring in a lot of developers (a major web browser or word processor or the like). And Cocoa has gotten well ahead of GNUStep over the last few years. It's possible that with the rise of interest in Cocoa due to iPhone, that GNUStep may revitalize and bring a nice cross-platform development framework, but I kind of doubt it. Folks who have a background in C++ look at C# and see a clear improvement. When they look at ObjC, they see a lot of square brackets where they don't expect them. For people raised on the "calling methods" paradigm, the Smalltalk paradigm of "passing messages" is alien and even a bit scary. Many developers assume they need a strongly typed language to avoid bugs and are uncomfortable with a system that relies primarily on programmer discipline and careful consistency. It is much easier to hack something that "just works" in C# than in ObjC. ObjC really expects a lot more of the developer in understanding what's going on and not relying on the compiler to protect you from your hacks.

Basically, folks knew C from Unix, and C++ makes sense in terms of C, and Java makes sense in terms of C++, and C# is just cleaned up Java. ObjC isn't any of these. It's Smalltalk, and no one learns Smalltalk anymore.

* I recently chatted with the guy who wrote +alloc about its history, and he might object to my calling it a simple wrapper given the inclusion of zones. So for you who know the difference, replace +alloc here with +new.




回答2:


Well, there is also the GNUStep framework that some people still develop for. I don't know how active that community is, however.

But for the most part Objective-C is now an Apple language, as illustrated by the fact that the "2.0" version of the language was launched as part of OSX 10.5 and seems to have been a purely in-house development effort at Apple.

Edit: Apple, as you probably know, has something called the Cocoa framework, which basically refers to the entire stack of libraries for Objective-C, including the NSObject common baseclass. Cocoa is a continuation of the NextStep library, which GNUStep is the open-source version of. So you'll find many of the NS-prefixed classes both places, but Apple has not held back in adding new classes or changing them in Cocoa, so interoperability at the GUI level is really only a theoretical possibility.




回答3:


@Stephen: I'm constantly surprised at how people never read our website or even check on the progress of the project before saying things like this. :) GNUstep follows Cocoa closely now and we're so much more than OpenStep at this point. If you, or others, want to have a real opinion on the subject get GNUstep from SVN, install it and try it out. Pontification about something you know nothing about (as demonstrated by your response here) is pointless.

Greg C. GNUstep Lead Developer




回答4:


GNUstep is actually much more active than most people think it is, and very worth keeping an eye on. It's not hard to create apps that work across GNUstep and Cocoa (meaning potentially on OSX, Win, Linux, BSD...)

These links are definitely worth checking out for anyone interested in the topic:

http://www.gnu.org/software/gnustep/information/aboutGNUstep.html

http://etoileos.com/news/

http://www.nongnu.org/gap/

Then there is Cocotron, an "open source project which aims to implement a cross-platform Objective-C API similar to that described by Apple Inc.'s Cocoa documentation":

http://www.cocotron.org/

EDIT: For an example of a commercial cross-platform product built with GNUstep, check out Eggplant.




回答5:


GNUstep. There is also Étoilé which is an OS built with GNUstep.

I think many people just like C or C++ better, and if they wanted a more modern language, they would use C# or Java.




回答6:


I think the Apple implementation is just better supported and still in active development. There are some other places, such as GNUStep, but they still look to be very much at the NextStep/OpenStep level. Unfortunately a lot has happened since then!




回答7:


The Mono team are doing something with iPhone development which allows iPhone apps to be written in .NET and cross-compiled with the Mono .NET compiler(s). Check it out at http://www.mono-project.com/Mono:Iphone

The latest .NET Rocks podcast has Rory Blythe talking about stuff he's been doing in objective C and iPhone development.



来源:https://stackoverflow.com/questions/874690/is-objective-c-only-used-for-development-on-mac-os-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!