2 ms·
Would suggest adding "In Python" to the title. It's actually a bit amusing to see The Standard Reasons given for the desirability of functional programming whe
by jerf 15y ago
Would suggest adding "In Python" to the title.
It's actually a bit amusing to see The Standard Reasons given for the desirability of functional programming when they really don't particularly apply to Python functional programming.
(To the extent that "modularity" and "composition" apply to Python functional programming, they aren't really all that much better than the usual Python tools, used properly, and to the extent that they are it is because they fit into the OO rather than the other way around. Python is an OO language with functional things appended as useful. This is not a bad thing, but it doesn't make it a functional language.)
- jasonjackson 15y agoPython is multi-paradigm; it's not dominantly OO. Comparing python libraries to java libraries, functional composition is used just as frequently as OO composition (if not more so). If you're building a website, in Python/Django, you pass in your request handler function using first class functions. In java, you inherit from the request handler class, and override the method. JsonTools loads and dumps are pure functions. In java, josn.org, there's a class for each JSON type that you interact with. That being said, I can also think of many Python libraries that use classes.
- wahnfrieden 15y agoThe use of functions doesn't itself mean "functional programming" - is C a FP language, for instance?
- szany 15y agoYes! http://conal.net/blog/posts/the-c-language-is-purely-functional/ http://conal.net/blog/posts/the-c-language-is-purely-functio...
- jerf 15y agoFunctions are objects in Python. Thanks to __call__, quite profoundly so. Multiparadigm is a bit oversold; in any language, when paradigms conflict, something wins. Either you consistently choose something, in which case you get a coherent language, or you don't, in which case you get an incoherent mismash (which may be usable, but tends to scale poorly in the end). In Python, that something is OO. OO broadly means the base abstraction of the language syntax and base libraries is classes and objects. That's Python. Everything is an object, even when that's papered over with things that don't wave it in your face.