I always stay out of these types of posts because they quite often
degenerate into flames, but cannot help myself this time because I can
see both view points and has made me question my views on what I
understand functional programming to be.
I think all the points that Edward raises are fair and technically
correct. However I am not sure how Conrad's answer is wrong when he
acknowledges this and explains that writing a book is about trade
offs.
I think really the issue here is about pragmatism.
- global variables can be modified and shadowed which technically
means this is bad from a functional point of view. However, Conrad
doesn't do these things so his functions are functional in the context
of the program.
Would you write this code if you were working in a team and hoped your
colleagues were disciplined enough to follow the same practices as
you? - probably not.
If you were the only one coding for fun or profit would you? Quite
possibly.
I have read many books on programming now and very few of them
actually get you excited enough to want to program and get you
programming real world interesting things quickly. Conrad's book does
but it already weighs in at 500 pages or so. As he said writing a book
is a balancing act. I am sure he could add more material to address
your concerns but I am not sure the book would flow the same. It
currently hits the balance between giving you the right amount of
boring theory before getting on with the fun stuff.
The book spends a little over 100 pages covering functional
programming. I doubt anyone is going to finish the book believing to
be an expert functional programmer. If it interests them they have
several books more reading to do before they will have a good solid
understanding of functional programming, and along the way they will
become more than aware of all the issues you raise.
I think also languages like Haskell force a functional programming
style but there is a reason why lisp is called the programmable
programming language. Lisp can be object orientated, procedural,
imperative and functional. You can bet it will be able to adapt to the
next craze that comes along, otherwise it wouldn't have had such an
impressive longevity. However this means that writing in a certain
style in lisp requires more discipline, because you don't have to.
I think that Conrad explains pretty succinctly what functional
programs need to do on page 293. At the end of the day we can use
language that enforce certain rules to make us behave in a certain way
or we can use something like lisp which allows us to do what we want.
However, the latter requires a greater understanding of what we are
doing and more discipline when we are programming. I think this is
what the cartoon on functional programming in the book tries to
highlight.