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?


Sam <lightaiyee at gmail.com> writes:

> Some have advised me to use Haskell instead because Python is not a
> good language for FP.

There are some features of functional programming which are not a good
fit with Python. By attempting to learn functional programming in
Python, you will necessarily compromise your Python code *and* your
understanding of functional programming.

> I am sort of confused at the moment. Is Python a dysfunctional
> programming language to apply FP? Can the more experienced Python
> users advise?

I think if you want to learn functional programming you should have a
good reason for doing so, and you should learn something like Common
Lisp or Scheme or another purely-functional language.

You will definitely learn a lot about programming that you didn't know
before, and be able to think about problems with an expanded mental
toolkit.

Similarly, I encourage anyone working with databases to learn correct
relational database techniques ? even though SQL is a deeply-flawed and
rather incomplete tool for working with relational databases,
nevertheless learning relational theory gives one an expanded mental
toolkit for thinking about database design and access when working in
SQL.

Much of the functional programming toolkit will apply to your Python
programming, but you will need to be aware of what tru functional
programming is, and then bring that toolkit back to Python.

-- 
 \         ?If nature has made any one thing less susceptible than all |
  `\    others of exclusive property, it is the action of the thinking |
_o__)                          power called an idea? ?Thomas Jefferson |
Ben Finney