Send me your list of D gripes and wishes
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Sun Jan 1 08:53:58 UTC 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.
More information about the Digitalmars-d
mailing list