How much math does Linus Torvalds know

Pay please! Linux: more than 25 million lines of code

The source code directory of the Linux kernel recently passed the 25 million line mark - including blank lines, comments, documentation, images and a few others. There is no end to this growth in sight, after all, Linux development has been following the same pattern for many years: Linus Torvalds releases a new kernel version every nine or ten weeks. As a result, Linux recently added an average of 290,000 lines thanks to new functions and improved drivers. No wonder, because new hardware components and computer technologies keep appearing that anyone wants to use with Linux - sooner or later manufacturers, Linux distributors and occasionally hobby developers provide support in the kernel.

Size comparison

Reminder: The term "Linux" in this text only means the kernel of this name and not operating systems built with it such as Android, Fritz! OS or Ubuntu. In the third pre-release version of Linux 4.14 released on Sunday night, the sources of this very kernel include exactly 25,023,143 lines.

One and a half days later, when this text was published, this number happens to be correct. A little later, however, it will be history, because Linus Torvalds integrates some changes into the main development branch of Linux almost every day. There he is currently preparing Linux 4.14, which should appear in the first half of November. Linux 4.13 was just under the 25 million mark with 24,767,008 lines of source code. The kernel broke through this when Torvalds integrated the main changes to the network subsystem for 4.14 that other developers had previously collected and reviewed.

For comparison: The files in the source code tree of Firefox 56 contain 31,342,142 lines, those of LibreOffice 5.4 to 17,171,162. In case you're thinking "stupid apple and pear comparison", here are the numbers for the kernels of FreeBSD 11.1 and NetBSD 7.1: 8,960,399 and 7,183,689 lines, respectively. But that too is ultimately just an apple and pear comparison, after all, Linux supports significantly more architectures and offers many more functions - at the same time, of course, the two BSD derivatives also do a number of things that Linux cannot.

Kernel approaches from Windows and Linux

We owe a comparison with the Windows kernel: Microsoft keeps it under lock and key and does not say how many lines its source code currently comprises. To compare this number would be even more absurd than the BSD comparison, after all, Windows uses a hybrid kernel. The core functions of such kernels are exported to fixed programming interfaces via which file systems, drivers and many other functions can dock; these can therefore be developed independently of the core of the kernel, which Microsoft probably does too.

Linux, on the other hand, is a monolithic kernel in which the core functions, file system code, drivers and the surrounding infrastructure are all contained in a source code tree. They exchange information via programming interfaces, which the Linux developers adapt from time to time in order to meet new requirements. Since all the code is in one place, you don't have to worry about backward compatibility: when you change the interfaces, you simply adapt the code that uses them. With the programming interfaces used by applications (the "userspace API"), kernel developers consider downward compatibility to be sacred.

Share distribution: drivers, architecture code, ...

Drivers make up the bulk of the Linux source code, because the directory alone currently contains 14,966,279 lines of code. That’s not even all drivers, because those for sound hardware are in. Now, of course, you could easily include the directory in an analysis - the 1,048,676 lines of code there also contain a lot of infrastructure through which applications interact with the audio functions of the kernel and its sound drivers. If you include this code, in fairness you would also have to include directories such as, and, after all, they provide the infrastructure for the use of storage, crypto and network hardware.