This paper describes some basic theories related to paradigms.
We will introduce the concepts and then discuss several specific paradigms.
1 the concept
Familiarize yourself with a few concepts before discussing this topic,
1.1 paradigm
The etymology of paradigm is
[…] […] […] […] Paradigm comes from Greek παράδειγμα (Paradeigma), “Pattern, example, Sample “[1] from the verb παραδείκνυμι (paradeiknumi), “Exhibit, represent, expose”[2] and that from παρά (para), “Beside, beyond”[3] and δείκνυμι (deiknumi), “to show, to point out”
Combining another commonly used word combination, Scientific Paradigm, Thomas Kuhn, a historian of science, describes it as
the set of concepts and practices that define a scientific discipline at any particular period of time
A set of concepts and practices that define scientific principles in a particular context.
Here we can understand paradigms as a series of concepts and practices for a particular object at a particular time. Similar to patten, but the latter is a technical summary of some specific problems.
In The Great Qin Empire, Shang Yang mentioned this word when he was telling Duke Xiaogong of Qin how to build a strong state. It was used to explain the differences between wei, Qi and Chu
The wei paradigm was strong in armored troops and goods, the Qi paradigm was strong in local officials, and the Chu paradigm was strong in mountains and rivers. And these three are not fundamentally strong enough to be imitated
1.2 Programming Paradigm
The concept of programming paradigms is explained in Wikipedia as a way of classifying different programming languages.
This section reference
- Classification of the principal programming paradigms
- Is there an authorative programming language feature list? [closed]
Solving a programming problem requires choosing a concept. Each paradigm is a collection of concepts designed to solve a particular problem more efficiently or concisely, such as object-oriented programming that is good at dealing with a large amount of associated data in a hierarchy. We have 27 of these combinations. Each language implements either one or more of these paradigms, and the language cannot properly handle concepts that are not included.
Each box in this diagram is a paradigm, Arrows point to concepts added from one paradigm to another, and you can see that two seemingly different paradigms may differ by only one concept (e.g., functional programming and object-oriented programming).
State represents the abstract representation of time in the program. For example, a function is stateless. The same input will have the same output.
Concepts, Techniques, and Models of Computer Programming are available for download here
- The cell and the port
Both concepts are similar and can be used to transfer data, with cells suitable for sharing data during atomic operations and ports used to communicate between active objects
-
Lexically scoped closure
Closures are an important concept, so let’s revisit it here. From an implementation perspective, a closure contains a PROCEDURE and its external references. From a programmer’s point of view, a closure is a packet of work: a program can add any instruction to the closure at one point, pass it to another, and decide to execute it at any point. The result of execution is as if it were executed at the point of creation.
The closure P, implemented in the D context, holds a reference to the corresponding context (D), such as a named state for x. We can say that the environment of P is closed over its definition context. At the location of the call, the C context, P uses a reference to the context.
- record
Is a data structure that can be used to access data
2. Specific Paradigm
2.1 Declarative programming and imperative programming
Declarative programming and imperative programming are two basic types of programming.
The former is used to represent the logic of the computation rather than to describe its control flow, such as XML. The latter uses statements that change program state to describe how the program operates, such as c.
2.2 Object-oriented programming
We all know that C ++ implements the object-oriented paradigm on top of C, and a related concept, procedural programming, is synonymous with imperative programming. From the previous chapter, the object-oriented paradigm adds the concept of closures to imperative programming.
The three characteristics of object orientation are
- Encapsulation enables information hiding by binding data to functions of operations
- The realization of inheritance is mainly divided into two kinds, one is based on class, the other is based on prototype, through inheritance can derive a new class or object, reuse the attributes and behavior of the parent class
- A Polymorphism can produce different results when it calls different methods in an inheritance hierarchy
For design principles and specifications for object-oriented programming, see this article.
2.3 Functional programming
Functional programming has one less concept than object-oriented programming, namely the cell. Therefore, pure functions have no state and should not have side effects other than returning corresponding values. However, not all of the functions we’ve seen are pure, as some may have the side effect of modifying the UI.
For more on Functional programming, see functional-light-js
End and spend