From nobody Mon Sep 09 12:46:04 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 4X2RQw3pNcz5WJW9 for ; Mon, 09 Sep 2024 12:46:16 +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 4X2RQw3CnTz4Dyr; Mon, 9 Sep 2024 12:46:16 +0000 (UTC) (envelope-from theraven@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725885976; 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: in-reply-to:in-reply-to:references:references; bh=0hPdbqbzO7FaYvh+NC8nbVMZ9iDb0oUlTOZ85UMW7iA=; b=YH+YWiksaJhRTmZCo5MoIBLS4ogB0+f9LE/OneYDGLNmQorCAn6ianywBhYqDevaQgT8aX bbEzX8dLLwMyAF72UnDU06kD1OxGBdXJjscP77rpQVBWh0zbM+RdGOokR0s4Mi4FebLnLi ly2RJDDhNlJlrDQ39SLYbwHfvvauCAszMCf/cF4LgwpEyOGgD2cSTTp0CZ4+bC65H2MbJi 5eMK5rv04UtyMlhdBJdAK2rU9pe1j04gFvM/QvAPVP+mCZ6UkjgUWhOCUEEWD0iVvnG+R3 octjQF3hDiJxSf+ZP8R031c/PC+4BWDjWIjUpy2NBhdDUNcQve3mNMAV+zc8YQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725885976; a=rsa-sha256; cv=none; b=Fv+eBeGWN9Uznk+A3vUsqMPiyCqzIrFfMKYrWyMQYrW0ZEuAifi+ld0bgQlE6zQQ7UFibJ s7R/o/JCb8hNTRvFniof5vQYV4xo+5mIn+sXTwjRtUAJ6RrEMaRvWCzaY5b+Kxw490+iBz PQKsmZF/a9tSTLmgfIznc1gilvUXHTfRCEISisuokeI8xp715MPwAJVRCw8uVDA9c4QbLH F3JK2IsIavDNDIgTDqZJRBnxB8YD4rNkfVlcKr4OpUFbNMdGPPLJ3ZW8bGyxFTKgrGwTvQ dlWxkvG/1ByLAfC0JYWewekke/0YjmkWi+paKjh+5wet8tqDtMPEIb/F4bggag== 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=1725885976; 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: in-reply-to:in-reply-to:references:references; bh=0hPdbqbzO7FaYvh+NC8nbVMZ9iDb0oUlTOZ85UMW7iA=; b=fB+K9FVQCxO6oxuq28QzafYvkr37F+DV5HiPfjCDVQmF20ulfghSaYAABgI30bJK5S6fFo 7Mnf5XkMoiFgTrBlsCTNhk2MXCwhBiqCjW6ojSbUzebQJkTlr0czk97f6Ck6eAbtJUxFDX UHkNuGxqjT/wE1crBbp37dS5bOGvwy0yV9L7g/ZMIgr00AyROyyJtgtW8OqiCWOZ2yxXsn H9goFJiYiWXzu09gW8KAV4zjijtyqK4avQhiogPSyqU3EE9rrvIm7FBwvjCx1eo/op1R2B 84WAqdO/SCZxrwb2mN8fhy3Wns/287/PmLpwN1EgPvHdbT3gJ4fEMKGZcdDoTA== 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 4X2RQw2btNz16nZ; Mon, 9 Sep 2024 12:46:16 +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 75C4D6588; Mon, 09 Sep 2024 13:46:15 +0100 (BST) From: David Chisnall Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_4DECCAE9-2F68-44CA-AEF5-C7C0B93B0F69" 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 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: The Case for Rust (in any system) Date: Mon, 9 Sep 2024 13:46:04 +0100 In-Reply-To: <202409091124.489BOWk2082765@critter.freebsd.dk> Cc: ske-89@pkmab.se, freebsd-hackers@freebsd.org To: Poul-Henning Kamp References: <202409091304.aa20239@berenice.pkmab.se> <202409091124.489BOWk2082765@critter.freebsd.dk> X-Mailer: Apple Mail (2.3776.700.51) --Apple-Mail=_4DECCAE9-2F68-44CA-AEF5-C7C0B93B0F69 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 9 Sep 2024, at 12:24, Poul-Henning Kamp wrote: >=20 >> What might that subset be? >=20 > 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=E2=80=99s 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 --Apple-Mail=_4DECCAE9-2F68-44CA-AEF5-C7C0B93B0F69 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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=E2=80=99s 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

= --Apple-Mail=_4DECCAE9-2F68-44CA-AEF5-C7C0B93B0F69--