On 05/02/2017 5:02 PM, thedeemon wrote:
snip
It may look so from a distance. But in my experience it's not that bad.
In most software I did in D it did not matter really (it's either 64-bit
or short lived programs) and the control D gives to choose how to deal
with everything makes it all quite manageable, I can decide what to take
from both worlds and hence pick the best, not the worst.
The best of both worlds can be done quite simply.
Instead of a chain of input ranges like:
int[] data = input.filter!"a != 7".map!"a * 2".array;
Use:
int[] data;
data.length = input.length;
size_t i;
foreach(v; input.filter!"a != 7".map!"a * 2") {
data[i] = v;
i++;
}
data.length = i;
Of course this is dirt simple example, but instead look at it for e.g. a
csv parser with some complex data structure creation + manipulation.
I have some real world code here[0] that uses it. Not only is there less
allocations and uses the GC but also it ends up being significantly faster!
[0]
https://gist.github.com/rikkimax/42c3dfa6500155c5e441cbb1437142ea#file-reports-d-L124