Which has more source lines of code (SLOCs), Windows or macOS?

The problem with comparing lines of code in two different code bases is that there are many many different criteria and tools for measuring lines of code, and the tools often have many options. To properly compare two code bases, you would need to run the exact same tool with the exact same options on both code bases.

Because both code bases are closed-source, and the two companies most likely don’t use the same tools for counting lines of code, and they generally don’t like to publish line counts because people can jump to all sorts of conclusions, getting an oranges-to-oranges comparison is tough. (I considered saying “apples-to-apples,” but that seemed confusing and tortured, in the current context.) Sometimes, in-house tools are used to count lines of code. For example, I worked on developing one of the line counting tools for the initial versions of Windows NT. Also, the result you get depends on whether you count the user applications that ship along with the OS, the included drivers for all supported devices, only the raw OS itself, etc. And, of course, each of these operating systems is a moving target, because changes are being made to the source code daily, to fix bugs, close security holes, add features, improve performance, etc.

That said, the last source code line count comparison between Windows and macOS I saw put Windows at about 55 million lines of code and macOS at 87 million lines of code. But keep in mind that there is no guarantee the two counts used anywhere close to the same tools, the same options, or even the same definition of what a line of code actually is. And keep in mind that the Windows line count includes features for all flavors, including desktop and server versions. Based on this data, I suspect that macOS has more lines of code than Windows. But without knowing what all was included in the comparison, without having a common definition of a line of code, and without using the exact same tools and options, we can only just speculate.

The conclusions you draw from one OS having more source lines than another is another exercise in speculation. Coding style alone can change the number of reported lines, even if the code does the exact same thing. Complex code can be squeezed into a single line that can be very hard to read and maintain. Having more lines of code doesn’t necessarily equate to more complexity, more bugs, higher maintenance costs, etc. Analysis beyond counting lines of code is required to make those sorts of judgments.