I don't write much D code, but here are my answers for _any_
language.
On Friday, 16 February 2018 at 09:44:27 UTC, aberba wrote:
D has tone of features and library solutions. When you
encounter a problem, how do you approach solving it in code?
1. Do you first write it in idiomatic D style or a more general
approach before porting to idiomatic D?
The style in my head, which sometimes is D function chains, for
example, this chain I put in Phobos:
https://github.com/dlang/phobos/blob/master/std/datetime/timezone.d#L2501
Compare it to the previously-written non-Android version just
below, which could probably be written as such a chain but might
be too unwieldy if done that way.
2. Do you find yourself mostly rolling out your own
implementation first before using a library function?
Look for a library function, and if nothing works, write your own.
3. Do the use of generics come out of first try or a rewrite?
I don't really need them for my own functions, so can't say.
4. What rough percentage of phobos knowledge is required for
reasonable good problem solving efficiency?
Just hunt for something when you need it. Knowing Phobos well is
like indexing your data beforehand, you'll find something much
quicker.
The reason D supports so many styles is so you don't have to
force yourself to use only one style. The D idioms are there if
you need them though, and you may find using them gives you
better code.