The mailing list for Linux kernel developers has revived a discussion that began six years ago about the prospects of using modern C++ code in the Linux kernel, in addition to the current use of C with assembly inserts and the promotion of the Rust language. The topic of kernel development in C++ was initially raised in 2018 by an engineer from Red Hat, who published a set of 45 patches on April Fool's Day as a joke, for using templates, inherited classes, and function overloading in kernel code.
The initiative to continue the discussion was put forward by Hans Peter Anvin, one of the key kernel developers at Intel and the creator of projects such as syslinux, klibc, and LANANA, who developed the autofs system for the Linux kernel, implemented RAID 6, and created the CPUID driver and x32 ABI. According to Anvin, who has authored numerous macros and assembly inserts in the kernel, the C and C++ languages have advanced significantly since 1999, and C++ has become better suited than C for operating system kernel development.
Capabilities that previously required specific GCC extensions can now be easily implemented in standard C++, and in many cases, using C++ can enhance the infrastructure without a complete code overhaul. The minimum specification mentioned is C++14, which includes the necessary metaprogramming tools, and the desired specification is C++20, which introduced support for concepts that can help eliminate many errors.
Anvin believes that C++ is more preferable than Rust, as the latter differs significantly in syntax from C, is unfamiliar to current kernel developers, and does not allow for incremental code rewriting (with C++, it is possible to gradually transition code from C, as C code can be compiled as C++). Support for using C++ in the kernel has also been expressed by Jiri Slaby from SUSE and David Howells from Red Hat.
Source: opennet.ru
