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

S

Sam

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?
 
D

Devin Jeanpierre

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 Haskellinstead 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?

Everything about FP that can be done in, say, Scheme, can be done in
Python, with the exception of tail recursion (but that isn't important
for "real" FP). But Scheme is old, and people keep thinking of new
things and more interesting variations on the lambda calculus.

Haskell is kind of the core of modern functional programming, and
involves heavy use of concepts that do not exist or are visibly alien
in Python. If you want to learn FP properly, you should learn Haskell.
Otherwise you will likely be confused when you overhear functional
programmers talking, whether it's about Hindley-Milner or sum types or
eta conversion.

-- Devin
 
C

Chris Angelico

Otherwise you will likely be confused when you overhear functional
programmers talking, whether it's about Hindley-Milner or sum types or
eta conversion.

ETA conversion? I know what that is. That's when a programmer says
something'll take six months, and the marketing guys start selling it
for delivery in three.

*dives for cover*

ChrisA
 
T

Terry Reedy

Everything about FP that can be done in, say, Scheme, can be done in
Python, with the exception of tail recursion (but that isn't important

You can do tail recursion in Python, but it will not be noticed and
optimized in the way it is is some functional languages.
for "real" FP). But Scheme is old, and people keep thinking of new
things and more interesting variations on the lambda calculus.

Haskell is kind of the core of modern functional programming, and
involves heavy use of concepts that do not exist or are visibly alien
in Python. If you want to learn FP properly, you should learn Haskell.
Otherwise you will likely be confused when you overhear functional
programmers talking, whether it's about Hindley-Milner or sum types or
eta conversion.

In some ways, Haskell is more different from Python than Scheme is, so
it may stretch your brain more.
 
C

Chris Angelico

What did, using google groups? :)

"Well! I've often seen context without a grin," thought Alice; "but a grin
without context! It's the most curious thing I ever saw in my life!"

ChrisA
 
R

Rustom Mody

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 Haskellinstead 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 wasthe
'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.
 
N

Neil Cerutti

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?

I recommend Scheme to learn functional programming style.

There's a short scheme tutorial that was entered in the
Interactive Fiction competition in 1998 or so. You can play it
online here, and try out functional programming on a scheme
interepreter implemented in Inform and running on a Z-machine
interpreter written in javascript. It was *my* first introduction
to functional programming.

http://www.eblong.com/zarf/if.html#lists

I purchased and really enjoyed Simply Scheme as a followup to
that mind-bending experience.

http://www.eecs.berkeley.edu/~bh/ss-toc2.html

I wouldn't recommend trying to learn anything at the same time as
learning Haskell. ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top