5

What's your opinion on functional shortcuts and 'hacks' in many languages, like map/reduce/filter, ternary operator, lambdas,inner/anonymous classes?

Imo they can make development faster and more efficent but they make the code very unreadable, especially if someone else has to read it, Therefore I try to use them only when it's appropriate. My dev friends use them too much and it makes reading their code a hellish experience, especially in Javascript with Rx.

Comments
  • 4
    Functional programming is not a hack... All those functions are very useful actually for making things readable too. For instance instead of writing multiple lines of code with temp variables and 5 loops, you can achieve it with stream() for example. I agree that in some cases it may not be required and make the code messy but in most cases it makes more sense and purpose of what's being done.

    Specially if you are using C# and linq, linq is God's gift and there's no reason whatsoever not to use it.
  • 3
    what px06 said, a map/grep (thinking of perl here) is much more understable than a couple of lines of a loop, specially if you're talking about big chunks of functional code.
    I don't see them as hacks at all, they're core functions and features like everything else.
  • 2
    Honestly I find map, reduce, and filter to be much more readable than any alternative.
Add Comment