Knowing the approach to solve a D challenge
Dukc
ajieskola at gmail.com
Fri Feb 16 13:19:30 UTC 2018
On Friday, 16 February 2018 at 09:44:27 UTC, aberba wrote:
> 1. Do you first write it in idiomatic D style or a more general
> approach before porting to idiomatic D?
In micro-level, it's usually fairly idiomatic from get-go.
Usually no heap allocations at inner loops, for-looping, static
variables etc. Sometimes if I get a bit desperate of frustated I
might do this a bit.
But at larger level, I often find myself shifting work between
functions, structs, modules and so. In other words, redesigning.
> 2. Do you find yourself mostly rolling out your own
> implementation first before using a library function?
No, the vast majority of my calls are from Phobos or other
libraries I use. And in case of Phobos at least, it's stuff is so
general that I don't need to design my own function often. An
exception is std.algorithm.each, but just to get better error
messages (template constraints don't tell why the call did not
work).
> 3. Do the use of generics come out of first try or a rewrite?
Rewriting a lot, but that's the case with all coding. With
generics, i often tend to forget ! before an alias parameter.
> 4. What rough percentage of phobos knowledge is required for
> reasonable good problem solving efficiency?
If we talk about experience of the language in general, it's more
than with C-style programming, Java or C# but less than with C++
generics. I don't think you have to know Phobos throughout, but
you have to know the language and understand the philosophy of
ranges quite deeply.
Percentages aren't important, I think that as long as you know
the general purpose of std.algorithm, std.range, std.stdio,
std.conv and std.array that gets you started. Again, if you know
the language and understand the range concept.
More information about the Digitalmars-d
mailing list