Newly released Cocotron lets developers code Mac APIs under Windows

16

Author: Nathan Willis

Don’t ask developer Christopher Lloyd about Back to the Future — that’s the other guy. This Lloyd does have a mad-scientist-like devotion to the Mac platform’s Cocoa application programming interface (API), though, and he is sharing it through the open source Cocotron project, which developers can use to cross-compile Cocoa applications from the Mac for use on Windows, and eventually Linux.

Lloyd’s involvement in Cocoa actually predates Cocoa itself, going all the way back to his days writing mainframe apps for the NeXTSTEP operating system. When the OpenStep specification came out, he says, he knew he would need a compatibility wrapper to migrate the NeXTSTEP code — so he wrote it himself. “I was and still am pretty hooked on Objective-C,” he says. “Java was really taking off then and OpenStep was one of the few things going for Objective-C at the time.” NeXT’s OpenStep became Mac OS X’s Rhapsody, which then eventually became Cocoa.

All the while, Lloyd was tracking the changes and adding to his personal project. He took it public in December, naming it Cocotron and putting in under the MIT license. “I think the license is a strong point. It can be used in closed source systems and you can integrate closed source with it and never have to distribute changes. If you enjoy working with Cocoa on the Mac but would like to be on Windows someday, the Cocotron is a good place to start.”

The current release implements two important Apple frameworks: Foundation and AppKit. The Cocotron Web site also distributes a package called Cocotron Developer Tools (CDT) containing gcc, some GNU utilities, and the MinGW utilities for Windows, all bundled for Apple’s XCode development environment . Using CDT, XCode can be set up to cross-compile existing Cocoa applications from the Mac for use on Windows.

Lloyd decided to target Windows systems first, in an effort to appeal to more programmers. The platform-specific parts of Cocotron’s AppKit implementation are still lagging for Linux, a situation Lloyd hopes will improve as additional developers discover the project and contribute code.

Some have already discovered Cocotron, and want to know why Lloyd chose to go it alone rather than join the GNUstep project. The answer is two-fold.

First, as part of the GNU project, GNUstep code is licensed under the GPL and LGPL. Lloyd wants to make his project attractive to commercial developers as well, so he licensed it under the MIT license, which makes sharing code between the two projects incompatible.

Second, although GNUstep does follow some of the changes to Apple’s Cocoa, its primary goal is implementing the OpenStep specification. Cocotron exists to follow Cocoa as closely as possible.

It is clear that in both cases, Lloyd’s driving principle is making Cocotron bridge the gap between Mac OS X and Windows programmers. “I am more interested in making Cocoa an approachable technology. One of the problems the Mac has is that it ends up with lame-o ports from Windows. If we can turn the situation around, where people are using Cocoa and then porting to Windows with Cocotron, then in a roundabout way make the Mac and Cocoa more acceptable technologies.”

At this stage, Cocotron is far from complete. In fact, when I asked Lloyd what he would say to a Mac developer looking to port applications to Linux or Windows today, he readily admitted that GNUstep is the way to go.

But the fledgling Supreme Cocotron Committee (as Lloyd calls it) is focused on fleshing out the missing pieces of the framework so that it is useful for cross-platform developers. In the short term, Lloyd is putting his energy into porting existing open source Mac development tools to Cocoa — calling it a good way to iron out bugs and a good motivation for filling in blanks. In the long term, though, he hopes the project will open up new platforms for a generation of Cocoa developers currently writing their software only for Mac OS X.