Learning D - first steps and best practices

Jonathan M Davis jmdavisProg at gmx.com
Tue Oct 1 20:28:47 PDT 2013


On Wednesday, October 02, 2013 03:19:19 Jesse Phillips wrote:
> On Tuesday, 1 October 2013 at 19:32:08 UTC, qznc wrote:
> > On Sunday, 29 September 2013 at 07:49:21 UTC, Jonathan M Davis
> > 
> > wrote:
> >> I confess that I don't understand why so many people are
> >> fixated on having a
> >> standard style, particularly when it's very, very clear that
> >> most everyone
> >> disagrees on what counts as good style. What little we have in
> >> terms of official
> >> style guidlelines for D can be found here:
> >> http//:dlang.org/dstyle.html
> > 
> > I think nowadays programmers expect their language to come with
> > more opinion and best practices. In contrast, the C++ world is
> > too fragmented for consistent advice.
> > 
> > I believe, the best solution would be to include an
> > auto-formatter (like go fmt), so people can simply reformat the
> > code before and after editing.
> 
> That may be, but we are not working with C++, python, Go, etc
> programmers. We are dealing with D programmers, and they can't
> agree on formatting. There are also many cases which require
> breaking rules for readability.

Yeah. Even if you like the rules that a formatting tool uses, it's never smart 
enough. Inevitably, you have to break the rules in some places to make the 
code appropriately legible. In some respects, formatting is more of an art 
than a science, and automatic formatters of course treat it as if it worked to 
have strict rules with no exceptions, and it doesn't, not if you want your 
code to look good.

> For me, if the program didn't format brackets on the same line I
> wouldn't use it. If you start making things configurable, may as
> well improve indent's support for D.

Whereas I'd hate to have to write code that didn't have braces on their own 
line. It's far better for us both to be able to write code the way that we 
want than try and force standard formatting rules of some kind. IMHO, they add 
little to no value and definitely make coding less enjoyable.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list