Question:
The functional approach is often contrasted with OOP. It's not entirely clear why? What makes functional programming different? Lambdas and the presence of functions like map, fold, reduce, etc.?
Update: What is the functional approach in terms of practice?
Answer:
Functional programming is a way of organizing stateless computation. Strictly speaking, such a program certainly has a state, it is a set of contexts of all its functions. But: The main problem behind the complexities of state, identity and change is that by introducing assignment, we are forced to introduce the concept of time (time) into our computational models. Before assignment appeared, our programs were independent of time – in the sense that every expression that had a value always had the same meaning.
In practice, using FP you go from simple to complex: you organize dependencies, relationships, transformations and composition of functions. Ways to do this are at the heart of FP methodology. Your functions are basically "pure", do not mutate the external context, and their result depends only on the passed parameters. FP completely eliminates the possibility of committing a whole class of errors (see SICP H. Abelson, D. D. Sussman : chapter "Pitfalls of imperative programming ").
It is wrong to think that functional style can only be written in an ultra-high-level language with artificial intelligence instead of a compiler. Of course, this can be done in any programming language that has higher-order functions . Moreover, the mechanics of functions is the basis of any interpreter and this mechanics is quite simple, but the introduction of the very concept of variables and their mutations greatly complicates the structure of the interpreter.
FP is opposed to OOP mainly because the wave of hype, created in due time around Java and C ++, went in the opposite direction. It turned out that template libraries and multi-level object hierarchies did not solve all the problems, on the contrary, creating new ones. The complexity of software systems continues to grow uncontrollably, and hence their cost. Here we see the industry's rational recourse to fundamentals to reduce entropy.