Atitit. Improve the principle and practice of language readability, and make atitit readable
Atitit. Principle and Practice of Improving language readability
Table 1-1 language evaluation criteria and language characteristics that affect them 1
1.3.1.2 orthogonal2
1.3.2.2 support for abstraction3
1.3.2.3 Expressiveness3
. 6. Trade-offs in language design4
Table 1-1 language evaluation criteria and language characteristics
|
|
Standard |
|
Features |
Readability |
Writability |
Availability |
|
Simplicity |
· |
· |
· |
|
Orthogonal |
· |
· |
· |
|
Data Type |
· |
· |
· |
|
Syntax Design |
· |
· |
· |
|
Abstract support |
|
· |
· |
|
Expression |
|
· |
· |
|
Type check |
|
|
· |
|
Exception Handling |
|
|
· |
|
Limited use of aliases |
|
|
· |
The third potential problem is Operator overloading, that is, an operator has multiple meanings. Although this is useful, enabling users to create their own reloads without being overloaded as usual reduces readability. For example, it is obvious that the overload "+" is used to add integers and floating-point numbers. In fact, this workload reduces the number of operators and simplifies the language. However, if the programmer defines "+" as the sum of all elements in two one-dimensional arrays, this program, it is hard to understand the programmers and the readers. A more challenging example that makes the program hard to understand is to define "+" as the difference between the first element of two vectors.
Of course, the simplicity of the language cannot be excessive. For example, as shown in the following section, the form and meaning of most assembly language statements are typical examples of simplicity. However, this simplicity makes assembly language programs less readable. Due to the lack of more complex control statements in assembly language programs, the program structure is not clear; because the statements are simple, there are much more statements required by the same program than advanced languages. If the control structure and data structure of the advanced language are inappropriate, although not as extreme as the above example, the conclusion is the same.
Author: nickname: old wow's paw (full name: Attilax Akbar Al Rapanui Attila Akba Arla Panui)
Chinese name: atira (iron), EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://www.cnblogs.com/attilax/
1.3.1.2 orthogonal
The orthogonal nature of programming languages means that a relatively small set of basic structures can be combined to form a language's control structure and data structure. In addition, any possible combination of the basic structure is valid and meaningful. For example, assume that a language has four basic data types (integer, single-precision, double-precision, and simplified) and two operators (arrays and pointers ). If both operators can act on themselves and four basic data types, a large amount of data structures can be defined.
A language is orthogonal, meaning it is independent of the context where the position appears in the Program ("orthogonal" comes from the orthogonal vector
IBM has many design restrictions, so it is less writeable.
Orthogonal and simplicity are directly related: the more the language design is, the less special cases are required for the language rules. The fewer special cases mean that the higher the design standards, the easier the language to learn, read, and understand. Anyone who has learned a lot of English can prove that many special rules in English are too difficult to learn (for example, I is always before e unless after c)
Too many orthogonal elements may also cause problems. ALGOL 68 language (van Wijngaarden, etc., 1969) may be the most orthogonal programming language. Each language structure in ALGOL 68 has a type, which has no limitations and has values in most structures. This free combination can produce extremely complex structures. For example, if the result is an address, you can place the condition statements, declaration statements, and other statements together on the left of the value assignment operator. This extreme orthogonal form leads to unnecessary complexity. In addition, because the language requires a large number of basic structures, a high degree of orthogonal will generate explosive combinations. Therefore, even if the combination method is simple, the overall number of them will lead to language complexity.
On the other hand, too many orthogonal elements are detrimental to writability. When the combination of almost any basic structure is reasonable, errors in the program will be difficult to detect, resulting in the compiler cannot find errors in the code.
It can be seen that the simplicity of a language is at least partly due to the combination of a relatively small amount of basic structures and the limited application of orthogonal principles.
Some people think that functional languages have good simplicity and orthogonal at the same time. A functional language, such as LISP, mainly performs computation by acting on a given parameter. On the contrary, imperative languages, such as C, C ++, and Java, usually use variables and value assignment statements to specify how to calculate. Functional Languages provide the best overall simplicity because they can use a structure called a function (function calls can be combined with other function calls in a simple way) to complete any computing. It is precisely this simple and elegant that some language researchers use functional languages as the primary alternative to complex non-functional languages (such as C ++. However, other factors, such as efficiency, limit the wider application of functional languages.
1.3.2.2 support for abstraction
In short, abstraction is the ability to define and use complex structures and operations in a way that allows you to ignore many details. Abstract is a key concept of contemporary programming language design, which reflects the central role of abstraction in modern programming methods. Therefore, the degree of abstraction allowed by programming languages and the natural degree of abstraction expressed are very important to the writability of languages. The programming language supports two different types of Abstraction: Process abstraction and data abstraction.
A simple example of process abstraction is to use a subroutine to implement the Sorting Algorithm needed in multiple places in the program.
As an example of data abstraction, consider a binary tree that stores integers on its nodes.
The final evolution of data-oriented software development began in the early 1980s S and evolved into an object-oriented design. The object-oriented design method is based on data abstraction,
1.3.2.3 Expressiveness
The expression of a language involves several different features. In a language similar to APL (Gilman and Rose, 1976), expressiveness means that there are several powerful operators that can implement a large number of computations in a very short program. The more common significance of Expressiveness is that the language has a simpler and less cumbersome way to specify the operation process. For example, in C, the form of count ++ is shorter and more convenient than count = count + 1. In addition, the Boolean operator and then in Ada can easily calculate the short-circuit value of a Boolean expression. The for statement in Java is more convenient than the while statement in writing a counting loop, the latter can also be implemented. All of the above improve the writability of the language.
Due to the structure of von noriman, the core features of imperative languages are variables (memory unit models) and value assignment statements (based on Transmission Operations) and Iterative Form of cyclic operations (this is the most efficient form of loop implementation in this architecture ). The operands in the expression are transmitted from memory to CPU, and the calculation result of the expression is returned to the memory unit represented on the left of the value assignment statement. Ti
Although in fact, the structure of imperative programming languages is based on the computer architecture, rather than the ability and willingness of programming language users, some people still think that using imperative languages is more natural than using functional languages to some extent, so many people think that even if functional programs run as efficiently as imperative programs, the use of imperative programming languages is still dominant.
. 6. Trade-offs in language design
The evaluation criteria for programming languages described in section l.3 provide a framework for language design. Unfortunately, this framework is self-contradictory. Hoare pointed out in his profound paper on language design (Hoare, 1973) that there are too many important but conflicting standards, and it is an important engineering task to coordinate and meet these standards.
References
1.3 language evaluation criteria-51CTO.COM.html