35

In several languages, instead of returning something like "macOS", the command to view the operating system instead returns

Darwin

I see this in languages like R, and node.

Why is macOS sometimes called Darwin??

  • 3
    It is for the same reason that Ubuntu OS is often called "Linux" or RaspberryPi OS is called "Linux" - Linux is not an OS. It is a kernel that can be used as the core of your OS. Which is why we call Android an OS even though it uses the Linux kernel – slebetman Sep 23 at 16:25
  • 7
    Darwin, however, is an OS, not just a kernel (the kernel is called xnu). Apple used to make it available as a separate OS, complete with binaries, installer, ISOs, etc., but they stopped many years ago. – Jörg W Mittag Sep 23 at 18:26
  • 2
    MacOS is the whole package. Darwin does not have the Aqua GUI so it is plain text or - like most other Unix/Linux variants - an X11 GUI. – Thorbjørn Ravn Andersen Sep 24 at 10:09
63

Why is macOS often referred to as 'Darwin'?

It isn't. macOS isn't Darwin and Darwin isn't macOS.

The history of macOS is long, convoluted, and complicated.

It starts with Steve Jobs (not entirely voluntary) "leaving" Apple and founding NeXT. NeXT wanted to revolutionize the Personal Workstation. They built both a powerful computer, the NeXT Computer (later NeXTstation and NeXTcube), and a powerful, modern Operating System, called NeXTStep. (Get it? The next step for the next computer. Really creative naming.)

The Operating System was based on porting BSD to a Mach microkernel, and adding object-oriented system libraries, frameworks, and toolkits (called "kits", which you can still see in Apple's naming today), with an object-oriented GUI framework and desktop, with object-oriented applications, all written in a modern object-oriented programming language (Objective-C) as the systems language, on top of the base BSD system. The display system was based on PostScript, and there was even an Intel i860 coprocessor running a stripped-down version of the OS, only for Display PostScript processing, plus a powerful DSP for video and audio processing.

NeXTStep pioneered many things we see in modern GUI programming. It had one of the first graphical GUI Builders, which still to this day is how you design GUIs for macOS, iOS, iPadOS, etc. (Today, it is called the Xcode Interface Builder.) It had the first ever App Store. When Tim Berners-Lee invented the World Wide Web, he chose NeXTStep as the OS to write the first browser for. Many game studios used NeXTStep and NeXT workstations for their development, e.g. id software for Doom, Doom 2, and Quake. Lotus Improv, still considered by many to be miles ahead of Excel even now, was implemented on NeXTStep.

Later, NeXT divorced the higher-level frameworks from the underlying OS and made them available under the name OpenStep for Windows NT, Sun Solaris, and under the name "OPENSTEP for Mach" still based on the same underpinnings as the original NeXTStep.

At this point, Apple had tried and failed multiple times to modernize MacOS, and they bought NeXT (thus bringing Steve Jobs back into the company) and all of its Intellectual Property and technology to develop a successor to MacOS based on OPENSTEP for Mach. They modernized the Mach kernel from 2.5 to 3 and extended it with concepts from the FreeBSD kernel to form a kernel known as xnu (a reference to the failed nuKernel project at Apple which was to develop a "new kernel"), and the BSD underpinnings from 4.3BSD to 4.4BSD and later FreeBSD.

Most importantly, they extended and expanded the OpenStep APIs and built new APIs on top. The collection of those APIs is known as "Cocoa". They also built an API called "Carbon", which was a close, but not identical re-implementation of a subset of the MacOS API on top of the new foundations. (The intention was that while it would not be possible to simply re-compile existing MacOS applications, it should be fairly easy to port them to Carbon, and then over the years rewrite them in Cocoa.)

The first prototype of this system was called Rhapsody. The full system wasn't finished in time, so a subset was released as MacOS X Server 1.0. And the rest is history: Rhapsody became MacOS X, then OS X, then macOS, and somewhere along the way, iOS was split off, and then further divided into iOS, iPadOS, tvOS, and watchOS.

Now, back to Darwin: Darwin is basically the underpinnings of macOS, from the xnu kernel, IOKit, drivers, etc. up to the BSD libraries and userland, plus some macOS-specific developments such as mDNSresponder and launchd. It does not, however, include any parts of what used to be OpenStep, Cocoa, Aqua, Quartz, QuickTime, or any of the other higher-level stuff. It does contain drivers and filesystems, although I am not entirely sure whether APFS is part of Darwin.

If you think back to the point in time where NeXT "divorced" the high-level OpenStep from its underpinnings, the low-level parts that are not OpenStep would be the ones that would later become Darwin.

In the beginning, Apple used to make Darwin available as a separate OS, including compiled binaries, installers, ISOs, etc. that you could install on Apple hardware. However, for many years now, Apple only provides a source code dump, every time a new release of macOS comes out. It isn't even possible to compile this source code, because it depends on Apple's internal build tools and build pipeline. There have been some projects trying to patch Darwin to compile it with publicly available tools, but those projects have all died from lack of interest.

Since all of the things you mentioned were born on Unix and use Unix APIs and Unix libraries, they actually typically don't even know about the "non-Darwin" parts of macOS, so it is only logical that they will consider the OS to be "Darwin". Note that "Darwin" is also what gets returned as the name of the OS when you call the Unix/POSIX int uname(struct utsname *buf) library function or the uname Unix/POSIX commandline utility.

So, to answer the question you didn't ask explicitly but is implicit in your question: why does Node.js return "Darwin" for the name of macOS? Because when Node.js asks macOS for its name, that's what macOS tells it its name is!

| improve this answer | |
  • 7
    @ljrk: There are many, many fun facts surrounding Sun and the history of macOS. Patrick Naughton, a developer at Sun disliked C++ and was a huge fan of Objective-C, so he decided to quit Sun and work at NeXT. However, shortly before he left, he ran into Scott McNealy, who told him about a super-secret project to develop a new language at Sun, and if he had such strong opinions about language design, he should direct his inputs there. So, Naughton joined the Oak (later Java) team as one of the lead designers. Later, during NeXT's decline, several other high-level Objective-C and NeXTStep … – Jörg W Mittag Sep 24 at 0:24
  • 5
    … developers left NeXT to work on Java. Many people are blinded by the C-like syntax or comparisons with C++, but Java is almost a carbon copy of Objective-C with static types and garbage collections. (interface is directly cribbed from protocol, for example.) Also, large parts of the core libraries are influenced by NeXTStep, for example, all the wrapper classes were designed by NeXTSteppers. That's why they're called Integer, not Int, for example, because the NeXTStep guys valued clarity over keystrokes. And the other thing is that apart from Rhapsody, Apple also worked on another – Jörg W Mittag Sep 24 at 0:27
  • 4
    … (failed) next-gen OS together with IBM, called Taligent. Like NeXTStep, Taligent also morphed from a complete OS into a class library ported to multiple existing OSs. And Taligent was both a huge influence on Swing, and a smaller influence on Aqua. That's why the Java integration with Apple's own JDK was so amazing: Java and Objective-C are very closely related, the core Java libraries and Cocoa are closely related, and there are common "genes" between Swing and Aqua. This, together with Apple's approach of deeply integrating the JDK with Objective-C/Cocoa and Swing with Aqua made for … – Jörg W Mittag Sep 24 at 0:31
  • 4
    … "close-to-native" Java experience, at least as long as Apple supported Java. Nowadays, unfortunately, we have to make do with a "generic" JDK that runs on many OSs instead of Apple's tailor-made one. Apple did the same thing with Ruby: they developed MacRuby, a tightly integrated Ruby implementation (again, Objective-C and Ruby share Smalltalk as a common ancestor, so it was possible to deeply integrate them.) – Jörg W Mittag Sep 24 at 0:33
  • 6
    @stevec: That is what Apple programmed the library call that returns the system name to return, so at least according to Apple, that is correct. Whether you consider that "right" or "wrong" is a question that only you can answer. Note that I am 100% sure that you are not using a native macOS implementation of R but rather the standard Unix version, so it makes sense that it returns the name of the Unix system underpinning macOS. In fact, if the separate Darwin OS were still a thing, it would probably run unmodified there. – Jörg W Mittag Sep 24 at 5:54
24

Darwin is the core upon which macOS (previously Mac OS X, and OS X) runs on.

It is derived from NextSTEP, which itself is built upon a BSD and Mach core, but Darwin is the open source portion of macOS.

Historically, when Apple bought NeXT in the late 1990s, they built upon the NeXT operating system (NeXTSTEP) to form the basis of the next version of the OS for the Mac.

See Wikipedia's Darwin entry for more details.

| improve this answer | |
  • 13
    Darwin is not the kernel. The kernel is xnu, which in turn is composed of multiple services running on a modified Mach microkernel. – Jörg W Mittag Sep 23 at 16:53
  • 1
    If you change "kernel" to "core" or "core OS", your answer would be correct. The word "kernel" have a very specific definition is the UNIX world and Darwin is not the kernel, Darwin is between the kernel (XNU) and the final OS/distribution (macOS, iOS, etc.). – zakinster Sep 24 at 8:02
  • 1
    After the edit this is better but I still think > derived from NeXTSTEP ... built upon a BSD and Mach core < is not really "correct". XNU is part of Darwin and based on a BSD-ified Mach Kernel. Darwin also contains other BSD libs and BSD core utils. So it's more like: Darwin = XNU + Userland, with Userland being of BSD heritage and XNU of shared BSD and Mach heritage – ljrk Sep 24 at 8:57
10

There are lots of ways to fingerprint an OS, but a canonical method for this on unix-like systems is to call uname Which outputs Darwin on all macOS versions and builds.

Apple publishes the source code to the Darwin part of the OS so you can inspect the code that matches the name.

https://opensource.apple.com/release/mac-os-x-100.html

If you want to see this yourself, open a shell (in Terminal.app) and you can generate the Darwin string and read the manual page for uname command or the system call (man 3)

uname
man uname
man 3 uname

Here's a nice example of a program needing to know which system is running by calling uname from a shell script. It then adjusts syntax and variables to do the same task on various OS:

I'll leave the "Why did human beings do this" for another time - that story is rich and multifaceted and there's tons of stories documented publicly on the Internet for the curious.

| improve this answer | |
  • 5
    Slight nit:uname isn't programmed to answer Darwin; it's programmed to look at known external resources to find the name of the platform it is running on. – chepner Sep 23 at 13:31
  • 1
    I'm pretty sure YARV doesn't shell out to the uname command. It is more likely, it uses the int uname(struct utsname *buf) POSIX library call. – Jörg W Mittag Sep 23 at 16:57
  • @JörgWMittag your answer is stellar as are the comments here. Thanks all for the information and thoughtful points made. – bmike Sep 24 at 17:06
7

From Wikipedia, Darwin is an open-source Unix-like operating system first released by Apple Inc. in 2000. It is composed of code developed by Apple, as well as code derived from NeXTSTEP, BSD, Mach, and other free software projects.

| improve this answer | |
  • 2
    And the next line in the wikipedia article : "Darwin forms the core set of components upon which macOS, iOS, watchOS, tvOS and ipadOS are based" explains why macOS is sometimes technically reffered to as a "Darwin" OS. – zakinster Sep 24 at 7:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .