From nobody Tue Jan 23 09:41:01 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 4TK2CY4gBxz57gc0 for ; Tue, 23 Jan 2024 09:41:13 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TK2CY4S93z52k2; Tue, 23 Jan 2024 09:41:13 +0000 (UTC) (envelope-from theraven@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706002873; 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=y2RmnzA9+rmGDZGLzFqUyYXG731+SHgR3wpgJYxANrI=; b=B/osMV4ryUzUy5jghqWxLJKY7aIMxVBmzvMtILkYL76G8oTimeayeGUi3QN44YEBJ0XfAw VeTkfmlk2q9uWEMCvbo4I4SskNLYsbq92YLYAwOMfJVVT2hjjmIepz0D8O/4Cn/IjnUlLd W//DoA/QhSDd0hDs/Iumj92ABjKHSkAftvbCH7+EDJCP3tnbeOjHgq1xsljDwxzBc4It6K Sg4v2ludlWNJEc03DCn55DfABiSsmhvy31pGf799dz/jqb9wH7O8rFxiAyRS8WGqVtknc3 7Ef/gOpx6E1vLZzW3403tnjU8usc6bTNygJks4z/mHmcsyYd8XdzdtI6wnKHzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706002873; 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=y2RmnzA9+rmGDZGLzFqUyYXG731+SHgR3wpgJYxANrI=; b=gbDsQ+ncRVXzCKlOSecbu0EtuydruK+j2CTrmhuQH+tlEH/Aivf5lyP0Y8fquoRLv5qX2K ORxUG69vcvqtHrW37f5mqLz+fGHRebK2rYXkMB7Mt1w9TLbTodqhynX4uilA4XgMjVyU2o rLY31uHS9X7zm5oFqN7gKdyQQKf0Y/SG1UEW/L3Ac9oFeyEfJtFAYlLWDJXZnyM4+fIFDz l0hrNb2UNV1Jh1n+xbv+npc3G6KiHb4F/P4++hhEqiJm1o+09WxoOCGbLRvA8fAvVtbRAG QKbbcOxYRJU2lCroK+0KU+WS85JB4xseVaFDQ85xTUa6y1bewxtXAK992zsY0g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706002873; a=rsa-sha256; cv=none; b=fpvZo4+4ouQhxrnS3UJndyTwiVBC6LDKuVRowee0N1C4wRUUg3McUzSMFgR6Neae7I/NWD 1dvzrUDbfXWWWbS5624arZqmZAeLr4Sey5BDzdoRkQhMzJSAFSiE/Q2UA1EUtcSgh7t8r7 K9lrAf2r1iKz+IFMilbHg+e1QB6fbdD00sTcCgBBEGMxEc78ZDdOiSHxzOE83FbpUy1huq zmUBPT7RNu/6pEm+HeKhBiuFyLNOKx3jF06g2gbP0ZpL/UJNydtJvoCpkKNkpxiyEJhRyL JQmPV4oo/ZDwAABJm9Rm16x/PqmHiUSXJ0NRj3wWKMpm+T4yoZopRvTr2F3NzQ== 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 4TK2CY3SMXz1FWc; Tue, 23 Jan 2024 09:41:13 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from smtpclient.apple (host109-153-95-118.range109-153.btcentralplus.com [109.153.95.118]) by smtp.theravensnest.org (Postfix) with ESMTPSA id B6434BF4A; Tue, 23 Jan 2024 09:41:12 +0000 (GMT) From: David Chisnall Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_D32357AB-84CC-416C-992B-1A0C0BCFDB0C" 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 \(3774.200.91.1.1\)) Subject: Re: The Case for Rust (in the base system) Date: Tue, 23 Jan 2024 09:41:01 +0000 In-Reply-To: <20240122164543.066e3cec@venus.private.rrbrussell.com> Cc: freebsd-hackers@freebsd.org To: "Robert R. Russell" References: <1673801705774097@mail.yandex.ru> <202401210751.40L7pWEF011188@critter.freebsd.dk> <20240121102421.GE14773@memo2.memo.frmug.org> <2f38cbcd-61a9-42b7-b7e6-ebd261fe66da@FreeBSD.org> <20240122164543.066e3cec@venus.private.rrbrussell.com> X-Mailer: Apple Mail (2.3774.200.91.1.1) --Apple-Mail=_D32357AB-84CC-416C-992B-1A0C0BCFDB0C Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 22 Jan 2024, at 22:45, Robert R. Russell = wrote: >=20 > Having had the luxury or curse of not being stuck with only one > programming language I have learned usable pieces of several. C++ is > not on that list even though I have the most formal education in it. > My best way of answering why is this. Would you write or use a C++ > codebase maintained by the average developer with just Vi? Up to C++03 > I can say yes, after that the answer is no. I have no idea what this means. There=E2=80=99s absolutely nothing in = newer C++ that makes it harder to write with a text editor. There is a = lot that makes it easier to write correctly. For reference LLVM is about 4MLoC (and about 5M lines of comments, = something that FreeBSD could definitely learn from) and is written in = modern C++. I don=E2=80=99t think I=E2=80=99ve ever used an editor = other than vim to work on it. I don=E2=80=99t use nvi, because it=E2=80=99= s not the =E2=80=9880s anymore. I use ALE with vim, which integrates with clangd via LSP and provides = autocompletion and error reporting for anything that can generate a = compile_commands.json. That=E2=80=99s not specific to C++. I = wouldn=E2=80=99t want to write C without syntax highlighting, = autocompletion, or live error checking either. It=E2=80=99s possible to = do so for C or C++, but you=E2=80=99ll be less productive. > A consequence of Microsoft's "Welcome back to C++" item that may have > gotten missed is what resources are they spending to enforce = compliance > with a certain C++ standard? I have no idea what this means. =E2=80=98Compliance with a certain C++ = standard=E2=80=99 is a thing that your compiler tells you when you try = to compile. =20 > Particularly, to enforce the restrictions on anti-patterns? That varies from project to project. I generally use clang-tidy and = clang-format in pre-merge hooks in CI for the projects that I worked on = at MS and that I work on personally. And, of course, code review. = Automated tooling is no substitute for code review. =20 > Cargo needs approximately a dozen lines in a > configuration file to restrict its upstream sources. That includes > whitespace and formatting. Here is the script that runs formatting and static analysis across a = codebase that I maintain: = https://github.com/microsoft/cheriot-rtos/blob/main/scripts/run_clang_tidy= _format.sh Almost all of the complexity is in *not* running it on files that we = have imported from elsewhere or where, for compliance with external = standards, we don=E2=80=99t want to enforce our naming rules, and for = finding the relevant toolchain files. The actual checker bit is right = at the end. Most projects run this kind of check through their build system, but we = wanted to run it on headers in isolation as well as on full compilation = units. =20 David --Apple-Mail=_D32357AB-84CC-416C-992B-1A0C0BCFDB0C Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 On 22 Jan = 2024, at 22:45, Robert R. Russell <robert@rrbrussell.com> = wrote:

Having had the luxury or curse of not being = stuck with only one
programming language I have learned usable pieces of = several. C++ is
not on = that list even though I have the most formal education in it.
My best = way of answering why is this. Would you write or use a C++
codebase maintained by the average developer with just Vi? = Up to C++03
I can = say yes, after that the answer is no.

I have no idea what this = means.  There=E2=80=99s absolutely nothing in newer C++ that makes = it harder to write with a text editor.  There is a lot that makes = it easier to write correctly.

For reference = LLVM is about 4MLoC (and about 5M lines of comments, something that = FreeBSD could definitely learn from) and is written in modern C++. =  I don=E2=80=99t think I=E2=80=99ve ever used an editor other than = vim to work on it.  I don=E2=80=99t use nvi, because it=E2=80=99s = not the =E2=80=9880s anymore.

I use ALE with = vim, which integrates with clangd via LSP and provides autocompletion = and error reporting for anything that can generate a = compile_commands.json.  That=E2=80=99s not specific to C++.  I = wouldn=E2=80=99t want to write C without syntax highlighting, = autocompletion, or live error checking either.  It=E2=80=99s = possible to do so for C or C++, but you=E2=80=99ll be less = productive.

A consequence of = Microsoft's "Welcome back to C++" item that may have
gotten = missed is what resources are they spending to enforce = compliance
with a = certain C++ standard?

I have no = idea what this means.  =E2=80=98Compliance with a certain C++ = standard=E2=80=99 is a thing that your compiler tells you when you try = to compile.  

Particularly, to enforce the restrictions on anti-patterns? =

That varies from project = to project.  I generally use clang-tidy and clang-format in = pre-merge hooks in CI for the projects that I worked on at MS and that I = work on personally.  And, of course, code review.  Automated = tooling is no substitute for code review.  

Cargo = needs approximately a dozen lines in a
configuration file to = restrict its upstream sources. That includes
whitespace and = formatting.

Here is = the script that runs formatting and static analysis across a codebase = that I maintain:


Almost all = of the complexity is in *not* running it on files that we have imported = from elsewhere or where, for compliance with external standards, we = don=E2=80=99t want to enforce our naming rules, and for finding the = relevant toolchain files.  The actual checker bit is right at the = end.

Most projects run this kind of check = through their build system, but we wanted to run it on headers in = isolation as well as on full compilation units. =  

David

= --Apple-Mail=_D32357AB-84CC-416C-992B-1A0C0BCFDB0C--