Lately I have been working on a version of Nu that I have modified to run on Linux. For now, it’s running on Ubuntu (Server 7.10), but other distributions can be easily supported. As you might imagine, there are several things that make this interesting.
1. Apple uses a custom version of GCC to compile its dialect of Objective-C. While many Apple changes have made it into the trunk, many are still out. However, all the source for Apple’s changes appears to be on Apple’s darwinsource web site. But even with that source available, I think that most Linux users would prefer to work with the stock versions of GCC that ship with common distributions.
2. There are two distinctly different Objective-C runtimes. For historical reasons, Apple’s is called the “NeXT” runtime and non-Apple systems use the “GNU” runtime. Apple’s runtime appears to be cleaner and faster (no surprise, since Apple is the largest and most successful corporate user of Objective-C), but GNUstep and most other Objective-C software on non-Apple systems uses the GNU runtime. Both runtimes are open source. The GNU runtime is GPL’ed, the Apple runtime is released under the APSL.
3. There is no obvious replacement for the Foundation framework, which Nu uses for much of its implementation. So far, I’ve looked at three possibilities:
a. the GNUstep “base” library. This may be the most mature, but it is LGPLed, seems a bit heavy, and has a very established style that developers coming from the Apple world may not like (such as using shared libraries instead of framework bundles).
b. Christopher Lloyd’s Cocotron project. This looks promising, but requires a custom runtime and has an infuriating build system that requires you to first build a custom gcc on OS X, copy over a bunch of headers and libraries from your target system, and then set up Xcode to cross-compile. To be fair, Lloyd’s focus is more on Windows application development, but to me it seems silly to set up a cross-compilation system to target a Linux desktop/server installation. So because it requires a non-standard gcc, for now I’ve dropped Cocotron in favor of the most lightweight choice of the three, which is…
libFoundation. It was written by Mirceau Oancea and Ovidiu Predescu and is currently maintained by Helge Hess. It is used in a set of frameworks called sope. libFoundation is BSD licensed and was relatively easy to build. But because its build system requires GNUstep (which I’m avoiding for now), I’m building it with a makefile that I’ve written myself (and I write terrible makefiles).
I’ve been doing this work in a VMware virtual machine running Ubuntu, and keeping my files outside VMware and NFS-exporting them into my Ubuntu VM. That’s let me continue to use TextMate as my text editor. It has also been handy a few times when I’ve accidentally bricked my VMware images and had to start over from backups.
For the last few years I’ve been completely off of Linux and exclusively working on OS X. But despite that, I managed to get from my first VMware install to a fairly workable Linux version of Nu in a little over a week, and a big part of that time was spent just figuring out how to build debuggable versions of the GNU runtime and libFoundation.
That was faster than I expected. Partly that’s because by now, I have a lot of experience working with Objective-C runtimes. But more importantly, this time my Objective-C runtime and Foundation library are fully open-source and debuggable. Until you’ve experienced it, you have no idea how much easier it is to work on a fully open-source stack.
I hope to get this into shape to share soon, but first I want to clean up and merge my changes back into the main Nu sources. There are a lot of differences between the two runtimes, and I want to try to minimize their effects before going much further. For now I’m staying with the GNU runtime, because even if I manage to compile the Apple runtime on Linux, there are likely to be many problems due to Mach/Linux differences and Apple’s GCC customizations.
There are still many Nu regression failures, but so far they seem to be due to differences between libFoundation and Apple’s Foundation classes.
But wow. It’s possible to run Nu on Linux, and it doesn’t even seem to be that hard. And once Nu goes cross-platform, perhaps RubyCocoa and PyObjC will too. Right, Laurent & Ronald?