Reputation: 19213
Most people say that even functional programming is less likely to land you a job, you can become a better imperative/OO programmer by learning it.
For me, it's mostly about writing "non member non friend" functions that have no side effects. But I couldn't come up with more examples where functional programming can be effectively applied in imperative languages, because working around languages' lack of features is often too cumbersome.
So what are some more (specific) examples/techniques that you actually applied in non-functional languages that were inspired by functional programming?
This one is quite abstract, but due to the lack of "objects" in most FP languages, the culture there tends favor rigorous data structure design. Usually, in OOP languages, because stuffing an extra variable in a class is too easy, things tend to go mess up rather quickly. Though the same could be done using OCaml's and Haskell's record syntax, that kind of approach somehow feels out of place in FP.
Upvotes: 4
Views: 506
Reputation: 6656
In my experience thinking on how to solve a problem functionally makes you think more about what data gets transformed to what - and not what state needs to be changed in order to keep the damn thing running...
Thinking of problems as transformations makes them appear different all by itself - which leads to different and most likely more elegant solutions.
Update: In c++ there is the <functional> header, and std::transform in <algorithm>.
Upvotes: 2
Reputation: 22126
Functional Java was already mentioned in the comments, but there is also some functional-ish stuff in Apache Commons Collections. See the org.apache.commons.collections.functors package.
Upvotes: 0
Reputation: 22126
The new-ish JavaScript array functions, filter, map, every, some, reduce, and reduceRight, are functional-inspired.
Upvotes: 0
Reputation: 10672
Most Ruby Enumerable methods are inspired by Higher Order Functions from Functional programming
Upvotes: 0