> The answer I was hoping for is "Oh, you can get the OpenStep libraries
> here, and if you use POC to compile them to plain-C you can then write
> the interface in C." It seems to me that this is possible in theory
> if not in practice, and it's the path I'm going to try to take.
I am no fan of Objective-C, myself. When I first started developing for
MacOSX I looked for ways to make an end-run around it. Carbon is just
awful, so that's out. In the back of "Inside MacOSX: The Objective-C
Programming Language," there's very thorough documentation of the C
functions that make up the Objective-C runtime, and I suspect those
could be used to produce a mostly C interface to Cocoa, if you really
worked at it. It wouldn't be fun, though, and it would be a hell of a
lot of work. You'd have to become an expert at Objective-C internals,
which is pretty much the *last* thing I want to do. Cocoa makes heavy
use of Objective-C's runtime polymorphism so a C interface wouldn't be a
very good fit anyway.
Even if you got that to work, you'd still be stuck with what I consider
to be the absolute worst part of Cocoa: retain/release/autorelease.
There's no getting around the fact that Cocoa expects NSObjects to work
that way. You can't just malloc() things into existence and then free()
them later on, as much as I'd like to.
So what I'm doing instead is writing a C++ API on top of Cocoa. You can
get by with a surprisingly small amount of ObjC in that case. I'd guess
it makes up less than five percent of my codebase. Once I get wrappers
written for all the controls and views and fonts and rects and points
and so on I plan to use, and get them all thoroughly debugged so that
the retain/release crud doesn't cause me to leak buckets-full of
objects, then I can program in C++ and pretend to be blissfully unaware
of what's going on underneath.
I'm almost done, only four or five more control wrappers to write, but
it was a *huge* job. It's part of a larger project, so I'm not sure how
much time I've devoted to just the Cocoa C++ wrapper, but I'd guess it
was six months of full-time work. *Way* too long. I should have bailed
when I realized what a big job it is but I am very stubborn. At this
point I'm sticking with it out of sheer hard-headed-ness.
If I had it to do over again I might very well write a Cocoa port for
wxWindows instead. There's another guy claiming he's doing that but
he's not making much progress. I can't work up much e*ment for
that, though. wxWindows tends to use MS Windows metaphors: everything
is a window, you draw with a DC, lots of operations require brushes,
etc. Not my bag.