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?
Like always, it depends. Do I attribute up all my functions with
const/@safe/nothrow... (is that even idiomatic) no. Do I build a
range to process some data... sometimes. Do I utilize
std.algorithm/std.range functions to process my data... when
available.
Even my C# code tends to be more idiomatic D than others.
2. Do you find yourself mostly rolling out your own
implementation first before using a library function?
I don't know. If a rolled my own I probably don't know of the
library function/function combination that does the same thing.
3. Do the use of generics come out of first try or a rewrite?
Usually not. If I don't have another use-case I probably don't
know what needs
to be generic.
4. What rough percentage of phobos knowledge is required for
reasonable good problem solving efficiency?
I would guess average. The reason I say this because unlike
popular languages search doesn't always provide a good example
for every question so you kind of need to already know what
you're looking for. It doesn't help that sometimes the answer is
a combination of this (.reduce!max that isn't found in std.math)