Are small amounts of functional programming understandable by non-FP people?
- by kd35a
Case: I'm working at a company, writing an application in Python that is handling a lot of data in arrays. I'm the only developer of this program at the moment, but it will probably be used/modified/extended in the future (1-3 years) by some other programmer, at this moment unknown to me. I will probably not be there directly to help then, but maybe give some support via email if I have time for it.
So, as a developer who has learned functional programming (Haskell), I tend to solve, for example, filtering like this:
filtered = filter(lambda item: included(item.time, dur), measures)
The rest of the code is OO, it's just some small cases where I want to solve it like this, because it is much simpler and more beautiful according to me.
Question: Is it OK today to write code like this?
How does a developer that hasn't written/learned FP react to code like this?
Is it readable?
Modifiable?
Should I write documentation like explaining to a child what the line does?
# Filter out the items from measures for which included(item.time, dur) != True
I have asked my boss, and he just says "FP is black magic, but if it works and is the most efficient solution, then it's OK to use it."
What is your opinion on this? As a non-FP programmer, how do you react to the code? Is the code "googable" so you can understand what it does? I would love feedback on this :)
Edit: I marked phant0m's post as answer, because he gives good advice on how to write the code in a more readable way, and still keep the advantages. But I would also like to recommend superM's post because of his viewpoint as a non-FP programmer.