March 15, 2011
Few months ago I have said that "pure" in D2 is a quite big thing, it's very useful. Recently I have found a blog post about functional Vs object oriented coding. This blog post is not so important, but it has given me a little push to understand something:

I have a bit of experience of D2 programming, and I am seeing functional&immutable programming in Haskell. In Haskell the immutability gives both some advantages, but sometimes it also asks for a complex way of coding that uses monads, etc. Among the advantages of the purity in Haskell there is the ability of the Haskell compiler to perform a good number of refined transformations and optimizations on the code that usually can't be done by C compilers on C code.

As Andrei has realized, strong purity in D2 allows for a style of programming that gives some of the advantages of both functional programming and procedural/OO programming. D2 strongly pure functions are allowed to perform impure actions inside them, this helps avoid some of the complexities (that I see as workarounds for the immutability) I see in Haskell programming, but in theory may allow to keep some of advantages of the purity of Haskell.

In my opinion this allows a D2 programming style that's different from both functional programming and imperative/structured programming.

To fully allow this programming style and the advantages it may bring, I think D2 has to:
1) Implement its strong purity well. This means:
  1a) removing the bugs of pure, implementing few extra niceties (like dependant purity, disallowing code that doesn't assign the result of a pure function to a variable, etc, all this is already present in Bugzilla);
  1b) try to remove some of the broken corner cases of the "pure" D2 implementation, like ones I have recently discussed on this newsgroup with Steven Schveighoffer.
2) Try to add the pure-related compilation transformations/optimizations done by a compiler like the Haskell one. Instead of being pure all the way down and allowing those optimizations on every little bit of code as in Haskell, D2 may allow to perform those optimizations on bigger lumps of code that are observationally pure. This is an open ground for D2 compilers, and probably can't be done much until the pure is implemented well.