Is phobos too fluffy?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Sep 17 20:20:12 UTC 2020


On Thursday, September 17, 2020 11:49:05 AM MDT jmh530 via Digitalmars-d 
wrote:
> On Thursday, 17 September 2020 at 17:16:42 UTC, Andrei
>
> Alexandrescu wrote:
> > [snip]
> >
> > This is exclusively about readability. Too much fluff means too
> > little context in front of you.
>
> When I looked at some of those examples above, I agree that some
> are extraneous (which should get flagged by the autotester)...but
> I almost always put an empty line after imports. I find that
> helps with readability and even maintainability in short
> functions/scopes in that I don't need to add them back after
> adding more lines and have more trouble finding them.

I do the same. Similarly, I usually put blank lines after declarations,
because that makes the code easier to read, but I'm also somewhat flexible
about it, since following strict rules about some of that stuff can
certainly result in way too many blank lines in some code. About the only
time I'll consider not putting a blank line after an import statement is
when the function is otherwise a one-liner, but even then, I'm likely to
prefer having the blank line (which Andrei clearly wouldn't like).

Either way, while I won't claim that Phobos' code always does a good job
with where it has blank lines (and there certainly are plenty of times that
I haven't like code formatting in Phobos), I haven't personally found that
the number of blank lines in Phobos causes problems with being able to see
code on a screen even on my laptop, and in my experience, trying to minimize
blank lines often makes code harder to read. It's a very subjective thing
though and is going to vary from person to person. Using a code formatter
would make it so that you don't have to argue about it in PRs, but it also
tends to result in uglier code. Personally, I'd prefer that we just not be
picky about it, but if we're going to be, then ultimately, using a code
formatter is probably the way to go.

That being said, unless the code formatter is smart enough to deal with very
small functions differently, removing blank lines after something like
import statements in order to reduce the number of blank lines in small
functions will definitely make longer functions harder to read - especially
when we're doing a lot with local import statements. You can get quite a
list of those in a row, in which case, I think that it's pretty bad not have
to have a blank line after it. I don't know how smart any code formatting
tools we currently have at our disposal are though, since I generally avoid
them.

- Jonathan M Davis





More information about the Digitalmars-d mailing list