-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Functional Programming Patterns #244
Comments
I'm a big fan of fp but although you can do it in Python, it is not always considered idiomatic. It's not a bad idea but I'm not sure if it's good to put it in this repo. I'd like to hear some thoughts from the rest of the community. |
As far as I know/learned until now some functional programming in Python is very pythonic. However these kind of patterns are more idioms than higher level patterns and not really suitable for the repo (due to low level). |
+1 for functional patterns here. @fkromer had you something particular in mind? I'll start proposing "pipeline" candidate |
I had the patterns addressed in S. Lott's "Functional Python Programming" in mind. In case you want to look into the book pay attention before doing so: There is a section about patterns and some references in the index but the majority of examples is spread over the whole book. It makes sense to depend on some Python package(s) which implement boilerplate required to implement the actual patterns. As @faif already said: I am not sure if it's a good idea to put this into here. Recently I started a small project called 30 seconds of functional python programming. Right now it's a collection of Python package API examples running in an interactive Python environment on Binder. Python packages for functional programming have been hardly addresses in the books I've looked into so far. The packages provide lowest level building blocks to adapt a FP style beyond what you can do with Pythons builtin and standard lib stuff. I think it's way more effective to learn new programming language features via exploratory experimentation. I've not pushed everything I've prepared so far but I will do so that you get a better understanding of what the project is aiming for. E.g. I'd like to port the JavaScript examples from Functional Programming Jargon to Python as well. And it would be reasonable to put pattern examples/implementations into specific Python package specific sections as well. Feel free to contribute there as well. |
Another higher level candidate: Parallel Functional Pipeline Pattern |
Perhaps this repo would be a better place to centralize functional programming pattens and concepts in Python. |
In my opinion, Python is not a good language for FP (many use cases are not covered), although it has some of the ideas of FP. [From this page: https://intellipaat.com/community/12542/why-isnt-python-very-good-for-functional-programming]
|
A project accepts PRs on functional programming patterns would depend on the project's goals and the maintainers' preferences. If the project's focus is on object-oriented programming, the maintainers may not be interested in adding functional programming patterns or restructuring the project in that way. However, if the maintainers are open to adding functional programming patterns, restructuring the project may make sense, and PRs related to functional programming could be considered. Ultimately, the best course of action would be to reach out to the maintainers and ask for their thoughts on the matter. |
I believe that functional programming idioms in any language are good, as long as they are not implemented in an obscure way. Especially the fundamentals such as immutability and pure functions can be very beneficial to Python programmers. So if people are willing to showcase them here, maybe it's a good idea to include them. |
Would you accept PRs about functional programming patterns @faif ? Would probably imply some project restructuring (e.g. putting dirs "behavioral" and "structural" into "oop").
The text was updated successfully, but these errors were encountered: