Lower than C?
Walter Bright
newshound1 at digitalmars.com
Thu Dec 6 14:13:41 PST 2007
Jesse Phillips wrote:
> To me D already has a lot of syntax to help the compiler make good
> optimization decisions, I don't know if it really fully optimizes yet
> either. The fact that it is moving towards pure functions seems to be
> good for multi-core.
High level language features are usually good for productivity. They can
be good for optimization in that they give the compiler flexibility in
how to implement a particular goal. An example of this is the foreach
loops, where the compiler can decide whether to use indexing or pointers
(the tradeoffs are CPU specific).
But some high level constructs can be bad for optimization, like dynamic
typing. Dynamic typing means the code has to test, at runtime, the type
of each operation and do the right thing according to the type. This
kind of thing is why dynamically typed languages run 100x slower than
statically typed ones.
Fortunately, since I've built optimizers, I think I'm in a good position
to be able to tell if a high level construct is helpful or a hindrance
to optimization.
More information about the Digitalmars-d
mailing list