From nobody Mon Sep 9 07:01:42 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 4X2Hnb2wyWz5Vx1Y for ; Mon, 09 Sep 2024 07:01:55 +0000 (UTC) (envelope-from theraven@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 4X2Hnb2VDRz4N8J; Mon, 9 Sep 2024 07:01:55 +0000 (UTC) (envelope-from theraven@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725865315; 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=GTRevHB2z4D32Pj52JHdpxVD2A3d/6lAuzxzQPSWU2c=; b=ZgoyzM4EVuztrL63n29BQy2US4yW2D34T4eFGdLsMLVW0W15mc8de4CSYboje6xjjQdjAx kO0L3pQzroNmY/Z3D5d8Ez7YhW1+OlQSbYJS7618XXdLn43VGAZS8wAoxkXFfNUTGNOOVh hch+LqKOC88Ka8kEijhq9APtWifBGkaEtReCIYAuvoHowoY1+tb4IFuvp3sMwrw/OEJlZ1 pMQ6578S/MMEcnBhMu0WvAPUzpcgbTlyy7++9TVjo0VEkXmrcwEu/hXnTQnK3lZ/XK4oub 2aI4IY0xm++x7E3hTQzfhXMlpj5DFNIvHW/JW8lACs9qEGUgXrcOf7uAKcFj6w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725865315; a=rsa-sha256; cv=none; b=HDsecJoX1V/3YPY63HZ3ciC6giZR1MT6ZDbHePRWgPfizVpcOWODH0TTZlf8dM4r+i4sks M7XHgge5Ps/1oBQLgdDPUdsMdKE4WdRK/XTu+KA1I2w+ftryycdiHONP1pVEWTRjopPff2 aHEs/bN4R3WiMBl/dZ2ld3VurcdA51KmkweIzSuTqyFhMQ7pDGnsTx4zKe5fnun4BuV4vn vz1lsLR6tmLRClUzxPacylBF5lNUHUvcC0af8OHqlxoiuqxTLiPBOQUWAshBI4KYdNFL4g dqJJFPDL8aHgk2rCv2eeNUaDYGjzvqJDeyw1fpUO/AVToeTDGBt6AC2riJ24fA== 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=1725865315; 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=GTRevHB2z4D32Pj52JHdpxVD2A3d/6lAuzxzQPSWU2c=; b=No2VJ64zNqJYjKt31X1BtNO43gnVccwsbi2oaVIxSaS9YI9FfmOULP150Xv9PMp32QTTc3 fU8mOIJjsn2eHxwE6gbOn0muFT225P/CAZt2gAovEgCL5lROQmGbp5dICalbF4BrYudl7M lIPgqssK+Oob4AXfR8sggXy/cMSPk1wSrfgjHW9dFRbtHRelt0xw3eQbNYkEMjV5s6N/mU eqy1f+Yx/YNmpfQdCBhSS+QQG6shmVIcMa8v2WEKZQ5DXJ6ecdGbnTtiuywToDW0N4JXgi Prq8wC/y++Ydndj2pg8i5GBSArW4webYpB5zKmsfChNkanRYlkFJ4maZ7yPpNQ== 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 4X2Hnb23qNz13HR; Mon, 9 Sep 2024 07:01:55 +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 1A5516580; Mon, 09 Sep 2024 08:01:54 +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: Mon, 9 Sep 2024 08:01:42 +0100 Message-Id: <202DD893-B152-4B38-AE9B-862E08785396@freebsd.org> References: <202409082111.488LBTtI074660@critter.freebsd.dk> Cc: Warner Losh , Kristof Provost , Alan Somers , Dmitry Salychev , Jan Knepper , FreeBSD Hackers In-Reply-To: <202409082111.488LBTtI074660@critter.freebsd.dk> To: Poul-Henning Kamp X-Mailer: iPad Mail (21G93) On 8 Sep 2024, at 22:11, Poul-Henning Kamp wrote: >=20 > =EF=BB=BFWarner Losh writes: >=20 >> I did C++ in the kernel in the 4.x->7-current time frame. >=20 > The logical progression of C++ adoption would start with using a C++ > compiler as a better C compiler. I=E2=80=99m always a bit nervous about this: C=E2=80=99s struct initialiser syntax is useful for things that look like o= ptional parameters in C APIs but is invalid in C++. I believe clang and gcc s= upport it in C++ mode in some places, but I=E2=80=99m not sure where. C++ has stricter aliasing rules than C. Some things that are valid C and wil= l do the right thing with -fstrict-aliasing will incorrectly compile in C++ m= ode. C permits implicit casts from void*, C++ doesn=E2=80=99t. The last codebase I= worked on that had gone through this transition was littered with implicit c= asts which made it hard to read. At a minimum, I=E2=80=99d want to add an al= ways-inline templates wrapper around malloc that did the right thing, if not= an explicit move to new/delete. 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 d= ifferent results in C and C++ modes. Compiling C as C++ will *normally* give the same output, but not always. David