3 ms·
The main thing I learned when learning Functional Programming was that there are multiple ways to solve the same problem, which forced me to look at the data an
by beatgammit 7y ago
The main thing I learned when learning Functional Programming was that there are multiple ways to solve the same problem, which forced me to look at the data and output first instead of jumping to the syntax to get intermediate results. A program isn't a set of conditionals, loops, and objects, it's a transformation of data from one form to another.
Before FP, I would implement a compiler as a massive state machine. In FP, I think more in terms of small functions that work together in a stream, and the state machine is implicit. With declarative programming, I think in terms of defining the grammar.
I don't use FP techniques for everything, but my whole way of approaching a problem is different because I know that other options exist. Sometimes I'll use a for loop, other times I'll make a recursive mapping function, it really depends on which solution is simpler and less likely to have bugs.