4 ms·
It doesn’t have to be all or nothing though. I’ve definitely seen (and written) functional Python in ‘real applications’ sprinkled here and there in an otherwis
by jgilias 3y ago
It doesn’t have to be all or nothing though. I’ve definitely seen (and written) functional Python in ‘real applications’ sprinkled here and there in an otherwise normal codebase.
In fact, I’d wager that any Python programmer worth their salt would suggest using a list comprehension and a lambda over a loop in most data transformation situations. Also currying comes in handy often once you have it in your toolkit.
It’s a bit silly to call two very mature libraries that are part of the Python standard library a ‘fun project’ just because the language itself supports multiple programming paradigms.
- xwowsersx 3y agoNo, it doesn't need to be all or nothing, but the scenario I was directing my point at was where people try to "do FP in lang X", not just sprinkling in functional concepts here are there. At this point, almost every language has some functional programming concepts in it, but I wasn't addressing that. I could've been clearer, but I've seen many cases where people would rather be programming in Haskell or some other functional language and then when "forced" to use some other language, like Python, they try to essentially recreate Haskell in that language and my point is that this really doesn't work or, at the very least, it's more trouble than it's worth and the resulting codebase is a complete mess because you've tried your hardest to do FP in a language that ultimately isn't suited for it. You are absolutely right though that it needs not be all or nothing. To the extent you can rely on some of these constructs and enable equational reasoning by avoiding mutation, etc. you'll be better off, no doubt (I do this too in Python and other languages because wherever I can make it easier to reason about my code, I will do so). I'm just cautioning against trying to do something akin to pure FP in Python.
- jgilias 3y agoThis I agree with completely! I’m a big believer of “when in Rome”. As in, try to be idiomatic in whatever language you need to use. I once saw a Python codebase where someone had tried very hard to write Java in Python.. That was equally horrible!
- xwowsersx 3y agoExactly. Java in Python sounds scary :)