Simple performance question from a newcomer
dextorious via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Feb 22 07:55:35 PST 2016
On Sunday, 21 February 2016 at 16:20:30 UTC, bachmeier wrote:
> First, a minor point, the D community is usually pretty careful
> not to frown on a particular coding style (unlike some
> communities) so if you are comfortable writing loops and it
> gives you the fastest code, you should do so.
>
> On the performance issue, you can see this related post about
> performance with reduce:
> http://forum.dlang.org/post/mailman.4829.1434623275.7663.digitalmars-d@puremagic.com
>
> This was Walter's response:
> http://forum.dlang.org/post/mlvb40$1tdf$1@digitalmars.com
>
> And this shows that LDC flat out does a better job of
> optimization in this case:
> http://forum.dlang.org/post/mailman.4899.1434779705.7663.digitalmars-d@puremagic.com
While I certainly do not doubt the open mindedness of the D
community, it was in part Walter Bright's statement during a
keynote speech of how "loops are bugs" that motivated me to look
at D for a fresh approach to writing numerical code. For decades,
explicit loops have been the only way to attain good performance
for certain kinds of code in virtually all languages (discounting
a few quirky high level languages like MATLAB) and the notion
that this need not be the case is quite attractive to many
people, myself included.
While the point Walter makes, that there is no mathematical
reason ranges should be slower than loops and that loops are
generally easier to get wrong is certainly true, D is the first
general purpose language I've ever seen that makes this sentiment
come close to reality.
More information about the Digitalmars-d-learn
mailing list