What is it
Before describing the difference and pros and cons, briefly introduce both.
Functional programming, as the name suggests, this kind of programming is the function of thinking as the core, in this thinking angle to think about the problem. The most important foundation of this programming is the lambda calculus, which accepts functions as inputs and outputs.
Object-oriented programming, which is the problem of the object as a property of the object and the behavior of the composition. Based on the concept of object, the class is used as the template of object, and the class and inheritance are used as the structure mechanism and object as the center to think and solve the problem.
Advantages
Functional programming: Support for closures and high-order functions, closures are an object that functions as a function and can be manipulated as objects, while higher-order functions can be programmed with another function as an input value. Supports lazy computing, which can be evaluated at a time when the evaluation requires an expression, rather than being fixed on a variable. It is also possible to use recursion as a control process. The code that is programmed by functional programming is relatively much less and more concise.
Object-Oriented Programming: Object-oriented has three main characteristics, namely encapsulation, inheritance and polymorphism. The description of the class shows the encapsulation, class as an object template, contains private and public data, encapsulation performance makes the data more security depends on the characteristics of the class, so that users can only see the external characteristics of objects, can not see the intrinsic properties of objects, users can only access public data can not directly access to private data. The derivation of a class shows inheritance, which is the mechanism by which the subclass shares the parent class, but because of encapsulation, inheritance is limited to the inheritance of the public data (as well as the inheritance of protecting the data), and the subclass can also be derived while inheriting. Polymorphism refers to the polymorphism of the behavior of the object based on the received information, and different objects receive the same information to form many kinds of behaviors.
Disadvantages
Functional programming: All data can not be changed, seriously occupy the running resources, resulting in the running speed is not fast enough.
Object-oriented programming: A lot of unwanted code is generated to write reusable code, and many people object oriented to object-oriented causes code to cause late maintenance a lot of trouble.