Atitit. the principle and practice of improving language readability
table 1-1 Language evaluation criteria and their linguistic characteristics 1
1.3.1.2 orthogonality 2
1.3.2.2 support for abstraction 3
1.3.2.3 Expression 3
. 6 trade-offs in language design 4
table 1-1 Language evaluation criteria and their linguistic characteristics
|
Standard |
Characteristics |
Readability |
Writable |
Reliability |
simplicity |
· |
• |
• |
orthogonality |
· |
• |
• |
data type |
· |
• |
• |
grammar design |
· |
• |
• |
support for abstraction |
|
· |
• |
expression |
|
· |
• |
type check |
|
|
· |
exception handling |
|
|
· |
Use aliases in a limited way |
|
|
· |
The third potential problem is operator overloading, which means that an operator has multiple meanings. While this is useful, it can degrade readability if the consumer is allowed to create its own overloads and is not routinely overloaded. For example, overloading "+" for the addition of integers and floating-point numbers is obviously desirable. In fact, this overload simplifies the language by reducing the number of operators. But suppose the programmer defines "+" as the sum of all the elements in the two one-dimensional array, and because it differs from the usual vector summation, it is difficult for the program, the person writing the program, and the person reading the program to understand. A more extreme example of a program that is difficult to understand is the definition of "+" to calculate the difference between the first element of two vectors
Of course, the simplicity of language cannot be too much. For example, as shown in the next section, the form and meaning of most assembly language statements is a typical embodiment of simplicity. However, this simplicity makes assembly language programs less readable. Because the assembly language program lacks more complicated control statements, the program structure is not clear; Because the statements are simple, the same program requires much more statements than a high-level language. If the control structure and data structure of the high-level language are not appropriate, though not as extreme as the example above, the conclusion is the same.
author:: Nickname :Old Wow's claws( Full Name::AttilaxAkbar Al Rapanui Attilaksachanui)
Kanji Name: Etila ( Ayron) , email:[email protected]
reprint Please indicate source: http://www.cnblogs.com/attilax/
1.3.1.2 orthogonality
the orthogonality of programming language implies a relatively small set of basic structures, which can form the control structure and data structure of a language in a less combinatorial way. Moreover, any possible combination of the underlying structure is legitimate and meaningful. For example, the data type assumes that a language has 4 basic data Types (integer, single, Double, and character) and 2 operators (arrays and pointers). If all 2 operators can act on themselves and 4 basic data types, you can define a large number of data structures.
a language attribute is orthogonal, meaning that it is independent of the context in which the location appears in the program ("orthogonal" comes from the orthogonal vector, which
IBM has more limited design and therefore less writable
orthogonality is directly related to simplicity: the more orthogonal the language design, the less special cases the language rules require, and the fewer exceptions mean that the more standardized the design is, the easier it is to learn, read and understand. Anyone who has learned a lot of English can attest that many of the rules in English are too difficult to learn (for example, I always before E, except after C)
too much quadrature can also cause problems. the ALGOL 68 language (van Wijngaarden, etc., 1969) is probably the most orthogonal programming language. Each language structure in ALGOL 68 has a type that has no restrictions and that most structures have values. This free combination can produce extremely complex structures, for example, if the result is an address, you can put conditional statements, declaration statements, and other types of statements along the left side of the assignment operator. This extreme orthogonal form leads to unnecessary complexity. Moreover, because the language needs a large number of basic structures, the high degree of orthogonality will produce explosive combination mode. Therefore, even if the composition is simple, the overall number of them can lead to language complexity.
On the other hand, too much orthogonality is detrimental to the writable nature. When almost any combination of basic structures is justified, errors in the program can be difficult to detect, causing the compiler to be unable to discover fallacies in the code.
It can be seen that the simplicity of language is at least partly attributable to a relatively small combination of basic structures and the limited application of orthogonal principles.
Some people think that functional language has good simplicity and orthogonality at the same time. Functional languages, such as LISP, perform calculations primarily by acting on a given parameter. In contrast, imperative languages, such as C, C + +, and Java, typically use variables and assignment statements to specify how to calculate. Functional languages provide the best overall simplicity because they are able to do any computation with a structure, called function calls (which can be combined in a simple way with other function calls). It is this simple elegance that enables some language researchers to use functional language as the primary alternative to complex non-functional languages such as C + +. But other factors, such as efficiency, limit the wider use 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 for the neglect of many details. Abstract is the key concept of contemporary programming language design, which is the reflection of abstraction playing a central role in modern programming methodology. Therefore, the degree of abstraction allowed by the programming language and the natural degree of expressing abstraction are very important to the writable nature of the language. The programming language supports two different types of abstraction: Process abstraction and Data abstraction.
A simple example of process abstraction is the use of subroutines to implement multiple sorting algorithms in a program
As an example of data abstraction, consider a two-fork tree that stores integers on its nodes.
The final evolution of data-oriented software development began in the early the 1980s and evolved into object-oriented design. Object-oriented design method is based on data abstraction,
1.3.2.3 Expression
the expression of language involves a number of different characteristics. In languages like APL (Gilman and rose,1976), expression means that there are several powerful operators that can implement a large number of operations in a very short program. The more general meaning of expression is that the language has a simpler and less cumbersome way to specify the computational process. For example, in the C language, the form of count++ is shorter and more convenient than the count=count+1. Also, the Boolean operator and then in the ADA language conveniently indicate short-circuit evaluation of Boolean expressions, which is more convenient for a for statement in the Java language than using a while statement in a write-count loop, although the latter can be implemented. All of these improve the language's writable nature.
due to von Neumann structure, the core feature of imperative language is the variable (the model of the Memory unit), the assignment statement (based on the transport operation), and the iterative form of the cyclic operation (which is the most efficient form of implementing loops on that architecture). The operands in an expression are transferred from memory to the CPU, and the result of the expression is passed back to the memory unit represented by the left side of the assignment statement. Iteration
Despite the fact that the structure of imperative programming languages is modeled on computer architecture, rather than the ability and willingness of programming language users, some people still think that using imperative languages is somewhat more natural than using functional languages, so many believe that Even if a functional program is as efficient as a command-type program, the use of imperative programming languages will still dominate.
. 6 trade-offs in language design
The evaluation standard of the programming language introduced in the L.3 section provides a framework for language design. Unfortunately, this framework is contradictory. In his insightful paper on language design (hoare,1973), Hoare pointed out that there are too many important but conflicting criteria to coordinate and meet these standards is an important engineering task.
Resources
1.3 Language evaluation Criteria-51cto.com.html
Atitit. Principles and practices for improving language readability