Originally posted by uid313
View Post
The Linux usage of C is a lot more memory safe than stock C++ usage. Yes this is purely because its not stock C and they have extend C. Yes sparse looks for extra attribute information in code that if not there it errors out. The plugins are looking for stack overflows and objects leaks. Objects Leaks are interesting one C++ and Rust are default tooling does not cover this.
How the argument to use C++ with Linux kernel has always falling apart is the same issue. Linux kernel C has been extended for a long time picking up issues a stock C or C++ compiler is not going to pick up. Adding C++ support would equal making the tooling to detect those extra faults more complex.
Rust has advantage with it borrow checker that it does check for at least some of what the extend C Linux kernel developers have made does check for as well as it base language being more strict.
C++ vs C with what is in the standard C++ wins the problem is this is not what the Linux kernel is. Linux kernel custom version of C happens to detect and prevent issues that stock C++ is going to let slide.
Lot of C++ so called better features end up depending on classes that end up using name mangling that creates it own form of issues for runtime introspection for kernel panics and the like. Rust yes has name mangling but you don't have to use name mangling features to get most of it extra protections.
The part where the instruction modern C++ falls apart is if I say you are forbin to usage of name mangling modern C++ no longer works to provide the protections.
Yes rust does not have classes but has traits that can be used to do same basic thing. Remember catch here coding a program in rust and being secure does not mandate you use traits/classes. Not using them means no name managing. No name managing less complexity in crash reporting code in OS kernel code.
Linus Torvald argument against C++ is mostly we can do X protections without name managing so what is the advantage of C++ other than making crash reporting code more complex. Rust language has lots of protections without using the name managing so Linux kernel developers see it as future acceptable.
Comment