Functional Programming in D

Bienlein ffm2002 at web.de
Thu Oct 10 14:47:22 UTC 2019


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.

I did programming in Smalltalk for about 10 years. Smalltalk has 
all those things that are now called "functional-style 
programming" or even IMHO incorrectly "functional programming" 
that are about applying operations on collections. In Smalltalk 
these functions (like collect, map, reject, detect, inject, etc.) 
are simply called "collection iterators". They already exist in 
Smalltalk-80, which is called that way, because it was published 
in 1980. To verify this you can download the Smalltalk-80 "blue 
book" from here and do a text search on these function names: 
http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook.pdf

In those 10 years where I did Smalltalk development I met no one 
who called making use of those collection iterators functional 
programming. There are several books about Smalltalk who have 
some importance in CS, because Smalltalk was the first truly 
useable OO language afer Simula. I don't think the term 
functional programming is ever used there.

Calling collection iterators functional programming opened 
Pandoras box of mixing up things. I fear it is too late to 
explain to people that functional progeramming is what is done in 
Haskel and Lisp and related languages and nothing else.

Collection iterators carry some aspects of functional programming 
such as non-destructive programming as the result of applying a 
function on a call returns a new collection leaving the original 
collection unchanged, but that alone is not enogh for things to 
be called functional programming. It is merely simply making use 
of closures.




More information about the Digitalmars-d-learn mailing list