In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what are the design goals and principles of C++". In daily operation, I believe many people have doubts about what the design goals and principles of C++ are. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what are the design goals and principles of C++". Next, please follow the editor to study!
one。 The design goal of C++ (C++ Design Aims)
The design goal of C++ is to make C++ not only have the adaptability and efficiency of C language suitable for system programming, but also have language facilities like Simula in its program organization structure (the kind of program organization structure supported by Simula is often called object-oriented programming style). In the design, great efforts have been made to make the high-level programming technology borrowed from Simula can be applied to the system programming. That is to say, the abstract mechanism provided by C++ can be applied to those programming tasks that require high efficiency and adaptability.
The above design objectives of C++ can be summarized as follows:
For programmers who want to solve practical problems, C++ makes programming more fun; C++ is a general-purpose programming language that:
Is a better C.
Support data abstraction
Support for object-oriented programming
Support paradigm programming.
The support for paradigm programming is only achieved as a clear and independent goal in the later stage of C++ design. For most of the evolution of C++, I have placed paradigm programming and the language features that support it under the headline "data abstraction".
two。 Design principles of C++ (Design Principles)
In [Stroustrup,1994], the design rules of C++ are divided into four aspects: basic rules, design-based rules, technical rules of language and rules based on low-level programming, which are listed below.
1. Basic rules (General rules)
A: every step of the evolution and development of C++ must be caused by practical problems.
B: C++ is a language, not a complete system
C: you can't pursue it endlessly.
D: C++ must be useful at that time of its existence.
E: every language feature must have a well-founded and clear implementation plan
F: it always provides a workaround.
G: can provide an easy-to-understand support method for every programming style you want to support.
H: it is not forced on others.
It can be noted that the three basic rules imply two things: an emphasis on convenient tools for a variety of real-world applications, and full consideration of the programmer's technology and orientation (preferences). From the beginning, C++ was aimed at programmers who wanted to do actual projects. The so-called "*" is considered impossible because C++ users are too different in needs, backgrounds and problems to be solved. Moreover, even the interpretation of the word "*" may change greatly throughout the lifetime of a general-purpose programming language. Thus, in the process of language evolution, the feedback from users and the experience accumulated by language implementers are the most important.
two。 Design-based rules (Design-support rules)
A: support a good design
B: provide language facilities for program organization
C: heart as one (Say what you mean)
D: all language features must have practical and effective tolerance.
E: turning on a useful feature is more important than avoiding all misuses
F: the ability to combine independently developed components into complete software.
One of the goals of C++ is to provide easier-to-use and bearable design ideas and programming technologies to further improve the quality of programs. Most of these technologies are derived from Simula and are usually discussed as object-oriented programming and object-oriented design ideas. However, the design goal of C++ is always to support a variety of programming styles and ideas within a certain range. This is in contrast to the general views on language design. Generally speaking, language design always tries to build all systems into a single supported, mandatory programming style (or paradigm paradigm).
3. Technical rules of language (Language-technical rules)
A: there is no inherent conflict with static type system (Static type system)
B: provide good support for user-defined types as well as built-in types
C: locality behavior is desirable
D: avoid creating sequential dependencies
E: when you are confused about a language, you can choose the easiest part of its features to master.
F: can cause problems due to improper use of syntax (Syntax matters (often in perverse ways))
G: weakens the use of preprocessors.
Of course, these rules need to be considered specifically in the context of more basic goals. It should be noted that the requirements of "high compatibility with C", "no loss of efficiency" and "convenient availability to solve practical problems" are opposed to the requirements of "complete type security", "complete versatility" and "perfect abstract beauty".
C++ borrows user-defined types and class hierarchy mechanisms from Simula. However, in Simula and many similar languages, its support for user-defined types is fundamentally different from its support for built-in types. For example, Simula does not allow space on the stack for user-defined objects, and only allows access to these objects through pointers (which are called references-- reference in Simula). In contrast, built-in objects are allocated space only in the stack, not in dynamic storage, and cannot be pointed to it using pointers. This difference in the treatment of built-in types and user-defined types implies a strict consideration of efficiency issues. For example, when used as a reference to an object allocated in a dynamic store, if the object is of a custom type (such as complex), it puts a load on the runtime and space; these loads are considered unacceptable in some applications. These are the problems C++ intends to dabble in to solve. At the same time, the difference in usage also determines that it is impossible to treat those semantically similar types in paradigm programming.
When maintaining a large program, a programmer will inevitably make some changes to the program based on some incomplete knowledge and only pay attention to a small part of the whole program code. Based on this, C++ provides class, namespace and access control, which makes the locality of design decisions possible.
In languages based on one-pass compilation, some sequential dependencies are inevitable. In C++, for example, a variable or function cannot be used until it is declared. However, the name rules and overload resolution (overload resolution) rules for class members in C++ are developed independently of the order of declarations in order to reduce the possibility of confusion and errors to *.
4. Rules based on low-level programming (Low-level programming support rules)
A: use traditional (clumsy) connectors (linker)
B: there is no unexplained incompatibility with C language.
C: no room is left for lower-level languages below C++ (except assembly language)
D: you won't pay for the parts you don't use (zero load rule)
E: in case of doubt, it can provide a way of complete self-control.
C++ is designed to be compatible with C's "source-link" approach as long as its support for strong type checking (strong type checking) is not seriously affected. C++ 's compatibility with C allows C++ programmers to have a complete set of languages and tools available immediately. There are also two important points, one is that a large number of high-quality teaching materials about C already exist, and the other is that C++ programmers can take advantage of C++ 's compatibility with C to directly and effectively use a large number of off-the-shelf libraries. When deciding to use C as the basis of C++, C was not as outstanding and hot as it was later, so when considering this question, compared with the adaptability and efficiency provided by C, the popularity of C is only a secondary consideration.
However, the compatibility with C also makes C++ retain some of C's flaws in some syntax and semantics. For example, the declarative syntax of C language is far from elegant, and the implicit conversion rules of its built-in types are also chaotic. Another big problem is that many programmers who switch from C to C++ do not realize that a significant improvement in code quality can only be achieved through a significant change in programming style.
At this point, the study of "what are the design goals and principles of C++" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.