finalpatch:

I really like the features offered by D but it's the raw performance that's worrying me.

From my experience if you know what you are doing, you are able to write that kind of numerical D code that LDC compiles with a performance very close to C++, and sometimes higher. But you need to be careful about some things.

Don't do this:
foreach (y; (iota(height)))

Use this, because those abstractions are not for free:
foreach (y;  0 .. height)

Be careful with foreach on arrays of structs, because it perform copies that are slow if the structs aren't very small.

Be careful with classes, because on default their methods are virtual. Sometimes in D you want to use structs for performance reasons.

Sometimes in inner loops it's better to use a classic for instead of a foreach.

LDC needs far more flags to compile a raytracer well. LDC even support link time optimization, but you need even more obscure flags.

Also the ending brace of classes and structs doesn't need a semicolon in D.

Bye,
bearophile

Reply via email to