Manu:

Assuming a comparison to C++, you know perfectly well that D has a severe disadvantage. Unless people micro-manage final (I've never seen anyone do this to date), then classes will have significantly inferior performance to C++.

Despite D has the two purities (currently they are three), const/immutable, and will hopefully have scope for function arguments, lot of D programmers will not add those annotations to D code (the D code I see in D.learn usually doesn't have those annotations), so the speed gains of D could be more theoretical than real.

So const/immutable/static/scope/@safe should be the default for a modern language, for efficiency, safety, code understandability and testing.

If you are a new D programmers, and the local variables in your function (including foreach loop variables) are immutable, you learn very quickly to add "mut" or "var" when you want to mutate them. And you will add that annotation only to the variables that you need to mutate. This avoids mutating variables by mistake, and mutating just copies by mistake as in a foreach on an array of structs. So this avoids some bugs.

Bye,
bearophile

Reply via email to