Which is a more functional programming language, Haskell or Python?


Question

Had learned Haskell during a Functional Programming course in school. Had found Haskell a bit difficult to work with. Have now worked a lot on Python. Python is quite easy to work with.

Python does support some functional programming constructs.

Was thinking of revisiting Functional Programming. What would be a better language to code? Haskell or Python? Why?

1
5
12/22/2009 11:09:14 AM

Accepted Answer

You'll find many criticisms elsewhere about how Python programmers should not use functional features like lambda. Alex Martelli is particularly good at this. But if you approach functional programming as a Python programmer, you will not get much of a feel for why people are interested in functional programming in the first place. In particular, you will not have access to a powerful static type system and algebraic data types. These tools are definitely part of the Haskell mindset.

Functional programming is not so much a set of features a a way of thinking. To see that way of thinking in action and to start to learn it, check out the paper Why Functional Programming Matters by John Hughes. What you learn from Hughes you can easily apply in Haskell. In fact, Haskell is much more likely to force you to learn that new way of thinking. With Python you can use a few lambdas here and there and fool yourself that you're learning functional programming. You won't be.

That said, Haskell can be a lot to swallow all at once. If you're finding it difficult you might want to try Standard ML or Racket (formerly called PLT Scheme or DrScheme). Standard ML will introduce you to more new ideas, but those people don't have their act together to welcome newcomers in the way that the Racketeers or the Haskell people do.

33
7/22/2012 6:50:17 PM

Haskell is a functional programming language, whereas Python just has some features of functional programming languages. So, this is settled. Q.e.d.

Edit: What is lacking in Python, just to give one example, is the optimization of recursive function calls. This is vital in most real functional programming languages.

Googling, by the way, just produced this nice article.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon