Hacker News new | ask | show | jobs
by parkcedar 616 days ago
Mac isn’t really BSD, it’s a common misconception. It shares some of the userland code, but it’s a vastly different kernel (derived from the Mach microkernel). The userland has diverged quite significantly now too. Though, I guess it probably is closer to BSD than Linux
3 comments

Not a misconception at all.

Mac OS X was essentially a continuation of NeXTSTEP, which is BSD with a new novel kernel. In fact, if you look into the research history of the Mach kernel at the core of XNU, it was intended as a novel kernel _for_ BSD. NeXT went and hired one of the key people behind Mach (Avie Tevanian), and he became one of the core systems guy that designed NeXTSTEP as a full OS around Mach.

Early in the proliferation of the Unix family, member systems went in one of two directions -- they based their OS on upstream AT&T Unix, or they based it on Berkley's BSD, and added their own features on top. NeXT was one of the latter. Famously, the original SunOS also was.

While Sun would eventually work closely with AT&T to unify their codebase with upstream, NeXT made no such change. NeXTSTEP stayed BSD-based.

The other extant BSDs like FreeBSD and NetBSD were also based directly on the original BSD code, through 386BSD.

If I have my history correct, Apple would later bring in code improvements from both NetBSD and FreeBSD, including some kernel code, and newer parts of the FreeBSD userland, to replace their older NeXT userland which was based on now-outdated 4.3BSD code. I think this is where the confusion comes in. People assume MacOS is a only "technically" a Unix by way of having borrowed some code from NetBSD and FreeBSD. They don't realize that it's fully and truly a BSD and Unix by way of having been built from NeXT and tracing its lineage directly through the original Berkeley Software Distribution. That code they borrowed was replacing older code, also BSD-derived.

>but it’s a vastly different kernel (derived from the Mach microkernel).

XNU is a combination of a FreeBSD-Kernel (Networking, Filesystem, etc) and a Mach-Kernel (scheduling, ipc, virtual-memory etc):

https://en.wikipedia.org/wiki/XNU

https://www.youtube.com/watch?v=-7GMHB3Plc8

Yes, but since it was initially created I believe a lot of it has been rewritten. Eg, the filesystem. I suspect the memory system is different these days too, since macOS handles compressed memory quite differently (though not sure how that gets implemented under the hood).

FreeBSD is like a great grandparent, related but still very different.

Every extant Unix has been rewritten since the original AT&T code, Ship of Theseus style. We still consider them members of the Unix family, because they can trace their lineage directly. One could built a Git repo showing every code change from the original Unix release through modern day BSDs, if only we had granular commit info going back that far.

In fact, it's been partially done for FreeBSD, https://github.com/dspinellis/unix-history-repo

We could in principle do something similar for Darwin (if we had enough of the historical code), which is the core of MacOS, which is based on NeXT, which was based on BSD with a new kernel. That makes MacOS every bit as much a member of the Unix/BSD family as FreeBSD is.

No one really cares about the kernel internals, its origin or the license of it. What is prominent is the user-space components (i.e. shell and other binaries). macOS is closer to other BSDs than Linux is, as Linux usually ships with GNU libs and utilities.
You hardly notice the binaries though, especially since gnu cmd line utils are so similar anyway. You’d expect the c libs to be similar, but they’re not really (about as different as Mac to Linux anyway).
GNU utils are not similar to BSD utils. My hardest time adjusting to macOS was learning that some command line options I was so used to didn't exist or didn't work the same way.

Sure, you have ls and df, but they behave similarly only on the surface.