Is D a cult?
James Iry
jamesiry at gmail.com
Wed Mar 10 08:09:29 PST 2010
I'm going to assume you meant "enforce" rather than "support" because both languages support immutability and purity precisely to the extent that the programmers want to use them (although, of the two, Scala's standard library has far more support).
But even if you mean "enforce", you've still got a strange point of view.
Common Lisp and Scheme do not enforce purity or immutability. In fact, in both languages, ALL data structures are mutable whether you want them to be or not. Yet the Scheme crowd in particular is deeply aware of the downsides of side effects.
SML and OCaml do not enforce purity or immutability except in a shallow sense that unlike (most) Lisps you can write data structures which are immutable. Scala sits firmly in that same camp. For instance, like SML, the Scala standard library List type is immutable (and persistent - meaning some operations, like prepend and tail, share structure with previous versions).
To insist that functional programming must be done in a language that enforces purity is to say that nobody ever did functional programming in a Lisp or ML derived language. That's historically false and many of the core concepts found in Haskell (1999) and Miranda (1985) were clearly already worked out in ML(1973) and LISP(1958). It also ignores the fact that the current Scheme, OCaml, and, yes, Scala communities work hard to create and use high performance immutable, persistent data structures.
What the purely functional languages really have brought to the table is a) clean ways to separate IO using things like linear types (Clean), monads(Haskell), or effect systems(Disciple) and b) a deep awareness of the power of laziness that can be found, to some extent, in the impure functional languages but which is pervasive in the pure lazy ones.
Also, GHC Haskell, the current reigning king of purity includes "unsafePerformIO" precisely because there is such a thing as too much purity. Besides doing traditional IO it allows the programmer to mutate shared variables and do other, nasty, imperative things.
Walter Bright Wrote:
> retard wrote:
> > It's perfectly clear to me that no matter what you do, D won't become a
> > functional language because the core runs on an imperative Turing
> > machine. But the functional constructs can help building more readable
> > and reliable code. That's why C# and Scala got those features..
>
> I'll reply to your other points later, but this one bothers me. Neither
> C# nor Scala support pure functions or immutable data structures, which
> are fundamental to FP. I don't see how they can be considered as
> supporting functional programming.
>
> http://en.wikipedia.org/wiki/Scala_(programming_language)#Functional_programming
>
> http://www.25hoursaday.com/weblog/CommentView.aspx?guid=3D5755BF-43CF-4D47-A7EC-B60F6B536702
More information about the Digitalmars-d
mailing list