2 ms·
Functional programming is simply the obsession with functions: the use of the function call, and indirection on functions, as the only control mechanism. Funct
by kazinator 8y ago
Functional programming is simply the obsession with functions: the use of the function call, and indirection on functions, as the only control mechanism.
Functional programming emphasizes recursion, deferral of control decisions into functions (e.g. pass functional arguments to some function, and let it decide which are called and which are not), and the re-ification of all control mechanisms as functions (e.g. continuations).
If it has loops, ifs and gotos, it is not functional. If it just has function calls, then it's functional, even if there is mutation going on of variables or array elements and such.
Purity plays well into functional programming, because if we have structured the control flows in the program based on function calls, we can determine which functions are pure and which are not, and get a good grip on reasoning about and managing the side effects to avoid surprises.