Learning Haskell makes you a better programmer?

Russel Winder russel at winder.org.uk
Fri Dec 28 04:46:38 PST 2012


On Fri, 2012-12-28 at 09:13 +0100, Red wrote:
> Why is immutable data considered necessary for functional 
> programming style? Can't a a programmer or programmer just do the 
> same thing with mutable data, but not mutate it? That is, 
> couldn't Python be used for functional programming?

Because immutable state is a concept entirely missing from functional
languages: functional languages have no tools for handling mutable
state. OK Haskell has introduced arrays and indexing but it remains a
dark corner for most use cases.

Yes, but… if a language provide features you would be writing in a
non-idiomatic way to simply ignore those features. The issue here is
that a language will embody a computational model and an idiomatic mode
of expression of algorithms. A language should always be used in as
idiomatic way as possible. To use an imperative language in a purely
functional way will lead to poor code. Conversely all use of mutable
shared state is a code smell that should lead to a refactoring.

Python cannot be used for functional programming in the purist sense due
to lack of single assignment, presence of for and while loops, and lack
of tail recursion optimization. However with higher order functional,
list, set and dictionary comprehensions, many of the techniques and
idioms of functional programming can, indeed should, be used when
programming in Python.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121228/49688a8b/attachment.pgp>


More information about the Digitalmars-d mailing list