December 31, 2022
On Monday, 26 December 2022 at 04:06:05 UTC, Richard (Rikki) Andrew Cattermole wrote:
> On 26/12/2022 4:57 PM, Paul Backus wrote:
>> I agree that the friction cannot be reduced to zero. I still think it is probably possible to reduce it to, say, 50% of its current amount, without compromising on quality.
>
> Here is a big one: remove the damn style checkers!
>
> Automatic format on PR and commit right back into remote branch.
>
> Problem solved. No more CI errors.

Genuine curiosity, because maybe you have experience with that that I don't: how would this work with multi-patch PRs?

I ask because, personally, I don't find CI style checks to be a problem, especially if there's an easy way to run a local tool to check and/or fix things on a patch-by-patch basis.  That way I can make sure that the code is both style-compliant and that it "reads" well for me.  OTOH I do have a bit of a problem with the idea of an external system rewriting my code for me, especially if the result is messy -- like a series of patches that violate code style followed by an auto-generated fix-the-style patch.

Maybe that's too fussy ... ?  But my experience has tended to be that when people entirely outsource style-compliance to external tooling, you wind up with a lot of quite ugly code and harder-to-follow patches.
December 31, 2022
On 31/12/2022 9:36 PM, Joseph Rushton Wakeling wrote:
> On Monday, 26 December 2022 at 04:06:05 UTC, Richard (Rikki) Andrew Cattermole wrote:
>> On 26/12/2022 4:57 PM, Paul Backus wrote:
>>> I agree that the friction cannot be reduced to zero. I still think it is probably possible to reduce it to, say, 50% of its current amount, without compromising on quality.
>>
>> Here is a big one: remove the damn style checkers!
>>
>> Automatic format on PR and commit right back into remote branch.
>>
>> Problem solved. No more CI errors.
> 
> Genuine curiosity, because maybe you have experience with that that I don't: how would this work with multi-patch PRs?

I don't see how it would differ, the format is a new commit as part of the PR.

See: https://mskelton.medium.com/auto-formatting-code-using-prettier-and-github-actions-ed458f58b7df

> I ask because, personally, I don't find CI style checks to be a problem, especially if there's an easy way to run a local tool to check and/or fix things on a patch-by-patch basis.  That way I can make sure that the code is both style-compliant and that it "reads" well for me.  OTOH I do have a bit of a problem with the idea of an external system rewriting my code for me, especially if the result is messy -- like a series of patches that violate code style followed by an auto-generated fix-the-style patch.
> 
> Maybe that's too fussy ... ?  But my experience has tended to be that when people entirely outsource style-compliance to external tooling, you wind up with a lot of quite ugly code and harder-to-follow patches.

You've got the problem right there. There is no tool to run locally. Its mixed between a few different CI runner types. They are all simple tests, like end of line white space and all have less than desirable error messages that you have to track down deep in log files.

People (including myself) spend time having to figure out why the CI failed, rather than letting it fix any problems it encounters. It adds a failure mode to contributing, when we could eliminate it and have more consistent code as a result!
December 31, 2022

On Saturday, 31 December 2022 at 08:56:34 UTC, Richard (Rikki) Andrew Cattermole wrote:

>

I don't see how it would differ, the format is a new commit as part of the PR.

See: https://mskelton.medium.com/auto-formatting-code-using-prettier-and-github-actions-ed458f58b7df

OK, understood. (It wasn't 100% clear from your previous post that you were envisioning one follow-up patch on top of the PR, as opposed to modifying patches in the PR.)

>

You've got the problem right there. There is no tool to run locally. Its mixed between a few different CI runner types.

Yeah, I see why that would be very painful.

What I'd like to suggest is that, regardless of what one does or doesn't do during CI, the absence of a single tool for checking or fixing style is the crux of the problem. Whatever CI does or doesn't do, it's IMO useful as a developer to be able to check one's own code for style correctness, before submitting in a PR.

So it seems to me that the best way forward here is to make sure that all the wanted style checks can be carried out by a single tool, or at least by a well defined set of tools with standardized configuration.

There are good examples in other languages. I've historically preferred tools that just define what's objectionable rather than what's correct (if that makes sense), so there is still an amount of flexibility for the developer to write code as they wish, but since I discovered the Python tool black, I think it's clear that it's at least possible to craft a deterministic formatting tool that consistently produces good looking code.

What's particularly nice about that tool is that it can be run to edit code in-place, or it can be used in a dry-run mode which outputs a patch showing what would have been changed (with exit code 0 if that's nothing, or 1 if changes are required).

Where CI for my own projects is concerned, I've preferred to use the dry-run mode and throw it back on the PR author to actually make the fix -- on the grounds that the PR author should be in control of what code changes, but also because it's straightforward to follow what changes are wanted, and equally trivial to run the tool locally to make them. But obviously one could use the same tooling to append a style-fix patch to a PR, if that was considered desirable.

>

People (including myself) spend time having to figure out why the CI failed, rather than letting it fix any problems it encounters. It adds a failure mode to contributing, when we could eliminate it and have more consistent code as a result!

I completely agree that we want to eliminate this kind of uncertainty. I just think that to achieve it we need a well-defined tool which can be run locally as easily as in CI.

