Is phobos too fluffy?

Paul Backus snarwin at gmail.com
Sun Sep 20 15:04:35 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?

Just for fun, I decided to run these calculations on sumtype, 
which uses my own personal formatting style:

Lines: 2389 total
Blank: 435 (18%)
Brace: 133 (6%)
Fluff factor: 24%

I'm clearly a lot less shy about using blank lines in my code 
than the average Phobos contributor, but I don't put opening 
braces on their own lines, so I end up with about the same level 
of fluff overall.

I wonder if this is a coincidence, or if "readable" code in 
curly-brace languages naturally converges to around 25% fluff? 
Further research is needed.


More information about the Digitalmars-d mailing list