Re: The Case for Rust (in any system)

From: Jan Knepper <jan_at_digitaldaemon.com>
Date: Mon, 09 Sep 2024 14:29:06 UTC
On 9/9/24 03:01, David Chisnall wrote:
> On 8 Sep 2024, at 22:11, Poul-Henning Kamp<phk@phk.freebsd.dk>  wrote:
>> Warner Losh writes:
>>
>>> I did C++ in the kernel in the 4.x->7-current time frame.
>> The logical progression of C++ adoption would start with using a C++
>> compiler as a better C compiler.
> C permits implicit casts from void*, C++ doesn’t. The last codebase I worked on that had gone through this transition was littered with implicit casts which made it hard to read. At a minimum, I’d want to add an always-inline templates wrapper around malloc that did the right thing, if not an explicit move to new/delete.
I have always found this to be a benefit.
Where C just casts away, C++ requires to 'review' to cast and show via a 
*_cast < ... > mechanism that the 'cast' is actually meant that way.
> C++ places type and value names in the same namespace. There are some corner cases where a structure and a variable have the same name and sizeof gives different results in C and C++ modes.
>
>
I have never found this to be a problem. They are indeed (rare) corner 
cases. (I also think I have noticed that particular C++ compilers at 
least warns when this might happen).

However, I do think if compilation would be moved from C compiler to C++ 
compiler that particular coding standards have do be defined and followed.
The proper standard being set and followed will prevent issues.