osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can one use Python to learn and even apply Functional Programming?


On Sunday, February 16, 2014 10:15:58 AM UTC+5:30, Sam wrote:
> I would like to learn and try out functional programming (FP). I love Python and would like to use it to try FP. Some have advised me to use Haskell instead because Python is not a good language for FP. I am sort of confused at the moment. Is Python a dysfunctional programming language to apply FP? Can the more experienced Python users advise?

For many years I taught programming in which a pure functional language was the
'mother-tongue' and was followed by a multi-paradigm language.
In the 90s the pair was Miranda + Scheme; after 2001 it was
a haskell (wee-subset) + python.

Two of the bedrock items for a FP education is 
1. Getting Hindley-Milner* 
2. Lambda Calculus

1 python does not have at all and 2 is ok but not great.

Once Hindley-Milner is in your bones -- yeah its radioactive and harmless --
you can happily think in pseudo-Haskell and code in(to) python (or C++ or 
whatever)

The syllabus I made and used (well kindof :-) )
http://www.the-magus.in/Publications/ip.pdf

I must say I am not personally too happy with haskell's direction today -- its
'progress' looks quite like how C++ 'progresses' C.
[Yeah this does not amount to a very helpful direction :-( ]

In more abstract, here is a blog-post of mine
http://blog.languager.org/2012/10/functional-programming-lost-booty.html
which lists out (in very brief) concepts/features that originated from
FP and would benefit programmers irrespective of language/paradigm/technology
they are currently into.