October 02, 2013 Re: Learning D - first steps and best practices | ||||
---|---|---|---|---|
| ||||
Posted in reply to qznc | On Wednesday, October 02, 2013 10:38:10 qznc wrote: > On Wednesday, 2 October 2013 at 03:28:59 UTC, Jonathan M Davis > > wrote: > > On Wednesday, October 02, 2013 03:19:19 Jesse Phillips wrote: > >> 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. > > My vision: Jonathan checks out Jesses code to fix a bug. On opening the file his editor automatically reformats to braces-on-own-line. When committing the fix, a pre-commit hook reformats to the project-specific style braces-on-same-line. Everybody is happy. :) Personally, I don't think that that's particularly realistic, but it's far from the first time that someone has suggested that sort of thing. And giving the inherent flaws in code formatters, I think that this sort of thing is doomed to failure. > Of course, there are edge cases, where automatic formatting should be broken. However, I think we should let them be and adapt. I also add code sometimes, just to remove a compiler warning like "unused argument". Likewise, I am fine with minor noise in exchange for consistent styling like described above. Whereas I care way more about being able to format code the way I want than I do about consistent styling. But code formatting is arguably very much a flamebait topic. - Jonathan M Davis |
October 02, 2013 Re: Learning D - first steps and best practices | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | On Wednesday, 2 October 2013 at 01:19:21 UTC, Jesse Phillips wrote:
> For me, if the program didn't format brackets on the same line I wouldn't use it.
I'm guessing you don't use druntime or phobos then :p
|
October 18, 2013 Re: Learning D - first steps and best practices | ||||
---|---|---|---|---|
| ||||
Posted in reply to qznc | On 2013-10-01 19:32:05 +0000, qznc said:
> 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.
You could also store the code not as text but as a datastructure like a parse tree. Then the editing environment is free to handle this information the way it wants...
|
October 18, 2013 Re: Learning D - first steps and best practices | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Larsson | On Sunday, 29 September 2013 at 07:13:26 UTC, Stefan Larsson wrote: > Hello, > > I have started my journey to learn D after using C/C++ and Python for many years. I am studying the book "The D-Programming Language" by Andrei Alexandrescu and I have tried to search the D-newsgroups for proper advice without success and I am humbly seeking enlightenment in the following topics... When i first started using D i found the two biggest barriers to entry were UFCS and D's Template syntax. Luckily i've covered both on my blog to give newcomers a quick leg up. Andrei's book is great and very thorough but without the two points above being explained fully the first half can be confusing. http://nomad.so/2013/07/templates-in-d-explained/ http://nomad.so/2013/08/alternative-function-syntax-in-d/ These are explained later in the book but examples use them long before they are covered. |
Copyright © 1999-2021 by the D Language Foundation