From nobody Fri Sep 6 07:41:44 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X0Sq84Tfgz5WFN5 for ; Fri, 06 Sep 2024 07:41:56 +0000 (UTC) (envelope-from theraven@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X0Sq841Tzz4Rxk; Fri, 6 Sep 2024 07:41:56 +0000 (UTC) (envelope-from theraven@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725608516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QMsZwDOdbWr+5Wp57aZJAuYIwDyJEWkQdBeDYrhFujA=; b=vqxnfR0Q4WE8rISm/dabOVTubFqYQq8dEN2UdtAN20x7Fqtpasesz4kJMsqEJb49xJly0C eaIOkQAjGNhquUfa6mT0hpSOzJAfKFzymwtsOJkzedxOKwwMjdHcVS7UhavF64RO43+JRk uv2G1alGk+UNEUxkyuI/XJvs1LFsSgoihWE8I3lEqo5lj4LiNSiuD2Fq5kOEol2FV7we9A q+gcZSXwVx9EHDhSM78IQGprjh68jt+1Zsp2Oq5+Avw+iDjAtcOauWOHH/K5aW5vSamorI Tts5CD2va9GJt/8kE7qMGuAoO67ejZ7ukQ7vYv+wO1VG/r/tj4+XVHt9/f6uKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725608516; a=rsa-sha256; cv=none; b=Jm5bYhaa0vG8jDRCQZYeY4agqGFm3sJHQRqqaJ6BSlmxi2A2kFXtied3jvrlYKHZSzOdDX +LnzzlVTLCkSDy+k9/XNJn9q4LkpaKSjVBsh2xNaXQvzYJcErrz0NlPgsgQeB20o3Rc7hO jFGrNV8WsHH1au5kedkGHPvDh7eQQ8wfRgzqLVGDMYUn0qUn6+WzFmXTfHVzTxn+N1PHwq nOGNM3qFmU7ZWT+e46LYHB8fygvd2+/kRhTJlQ+FcDdPAm1qhEX0aWOjmal6Sc+MWradMu h9c+BrlyvFoua8LOEnAo5VZhCmKJH79alIVjc9emKH8uJPFkx21Sx7kdr4KP0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725608516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QMsZwDOdbWr+5Wp57aZJAuYIwDyJEWkQdBeDYrhFujA=; b=QJOm/uHd7Fz8bDpquhDxQPaszuNQZ2N4xBNQHJW7ieDl4UM7QBC8DbjEBOmMX3RACVYxWo 5yeU1YuC21UDF8EtX+mvJ4y0O+axOxKO+UIBNETt6X0IhFbxFMHmGgGBRdaspOBwkm5sy3 KicSRG0n3JUMg/r5vqYkG4HAgMpcqpICRKKpyw9muwV2k/KnFW3Weq+Nxh3UppvxuPEiQ+ InusgyiO6ulgxvZ9qOV5ETKyJ+lDYa4Uit0SVhnNrjIDNlAzUbhHkfHnO3PCAYBkxpl/dn WrTUs5hn1GPuvD5OfPDhvhfz+DRzKQEVrI7iWhnpZGKb37sPDtVxVnWLcvt9nA== Received: from smtp.theravensnest.org (smtp.theravensnest.org [45.77.103.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: theraven) by smtp.freebsd.org (Postfix) with ESMTPSA id 4X0Sq83ZvmzHSD; Fri, 6 Sep 2024 07:41:56 +0000 (UTC) (envelope-from theraven@freebsd.org) Received: from smtpclient.apple (host109-155-136-107.range109-155.btcentralplus.com [109.155.136.107]) by smtp.theravensnest.org (Postfix) with ESMTPSA id BFB4464FB; Fri, 06 Sep 2024 08:41:55 +0100 (BST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: David Chisnall List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org Mime-Version: 1.0 (1.0) Subject: Re: The Case for Rust (in any system) Date: Fri, 6 Sep 2024 08:41:44 +0100 Message-Id: <4E4FB8CC-A974-42C4-95D5-2E1E4BF681AD@freebsd.org> References: <202409060725.4867P3ul040678@critter.freebsd.dk> Cc: Alan Somers , Dmitry Salychev , Jan Knepper , freebsd-hackers@freebsd.org In-Reply-To: <202409060725.4867P3ul040678@critter.freebsd.dk> To: Poul-Henning Kamp X-Mailer: iPad Mail (21G93) On 6 Sep 2024, at 08:25, Poul-Henning Kamp wrote: >=20 > I will also note that almost all the blame for C's current status > lies with the standardization efforts, which almost seem hell-bent > on destroying the language rather than improving it. As someone who is involved with C++ standardisation and so periodically hear= s things from WG14, my impression is that the people who care about the thin= gs that you list have all moved to C++, where they were solved problems at l= east a decade ago. The people still actively driving C are the people who di= dn=E2=80=99t leave because they don=E2=80=99t want these things (and, increa= singly, C++ people who just want to make sure that C doesn=E2=80=99t diverge= too much from being a subset of C++). It=E2=80=99s trivial to write a packed struct in C++ where the fields are al= l BigEndian that do byte swapping on implicit conversion to and from T, f= or example. Integer ranges can be implemented in the same way and there is a= proposal to add them to the standard library that looks nice (the ranged in= tegers are a small part, the proposal is mostly about units and quantities).= Having written a kernel in C++, and worked on two in C, and read a reasonabl= e amount of one written in Rust, I am firmly of the opinion that C is absolu= tely the worst choice for writing a kernel. This was not true in the =E2=80=98= 80s and it wasn=E2=80=99t true even 15-20 years ago, so the question is how t= o move from where we are to where we should be. The strategy document that I= coauthored at Microsoft recommended the following: - C++ conforming to the Core Guidelines and with static analysis for existi= ng C/C++ projects with the C parts incrementally migrated to C++. - Rust, C#, or TypeScript for new projects and discrete new components with= well-defined interface boundaries. - No new C code, except in open-source projects that accept only C contribu= tions. That=E2=80=99s probably not quite the right shape for FreeBSD (at the very l= east, I=E2=80=99d recommend Lua instead of C# or TypeScript in most places).= David