Is Objective-C used without Cocoa?
Asked Answered
D

3

6

It seems that Cocoa seems to be the main platform for Objective-C. GCC (which Xcode uses) supports Objective-C so it must be available on a wide range of platforms.

Are there any notable cross-platform projects that use Objective-C but not Cocoa (or its open source cousin GNUStep)? Is it really used outside the Apple ecosystem?

Darr answered 19/2, 2010 at 16:50 Comment(2)
I can't tell for sure from your wording, but just for clarity, you do realize that GNUStep is cross platform, right? "GNUstep currently supports Unix (GNU/Linux and GNU/HURD, Solaris, NetBSD, OpenBSD, FreeBSD, Darwin) and Windows" quoted from gnustep.orgWhistler
Yes, I understood that. I'll clarify. I'm trying to ask whether Obj-C is used as a general purpose language (in the same kind of contexts as for example, C or C++) rather than for only interacting with libraries / frameworks such as Cocoa or GNUStep.Darr
R
12

Objective-C has also been popular in the scientific and financial services communities. There are still many Objective-C based applications deployed in banking, mostly on the trading analysis front. A friend works on a nearly million line of code Objective-C based analysis and trading engine for which they have written their own class hierarchy from scratch.

At one point, one of the more popular Linux window managers was written in Objective-C. That was a few years ago and may no longer be the case.

The LLVM compiler also compiles Objective-C, including having full support for Blocks. It is quite portable, too.

There is also David Stes's Portable Object Compiler. It compiles Objective-C to C and uses a class hierarchy that is based quite directly upon the original ICPak class hierarchy from StepStone.

Reflection answered 19/2, 2010 at 16:58 Comment(0)
J
4

It seems what you're asking is if Objective-C is ever used without Cocoa, or GNUstep, or Cocotron, or any API like them.

The answer is basically no. Without an API like Cocoa (or GNUstep, etc.), Objective-C isn't very useful. For example, without NSObject, retain and release wouldn't even exist. A ton of very important features are built into these APIs, so it's somewhat pointless to use Obj-C without one of them.

Jarvisjary answered 19/2, 2010 at 23:10 Comment(2)
Ok. That's the answer I was looking for! Thank you. I forgot that the all-important NSObject is defined in the API not the language (you would have thought the NS would give it away...) FYI the reason I was asking is because I was thinking tidying up a straight C project with some Obj-C and that led me onto the question.Darr
The Objective-C runtime (the older one on Mac OS X and the GNU runtime) defines an object called Object that has many methods in common with NSObject, although some have different names. It doesn't contain release/retain but it's enough to start your own framework independent of Cocoa.Gild
S
0

Yep, there sure are. The one I can think of from the top of my head is Cocotron. An effort to port AppKit to Windows.

http://www.cocotron.org/

Aside from that, Objective-C can be used on any platform that gcc will run on. You won't have the wealth of frameworks that are available in Cocoa on OS X or the iPhone, although as you mentioned, GNUStep does a pretty good effort.

Starflower answered 19/2, 2010 at 16:54 Comment(3)
GNUStep (which includes the wmaker window manager and its own graphic app builder) is definitely anything but Apple API centric - they are derived from the same NeXTStep objectiveC that Cocoa is based on.Whistler
It depends if you believe Steve took the spirit of Apple with him in 1985... :) I meant NeXT and its successors (including Apple).Darr
@Justin Smith: GNUstep does not include wmaker, they just play nicely together and lately GNUstep tries to focus on being Apple compatible.Dicrotic

© 2022 - 2024 — McMap. All rights reserved.