1.3.1 function paradigm
Functional programming is a programming paradigm that defines the concepts we can use when thinking about a problem, but it cannot precisely specify how to express these concepts in programming languages. Therefore, many function languages emphasize different functional styles and features.
We can use a more familiar paradigm, Object-Oriented Programming (OOP) to compare. In the object-oriented style, we think about the problem as an object. Every object-oriented language has an object concept, but the details vary by language. For example, C ++ has multiple inheritance and JavaScript has prototypes ). In addition, you can also use the object-oriented style in non-object-oriented languages, such as C. Although this is uncomfortable, it will still enjoy some benefits.
Multiple Programming paradigms do not conflict. C # language is mainly object-oriented, but some functional functions are also available in version 3.0, so we can directly use the techniques from the function style. On the contrary, F # It is mainly a function language, but it fully supports. net object model. The advantage of the combination paradigm is that we can choose the most suitable solution to the problem.
Even if you are not planning to use the function language, learning the function paradigm is worthwhile. By learning the function style, you can get a more convenient concept to think about and solve daily programming problems. Interestingly, many standard object-oriented models describe how to write code for functional concepts in the object-oriented style.
Now let's look at the benefits of functional programming. We will first understand the Declarative Programming style, which provides a richer vocabulary to describe our intent.