Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jan 2024 15:04:31 +0000
From:      David Chisnall <theraven@FreeBSD.org>
To:        "Robert R. Russell" <robert@rrbrussell.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: The Case for Rust (in the base system)
Message-ID:  <48FF6847-FCF0-4B6D-AC67-E3B939294847@FreeBSD.org>
In-Reply-To: <20240123085540.42f8b70c@venus.private.rrbrussell.com>
References:  <CAOtMX2hAUiWdGPtpaCJLPZB%2Bj2yzNw5DSjUmkwTi%2B%2BmyemehCA@mail.gmail.com> <1673801705774097@mail.yandex.ru> <CANCZdfpqWgvV_RCvVO_pvTrmajQFspW%2BQ9TM_Ok3JrXZAfeAfA@mail.gmail.com> <ef4ad207-5899-42b6-8728-bc46f1417e9e@antonovs.family> <202401210751.40L7pWEF011188@critter.freebsd.dk> <20240121102421.GE14773@memo2.memo.frmug.org> <2f38cbcd-61a9-42b7-b7e6-ebd261fe66da@FreeBSD.org> <20240122164543.066e3cec@venus.private.rrbrussell.com> <D846A8E3-1FE3-4A82-B9C3-5FA3BE7406A0@FreeBSD.org> <20240123085540.42f8b70c@venus.private.rrbrussell.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 23 Jan 2024, at 14:55, Robert R. Russell <robert@rrbrussell.com> =
wrote:
>=20
> The specific anti-patterns is was thinking of in both instances is
> called Meta Template Programming. Back in C++03 I just used the
> template system as a form of generics. In that role it works well and
> with the new smart pointers definitely improves some of the older
> problems C++ had.

Template metaprogramming is a core feature of C++, and more recent =
versions have added constexpr / consteval / constinit and concepts to =
make it a lot more readable.  It can be abused, but it is not, in =
itself, bad.  My example from earlier in the thread used template =
metaprogramming to do compile-time checks of correctness of the overflow =
/ wrapping behaviour of a ring buffer.  Making it easy to check =
properties of your code at compile time is very much a feature, not an =
antipattern and it=E2=80=99s hard to see how you could argue the =
converse without arguing that bugs are a good idea.

> However, C++ definitely has a complexity cult and a ricer cult in its
> community. The overlap between the two appears to be fairly large =
which
> worries me.

Non-specific ad-hominem arguments are tremendously unhelpful.

> I have less reservations about C++ than I did earlier, though I think
> the build system may require major surgery to support it well.

The build system for both userspace and the kernel already support C++.  =
I have written a kernel module in C++ in the past.  Currently, there=E2=80=
=99s no mechanism in the kernel loader to support COMDATs (and I don=E2=80=
=99t really want to add it, I=E2=80=99d much rather handle them as an =
install-time preprocessing step for kernel modules), so you can=E2=80=99t =
load kernel modules that use inline functions / variables, but that=E2=80=99=
s orthogonal to the build system.

David





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48FF6847-FCF0-4B6D-AC67-E3B939294847>