Re: The Case for Rust (in any system)

From: David Chisnall <theraven_at_FreeBSD.org>
Date: Mon, 09 Sep 2024 12:46:04 UTC
On 9 Sep 2024, at 12:24, Poul-Henning Kamp <phk@phk.freebsd.dk> wrote:
> 
>> What might that subset be?
> 
> Initially it will be "better C compiler", but then we will gradually
> allow more and more of C++ to be used.

In my experience, the worst C++ code is written by people thinking in C.  The second worst is written by people thinking in Java (or Smalltalk).

This is where the real problems come in.  It’s very hard to characterise bad C++ in terms of language features.  The same language features are used to write good and bad C++.

For example, virtual inheritance is can be used to build deep hierarchies that are painful to work with.  It can also be used to build type-erasure where an inline template does the static checking and then forwards to a generic interface, which reduces code size.  Both of these use the same feature, but only the latter should be encouraged.

In general, a lot of C++ features exist for the purpose of building abstractions and do not need to be used directly by users of those abstractions.

David