3 ms·
I do actually experience this : functional style is shorter, more effective, and more bugfree, and you can do it even in Go (if you're willing to copy bits to c
by iofj 10y ago
I do actually experience this : functional style is shorter, more effective, and more bugfree, and you can do it even in Go (if you're willing to copy bits to compensate for lack of generics).
However, there is a large class of programmers that will kill you on the code review if they see this. Mostly I think it's for lack of understanding, or I've gotten comments complaining exactly that it's not imperative code.
Unless you're willing to educate your colleagues, the post may have a point : learning functional style will improve your programs but seriously increase your frustrations.
- elcapitan 10y agoThe post sounds like an instance of solving the wrong problem. If you can write more concise, elegant and bug-free code, but all your colleagues can't deal with it and want to stick with their stuff, you're probably in the wrong place. On the other hand: Python doesn't exactly impress me as a particularly "functional" language. The examples are not as straightforward as the Haskell examples. Python uses a weird mix of OOP, imperative and functional programming, and this creates mental strain for everybody who has to read it. When I switch from Ruby to Python, I usually enjoy the simple imperative-pseudo-code like way of how the most idiomatic code there works. Then when I go back to Ruby I'm happy to use idiomatic metaprogramming, chained blocks of code etc. The same is true for Go and probably part of the current fascination of the dev community with the language (because it's proud of constraining complexity of expression).
- accountt 10y ago> Python uses a weird mix of OOP, imperative and functional programming, and this creates mental strain for everybody who has to read it. I used to think so until I came across Oz. It's Prolog, Lisp and Python all in one nice package :) Granted, it's more of an educational language, still though, Oz is a mind-stretcher.
- falcolas 10y ago> and this creates mental strain for everybody who has to read it. Really? I find it just the opposite. List comprehensions are broadly welcomed instead of one- or two-line for loops, lambdas are quite useful in the right context (such as sorting, list comprehensions, etc), and functions are a first class citizen, and easily used (and recognized) as such. It just lets me use the right tool for the job, without having to switch languages. And since the functional bits have been baked in for so long, it's easy to do. And let's be fair, you can't say that there's cognitive overhead to functional programming in Python while claiming Ruby does not. Both languages have nearly identical capabilities in this regard (though, I do miss Ruby's multi-expresssion lambdas when in Python).