Python tooling is particularly instructive as a good point of reference, because there are other tools (e.g. tox) which make it very easy to run a range of different checks (style, linter, test suite, ...) in a standardized way, via a single command.

Of course, it's not like people haven't already tried (dfmt etc.). It just seems to be hard to sustain the momentum to implement and maintain such tools for D :-(

I'll mention some of these thoughts in the feedback I plan to write to Mike.

December 31, 2022
On 12/31/2022 12:36 AM, Joseph Rushton Wakeling wrote:
> But my experience has tended to be that when people entirely outsource style-compliance to external tooling, you wind up with a lot of quite ugly code and harder-to-follow patches.

True enough. I adjust the style based on what the particular sequence of code is doing. I doubt "good style" can be mandated. Note that D's style checker has a number of knobs that turn various checks off, and this is used in its checking of the compiler source files.
January 01, 2023
On Saturday, 31 December 2022 at 08:56:34 UTC, Richard (Rikki) Andrew Cattermole wrote:
> You've got the problem right there. There is no tool to run locally. Its mixed between a few different CI runner types. They are all simple tests, like end of line white space and all have less than desirable error messages that you have to track down deep in log files.

You can run the checks locally with `make -f posix.mak style_lint` (Phobos, druntime) or `./build.d style` (DMD).
January 01, 2023

On Saturday, 31 December 2022 at 18:25:38 UTC, Walter Bright wrote:

>

True enough. I adjust the style based on what the particular sequence of code is doing. I doubt "good style" can be mandated. Note that D's style checker has a number of knobs that turn various checks off, and this is used in its checking of the compiler source files.

Clearly we are in sympathy here :-) But I've had to recognize that not everyone agrees, and that people have well-motivated reasons for wanting to try to automate the code style. Typically, they want to be able to put 100% focus on what the program is doing and not have to discuss, debate, or spend time manually tweaking stylistic aspects.

That's caused some friction for me in the past, because I was very unhappy with the automated formatters that seemed to be available. Finding black allowed me to change my mind, because here was a tool that deterministically generated a highly opinionated style (config options are limited), while still producing Python code that read well to my eyes. Of course there are always a few edge cases, but they are very limited.

If you have a spare 35 minutes and are curious, you might find it interesting to watch this talk by the black lead developer, which goes over some of the issues involved:
https://www.youtube.com/watch?v=nnKvBwRt72Q

That, plus trying out the tool, was enough to convince me that with careful enough rule design (implicitly that talk shows how important it is to tailor rules to the particular language syntax), it is possible to design deterministic formatting rules that are good enough probably 95+% of the time -- with the remaining cases either tolerable, or possible to work around with judicious disabling of the formatter for particular code blocks.

(Dicebot told me this years ago, it's just taken this long for me to start believing him:-)

Of course, being possible in principle doesn't necessarily make it easy to do for a particular language. :-( I have a personal hunch that ML-style languages like Python, Go, and Rust lend themselves more naturally to such auto-formatting than Algol-style, but that may be just my lack of experience of good deterministic styling tools for the latter.

January 01, 2023
When it comes to style, people are not going to be happy, no matter what you pick.

You don't need to put too much work into the set of rules due to this.

In our case we have declared what the style should be for the dlang/ repos. So... that's what the tool must do.
January 01, 2023

On Saturday, 24 December 2022 at 13:46:33 UTC, Mike Parker wrote:

>

Everyone in the D community has their own reasons for being here. We each have our own goals and plans, our own likes and dislikes, our own expectations and tolerance levels when those expectations go unmet, and so on.

[...]

Referring back to my post a month ago: https://forum.dlang.org/post/xamclovgxzzrjzntengl@forum.dlang.org

An eidetic memory is not required, this is all stuff that everyone with long-term D experience has seared in to their brains.

January 02, 2023
On Sunday, 1 January 2023 at 09:52:55 UTC, Richard (Rikki) Andrew Cattermole wrote:
> When it comes to style, people are not going to be happy, no matter what you pick.
>
> You don't need to put too much work into the set of rules due to this.
>
> In our case we have declared what the style should be for the dlang/ repos. So... that's what the tool must do.

I've been part of some C++/Python codebases which transitioned to enforced clang-format/black formatting and in the end it was a good decision. Turned out everyone's personal code style isn't so precious after all and with modifying a few rules in the formatter you can adopt a formatting style that is acceptable for majority of folks. Also, every sourcecode formatter allows you to opt-out of auto-formatting for blocks of code, which is useful for manual tables and alignment.

In my personal D projects I have set dfmt to run on each source code file save and never really had to worry about formatting. I just write whatever, ctrl+S and get a nicely formatted D code. I may disagree with the way it formats things sometimes, but I just accept it as a minor tradeoff for convenience.
January 02, 2023

On Saturday, 24 December 2022 at 13:46:33 UTC, Mike Parker wrote:

>

I invite every member of the D community to email me at social@dlang.org with your specific gripes about the current state of D and the things you'd like to see in the future (changes, new features, etc). But don't write in general terms. Be specific.

Okay, sent my list. A noteworthy thing IMO is that I could not think of any one big issue in the language or the standard library itself. I submitted six points of which one of them was about tooling. All of the remainder were some sort of social or policy issues.