Are there any advantages of using Rust instead of C in the Linux kernel?

BearPear@lemmy.world to Linux@lemmy.ml – 87 points –

Will there be performance and security improvements?

35

You are viewing a single comment

Performance? Not really no. I believe C is slightly faster with Rust and C++ competing for second place. The benefit is safer code as Rust is built with performance and safety in mind. It highlights what potential errors can be found where making human error way less common. Instead of potential null errors types are wrapped in an option enumerator which ensures you know there can be a lack of a value. Expections are also enumerators done similarly with a result object so you know which functions may fail. Instead of using memory and potentially forgetting to free it we have the ownership system.

How is C faster than C++? Unless you use virtual functions, it's as performant as C. And you definitely wouldn't use virtual functions in a kernel.

C++ is only as fast as C if you use only the parts of C++ that are identical to C. In other words, C is faster than C++

You can use compile time polymorphism in C++ without any runtime performance cost.

Compile time has got to be part of the convo esp when it comes to the kernel. The Linux kernel is one of the few bits where end-users are actively encouraged to compile from source. It is a feature!

Adding C++ compilitis is pain for what gain, from a kernel pov.

I am not a big fan of c++ overall however that is because other languages have emerged that are sweeter than C that gate some of the people issues with C++.

Anyone who has ever had a thing that was like a thing but not exactly the thing, in C, knows C ain’t great at that.

Unfortunately, that's not true

The description says:

In this video, we'll do a deep dive on what C++ Polymorphism is, what "virtual" does under the hood, and ultimately why it is SUCH a performance hit compared to languages like C and Rust.

This is not about compile-time polymorphism.

6 more...

Since C++ has Turing complete compiling, I guess technically it can go infinite compilation time

6 more...
6 more...