4 ms·
Just because it has those functions doesn't make it good at them. Have you ever seen a Pythonic program converted into functional style? It looks horrendous.
by Sirenos 11y ago
Just because it has those functions doesn't make it good at them. Have you ever seen a Pythonic program converted into functional style? It looks horrendous.
- aidos 11y agoI would imagine it depend on what extreme you take it to. You don't have pattern matching or tail recursion, which make certain styles impossible. There's a much better discussion over here http://stackoverflow.com/questions/1017621/why-isnt-python-very-good-for-functional-programming http://stackoverflow.com/questions/1017621/why-isnt-python-v...
- icebraining 11y agoIf you define "functional style" as using immutable data structures, higher-order functions, avoiding side-effects and using referentially transparent variables, I think Python programs look fine, and I try to write all the code I can this way (although practicality beats purity). If you define "functional style" as writing Lisp or Haskell programs using Python syntax, I agree they look horrendous.
- cutler 11y agoOr you can use Hy (http://hylang.org http://hylang.org) and write Python in Lisp syntax.
- tome 11y agoWhere did you get immutable data structures from in Python, and what do you do when every third party library you interact with uses mutable ones?
- icebraining 11y agoBesides tuples, I mostly treat the standard data structures as if they were immutable, without relying on them actually being :) As for third-party libraries, very few of them actually mutate structures passed by my code, in my experience; if they do, I simply make a copy before passing it.
- devishard 11y ago> Where did you get immutable data structures from in Python Here's my favored source (in the Standard Library) https://docs.python.org/2/library/collections.html#collections.namedtuple https://docs.python.org/2/library/collections.html#collectio... > and what do you do when every third party library you interact with uses mutable ones? That's situational; which library are you having a problem with? I haven't really had that problem (okay, sometimes the tooling around web frameworks do stupid things, but that's not common). Note that just because something is mutable doesn't mean you have to mutate it. Yes, Python doesn't as widely enforce non-mutation as Haskell, OCaml, etc., but that doesn't mean that suddenly all the Python programmers lost their minds and started mutating all the things. We're not savages.
- tome 11y ago> Note that just because something is mutable doesn't mean you have to mutate it I agree, and I don't mutate it, but my third party libraries and my collegues functions will. Not all of them, but enough to introduce annoying bugs.
- devishard 11y agoThis is why I asked, "Which library are you having a problem with?" You've claimed that third party libraries and your colleague's functions will mutate the data structures you pass them, but this has very rarely been my experience.