Is phobos too fluffy?

Arun aruncxy at gmail.com
Thu Sep 17 19:42:05 UTC 2020


On Thursday, 17 September 2020 at 15:51:18 UTC, Andrei 
Alexandrescu wrote:
> As wc -l counts, phobos has some 330 KLOC:
>
> $ wc -l $(git ls-files '*.d') | tail -1
>   331378 total
>
> I noticed many contributors are fond of inserting empty lines 
> discretionarily, sometimes even in the middle of 2-5 line 
> functions, or right after opening an "if" statement. The total 
> number of empty lines:
>
> $ git grep '^$' $(git ls-files '*.d') | wc -l
>    38503
>
> So Phobos has 11.62% empty lines in it, on average one on every 
> 9 lines of code. I find that a bit excessive, particularly 
> given that our coding convention uses brace-on-its-own line, 
> which already adds a lot of vertical space. Here's the number 
> of lines consisting of only one brace:
>
> git grep '^ *[{}] *$' **/*.d | wc -l
>    53126
>
> That's 16% of the total. Combined with empty lines, we're 
> looking at a 27.65% fluff factor. Isn't that quite a bit, even 
> considering that documentation requires empty lines for 
> paragraphs etc?
>
> Today's monitors favor width over height and I didn't yet get 
> to the point of rotating my monitor for coding purposes. (It's 
> also curved, which would make it awkward.) Would it be 
> reasonable to curb a bit on the fluff factor? E.g. there should 
> never be two consecutive empty lines, and code blocks shorter 
> than x lines should have no newlines inside.

Good that someone from the core team pays attention to these 
things. We should encourage the use of dfmt for such things, come 
up with a standard .editorconfig and commit that to the repo. 
Vim, emacs, VSCode - pretty much the majority of the editors 
support dfmt + .editorconfig. The more dogfooding, the better it 
is. That's not happening at the moment.

druntime uses different style from Phobos as well.

I wish all the community projects use a common D-style (even the 
one recommended officially). But I understand where that 
discussion will lead to.


More information about the Digitalmars-d mailing list