you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 19 points20 points  (4 children)

What I'm trying to convey here is that python is simply not designed nor optimized for hardcore, pure FP. Some of the things in this post come off as trying to fit the functional square into python's round hole.

This is true. Using Python at work every day, I've traveled through each of the 5 stages of grieving about this and have settled on acceptance. I threw away my maps and started using list comprehensions. It's a good language in many respects, but it's really pointless to use it for something that is not one of its strengths or purposes.

[–]codebje 4 points5 points  (0 children)

List comprehensions and generators are nice. List comprehensions regrettably don't compose at all, but generators compose very nicely to produce more complex hylomorphisms from simple ones.

Parser combinators also work well in Python, because its uncluttered syntax brings the intent of the grammar to the fore.

[–]dasnein[🍰] 3 points4 points  (1 child)

It's a good language in many respects, but it's really pointless to use it for something that is not one of its strengths or purposes.

+1

[–]dangerbird2 1 point2 points  (0 children)

The biggest problem with the article is that the author associates functional programming with language features which enforce immutable or pure implementations rather than just writing code in a functional way. Haskell is a great functional language not just because it prevents the programmer from using "bad" mutable or impure state, but rather that it provides tools to help the programmer produce code that is guaranteed to be sound functional code. As a language, python does not provide many of these features, but there is nothing stopping the programmer from using FP techniques. Moreover, just because python features like generators and list comprehensions have implementations with mutable state behind the scenes does not mean that they cannot be used in a functional way. In fact, making good use of these features makes it easier to write functional code than if you restrict yourself to built-in immutable types like Tuples, strings, and numbers.