The OS X Kernel is Open Source
I think people either don't know this or forget about it, but the OS X kernel environment is open source, which obviously is the core of the iPhone OS as well. It doesn't include all of the stuff at the GUI layer, but there is a ton of code in there that is generally kept in sync with current consumer product releases.In addition to being the core of OS X, Darwin itself is a free-standing open source operating system in the same sense that Linux or FreeBSD is. As far as I know, you can install X11 on it and run it as a standard UNIX OS with whatever window manager and desktop environment you like.
The Darwin repository also hosts CoreFoundation lite, which has the source for a number of classes used in the C-based CoreFundation API that backs Cocoa's Foundation framework. If you want to see how the guts of NSString work, you can just look at CFString.c. In fact, there's a lot of interesting stuff in there even if you're not writing Cocoa apps. A free online ADC account is enough to get access.
The OS X Kernel is Open Source
Posted Sep 26, 2008 — 20 comments below
Posted Sep 26, 2008 — 20 comments below
Elliott Hughes — Sep 27, 08 6398
The good part of Mac OS is all the other stuff, not Darwin. And the Linux kernel is the least problematic part of the average Linux distro.
If you're only trying to tell Apple developers that they can see their kernel source too, this post might be clearer without the middle paragraph.
MatzeLoCal — Sep 27, 08 6399
NeatLittleMacApps.
Maybe Apple should be a bit noisier about their OpenSource-Stuff.
Scott Stevenson — Sep 27, 08 6400
Particularly surprising considering WebKit.
MatthiasWolf — Sep 27, 08 6401
I think the apple community is the only one, aware of apples commitment. I was talking to this linux guy the other day. While he was aware of WebKit, he wasn't aware it is comes from Apple. The same goes for CUPS, which Apple acquired a while ago
Apple should definitely be more noisy about it's open source commitment.
SJC — Sep 27, 08 6402
As one example: you mention CoreFoundation. Core foundation requires the open source Objective-C to run, which in turn requires the closed source "libauto" garbage collection library -- with the result that you can't run Core Foundation. And without CoreFoundation you don't get vital stuff like launchd.
Visit PureDawin.org for a few more of these gotchas and progress trying to get things working. Apple will fix these problems when people find them, so the more of us looking at the code the better.
Rafael Bugajewski — Sep 27, 08 6403
Nigel Kersten — Sep 27, 08 6404
Most of the Darwin stuff I end up poking at won't build (with darwinbuild or otherwise) due to private frameworks.
(An Apple person very recently told me to bug report these though, as usually it's just a case of someone forgetting to get something released...)
The real value for me as a sysadmin at least is simply being able to browse the code. It's awesome when you can lodge a radar and reference specific line numbers in Apple's released code when discussing a problem.
Jeff Johnson — Sep 27, 08 6405
MatzeLoCal — Sep 27, 08 6406
In my opinion WebKit is one of the best examples how a large company could contribute OpenSource.
Scott Stevenson — Sep 27, 08 6407
You didn't mention specifics, so I'm not sure if we disagree. Clearly the "lite" version is different by definition for the reasons you cite, but I don't know if that really prevents it from being useful in the way you suggest. I do see how the wording made it sound like Foundation was backed by CFLite instead of CF, so I changed that bit above.
That said, I don't think reading CFString.c and drawing conclusions from that is going to send you down the wrong path. It wouldn't be in anyone's interest to maintain two radically different versions of the same Foundation-level class. In fact, ridiculous_fish has referred to CFLite sources a number of times to describe how Foundation works.
If you think I've misunderstood your point or I'm missing a critical piece of information, let me know. Admittedly, I haven't gone line-by-line through the CFLite sources.
@Elliott Hughes: If you're only trying to tell Apple developers that they can see their kernel source too
That was part of it, but the other reason was to address the idea that some new Mac users have (often coming from Windows) that you can't get "under the hood" of Mac OS X. I don't think this is true in even the general sense, but certainly you can't get much more under the hood than kernel source.
Jeff Johnson — Sep 27, 08 6408
It is in Apple's interest to protect its Cocoa source code. Note that CFLite is always the last to be released when they open source a new Mac OS X update. Perhaps they need to spend more 'sanitizing' that code.
Evil Twin of Sarah Palin — Sep 29, 08 6412
For Apple, Darwin is mostly just a handy excuse not to document the Core OS layer properly. They don't need to do a good job documenting the driver model for individual driver families, because: hey, go look at the source.
WebKit is actually the only example from Apple of a good open source project (emphasis on the open).
Darwin could be run that way and, bonus, Apple's core OS would suck a whole lot less. It's not that people aren't interested -- there has been a lot of interest. Darwin build-process related problems are a popular topic on the darwin-dev list. Some Apple manager has decided not to spend the resources required to make the kernel and other parts easily buildable by outside parties. Yes, the engineers will accept patches (when they don't arbitrarily close your radar bugs because they misunderstood you -- the Darwin group must be the thickest-skulled people at Apple), but it will break again in two seconds, because Apple doesn't use the same bits internally. This could be fixed, but it would require a few days of work and some discipline, and god knows, that's not the Unix way and we are Real Men Unix programmers.
Sorry for the rant, but it's all true.
Ted Wise — Sep 29, 08 6413
Reza Jelveh — Sep 29, 08 6414
That's probably because it didn't. It came from the KDE peeps. And afair apples opensource commitment was indeed awful at the beginning. BUT that is no longer the case.
Scott Stevenson — Sep 29, 08 6415
WebKit was originally based on KDE's KHTML engine, but that was forked over six years ago. I haven't looked at all of this in a while, but my recollection (and I could be wrong) is that the version of KHTML they started with was far from having even complete CSS2 support, but they loved the simplicity of the code base. In fact, there was so much code coming from the WebKit side that it became a bit of a public disagreement for a while.
Reza Jelveh — Sep 29, 08 6416
I'm rather happy with Webkit thought. And as someone else stated cups was acquired by apple, which is, I guess a bit to its advantage. But Webkit seemed to have a rather "bloody" history. :p But yes, that seems to be history.
Michael Engel — Oct 07, 08 6469
The Jaded Consumer — Oct 13, 08 6486
Apple was making updates to WebKit, not the KHTML tree. Apple's fork diverged quite severely for genuine design reasons, and Apple makes its code changes available -- now, even faster than previously. The value Apple has added in its fork is underscored by the fact that WebKit rather than its older cousin KHTML has been chosen to serve as the the back-end of tools like Google's Chrome, Adobe's Apollo, Torch Mobile's Iris (for WinCE), and Nokia's S60 browser.
I understand that taking code contributions from Apple might seem like trying to drink from a fire hydrant, and that Apple's (understandable) practice of making updates against its own tree rather than KHTML's tree is less convenient for KHTML folks, but this isn't an evil of Apple and it's not a slight against KHTML: WebKit is currently more heavily used and is under heavier development, and should be expected to end up exerting the gravitational pull of a planet, despite that the KHTML folks imagined Apple would just be launching a little satellite.
As mentioned in comments to my discussion of Chrome (which I enjoyed using wile evacuated to North Texas for Hurricane Ike), Apple's SquirrelFish javascript engine is already in bake-offs with Google's V8, which can't help but advance users' interests as better performance and more stable code is created to obsolete some of the garbage they've been fed in the browser world from vendors who don't need to be named.
It's not like Squerrelfish isn't also an open-source Apple offering.
Apple seems to have realized that it benefits from standards, and from being able to leverage good code into projects. Apple hasn't violated its open-source obligations with respect to code, even though there are people who wish Apple would spoon-feed fixes back into their trees rather than just release what they have changed in their own trees. Frankly, though, Apple can't afford to do that. Apple isn't getting its code from KHTML in block imports, it's making changes to its own tree.
By comparison, in projects like FreeBSD -- from which Apple does take code imports -- Apple has upstream contributors working on the source project's code base. Some folks actually credit Apple with much more in connection with FreeBSD.
Other Apple projects include the CalDAV implementation it released, its ZeroConf implementation, the CUPS code it helped support until it finally hired the developer full-time, the streaming server, and Apple/Genentech BLAST.
It's fun to blast Apple, sure, but Apple is doing more than nothing for open source. It's not a charity, but it's a definite contributor. Apple has figured out that it benefits from standards, and that works for everybody against single-vendor lock-in.
Daniel Ct — Oct 14, 08 6487
http://cafeine.crulrg.ulaval.ca/users/dccote/weblog/0514e/CoreFoundation_on_Linux.html
Cyprian Gwd — Apr 29, 09 6725