On Thursday, 10 October 2019 at 10:08:14 UTC, H. S. Teoh wrote:
On Thu, Oct 10, 2019 at 09:59:49AM +0100, Russel Winder via
Digitalmars-d-learn wrote:
On Wed, 2019-10-09 at 11:12 -0700, H. S. Teoh via
Digitalmars-d-learn wrote: […]
> Actually, std.functional is somewhat of a misnomer. It
> mostly deals with higher-order functions, i.e., functions
> that return functions, currying, that sort of thing. These
> are part of functional programming, but there's more to
> functional programming than that. I'd say std.range and
> std.algorithm are another major part of functional-style
> programming support in D, along with the purity system.
[…]
I feel that it is best to leave functional programming to
functional programming language, e.g. Haskell, Scheme, etc.
rather than try to do functional programming in imperative
languages, e.g. Java, C++, Rust, D.
[...]
Note this is why I wrote "functional-style programming" w.r.t.
D, rather than "functional programming". Clearly, what D has
isn't "real" functional programming in the strict sense, but it
does share similar characteristics when written in that style.
T
An even better phrase is simply "good programming practice".
Avoiding global mutable state, writing pure functions, passing
around functions as arguments, and letting the language handle
iteration rather than using for loops and related outdated
constructs is good practice. You might need to make exceptions
for performance reasons, but then you're in the realm of hacks
rather than practices.