Order:
Many facts have given us a warning that fashion may turn into a blind image, and things that are noticed by the eye will soon be ignored, the most fierce hypes often disappear as quickly as possible, while the real valuable results often originate from people's most basic needs and aspirations.
To readers:
Here I would like to reiterate my long-term and strong belief that language is rarely meaningful and less fair.
My unwavering belief is that all successful languages are gradually developed, instead of being designed based on a certain first principle. The principle is the basis of the first design and guides the further evolution of language. However, in any case, even the Principles themselves will also develop.
Part 1 (the origin and development of C ++, Review and Outlook -- thy)
Chapter 1 C ++ prehistoric times:
A programming language may be the most important factor in the programmer's daily life. But in any case, a programming language is only a tiny part of the world, so it should not be taken too seriously. To maintain a balanced attitude, it is especially important to maintain your sense of humor.
Chapter 2 C with class:
This is the initial concept of an empirical law developed into C ++. The rule is: the relationship between user-defined types and internal types should be the same as the language rule, supports the same program in terms of language and related tools.
Over the years, thinking along this clue has gradually evolved into a C ++ design rule: it is not enough to provide only one feature, it must also be provided in a way that is actually affordable.
C ++'s access control aims to prevent unexpected events rather than spoofing. Any programming language, as long as it supports access to the original storage, will make the data in an open state, all attempts to touch a data item in a manner that violates the rules of the original data type can be implemented. The duty of protecting the system is to ensure that all operations against the type of system can only be performed explicitly, and the necessity of such operations should be minimized.
Chapter 3 C ++:
That is to say, orthogonal should be the second principle-after the most basic consideration of usefulness and efficiency.
The key to a good design is a deep understanding of the problem, rather than providing the highest level of features.
"C ++ is a general programming language designed to make serious programmers feel more pleasant to compile programs ."
Chapter 4 C ++ language design rules:
The theory must be consistent with the experimental data, otherwise it should be replaced by a better theory.
General rules of C ++
The development of C ++ must be driven by actual problems.
Not to be involved in the futile pursuit of perfection: any programming language is not perfect, because problems and systems are constantly changing, and there will be no perfect language in the future.
C ++ must be useful now;
Each feature must have a reasonable and obvious implementation method: there should be no features that must be correctly and effectively implemented through complex algorithms;
Provides a transformation path;
C ++ is a language rather than a complete system;
Provide comprehensive support for each style that should be supported;
Don't try to force people to do anything.
C ++ Design Support rules
Supports consistent design concepts;
Directly say what you mean: allow the language itself to express all important things, rather than using hacker techniques such as comments or macros;
All features must be affordable;
It is more important to allow a useful feature than to prevent the use of various errors: programmers will inevitably learn in the long term. This idea is also a variant of the traditional "Believe in programmers" in C language;
Supports software combination based on the separately developed parts.
C ++ technical rules
The static type system is not implicitly violated;
Provides the same support for user-defined types as internal types;
Localization is a good thing;
Avoid sequential dependency;
If you have any questions, select the form that is the easiest to teach about features;
Syntax is important (it often works in a way we don't want );
The necessity for using preprocessing programs should be cleared.
C ++ low-level Program Design Support rules
Use a traditional (dumb) Connection Program;
There is no incompatibility with C for no reason;
In C ++, there is no space for lower-level languages (except assembly languages );
There is no need to pay for unnecessary things (0 overhead rules );
Manual control is provided if you have any questions.
My Opinion on C ++ is that it is a new language for producing software, paying special attention to the mechanisms that affect the program structure, compared with the natural tendency to only make small adjustments, this idea is totally different from the same path.
Chapter V year:
Release2.0, labeled c ++ reference manual, ANSI and ISO Standardization
Chapter 6 standardization:
In fact, there is a consensus that the transformation to the object-oriented style will also lead to a significant reduction in the parameter table, because some common parameters or global values are now in a local state. Based on these experiences, I expect the average length of the parameter table to fall below 2, and it is rare to install more than two parameters.
Chapter 7 follow and use:
The programming environment can also be used by providers to lock users in a world closed by features, libraries, tools, and work templates, and cannot be easily transferred to other systems.
"You must be especially careful to ensure that the program source code can be transferred between different environments at a very low cost ."
New concepts need to be learned and mastered through practice. The old work habits that have been tested repeatedly need to be reevaluated.
If you can take all the time to learn C ++, you may be able to adapt to it faster. However, this adaptation may also be a lie before we apply new ideas to real projects. Object-Oriented Programming and object-oriented design are basically practical training rather than theoretical training.
Sadly, people often forget that, in reality, there will always be a need for a variety of languages, a real niche language, and an experimental language. Praising a language, such as C ++, does not mean criticizing all other languages.
Chapter 8 database:
Designing a database is often better than adding a language feature.
Designing a database can often become the most constructive way of venting the pursuit of new mechanisms. Only when the road to database is truly inaccessible should we embark on the road to language expansion.
The C characters in the names of standard I/O Stream cout and CIN are designed for character-based I/O.
Chapter 9 Outlook:
You cannot swim in the same river twice.
"C ++ is a general programming language designed to make a serious programmer feel more pleasant. "(The author cited his own words here to demonstrate his belief in the design purpose-Thy)
C ++ makes Object-Oriented Programming and data abstraction cheaper and usable.
I have always considered the isolation of environment and language as the most fundamental thing. I do not want to use only one language, one set of tools, or one operating system. To provide choices, isolation is the most basic thing. Once such isolation is available, people can provide different environments to adapt to different work and different needs, in terms of technical support, resource consumption, and portability.
C ++ is designed for serious programmers and will grow to help them face bigger and more complex tasks.
"According to our comments, C ++ is already too big and too complicated, and millions of lines of code have been put there. We need to try not to break them ....... As long as possible, we will be more willing to see the expansion of replacing the language with programming technology or library functions ."
I want to build C ++ as a bridge where programmers can use it to transition from traditional programming to data abstraction and object-oriented programming. We still need this bridge for a long time.
The advantage of C ++ lies more in that it is a good solution to many problems, rather than being the best solution to a specific problem.
The most notable strength of c ++ is that it works well in systems or organizations that combine multiple different applications.
All languages will die or change to meet new challenges. The language of an extremely large and active user community will always change rather than die. This is what happens in the C language, resulting in C ++. One day, this may also happen to C ++.
C ++ is not perfect; it does not want to be designed to be perfect, and no other language can be used.
Basically, development does not come from an isolated progress, but from a large number of progress in different fields.
Part 2 (Language Features of C ++)
Chapter 10 storage management:
You may need fine-grained control over storage allocation and release in the following three cases:
One is to make an independent class distributor for a frequently used class (such as Tree nodes, linked list links, points, lines, messages, etc.
There are two factors at work: the run time and storage overhead of the storage allocation operation, and the fragmentation problem caused by the mixing of various sizes of objects.
Second, the program that needs to run for a long time without interruption in a resource-intensive environment.
Third, an object must be placed in a specific address or a special storage area to meet the special requirements of hardware or system.
Chapter 4 heavy load
This rule (the void * parameter is selected only when no other pointer parameters can match) has an interesting property: It establishes void * as the root of the class conversion tree.
A simpler, stricter, and easier-to-understand language can not only attract programmers who have been dissatisfied with the existing language, but also attract more programmers who dare to take risks.
Private destructor can also stop Derived classes (in fact, private constructors can also stop derivation ). This actually indicates that classes with private destructor and abstract classes complement each other logically.
Chapter 2 Multi-Inheritance
In addition to providing only one object in a derived class, the virtual base class is identical to the non-virtual base class in other aspects.
However, classes accessed through virtual functions and classes that simply save a few data items are usually the best virtual base classes.
Most of the language wars are stupid, but it is even more stupid to concentrate on an isolated feature.
"Multi-inheritance is like a parachute. You don't need it often, but it is the most important thing when you need it ." (-- Grady booch)
Chapter 1 refinement of class concepts
An abstract class represents an interface.
An abstract class is a pure interface, and its implementation is provided by the class derived from it.
I really valued the ability to define classes in stages. That is to say, I found it useful to define some pure virtual functions in advance and leave others to further derived classes for definition.
(Const) benefits mainly include the clarity of the Code, the increase in the number of objects that can be inserted into the Rom, And the segmentation feature of the Code.
People are constantly loading all kinds of unnecessary things into their header files, thus being hurt by excessive Compilation Time. Therefore, every technology that helps reduce unnecessary coupling between users and implementers is very important. (For example, class Forward Declaration, abstract interface design, so that you only need to import the abstract class header file, use a forward reference template class header file such as <iosfwd>)
Chapter 4 force
I never think that organizing programs in the form of type switch statements should be directly supported.
A simple conversion policy is to force static_cast to all of them, and then let's look at what the compiler will say.
Chapter 4 Template
In my mind, the template and exception are two sides of a coin :......
Any nature of a type or algorithm can be represented by a type..., such a type can be used to guide the parsing of overload, by selecting functions that depend on the relevant nature.
A specialization must be declared before use. For example:
Template <class T> void sort (vector <t> & V) {}</P> <p> void sort <char *> (vector <char *> & V) {}// specialization </P> <p> void F (vector <char *> & V1, vector <string> & V2) <br/> {<br/> sort (V1); // use specialization sort (vector <char *> &) <br/> sort (V2 ); // use general template sort (vector <t> &) <br/>}</P> <p> void sort <string> (vector <string> & V ); // error: specialize after use </P> <p> void sort <> (vector <double> & V); // fine: sort <double> hasn' t yet been used <br/>
"C ++ is a strong enough language-the first such language in our experience-it enables humans to construct program design components of a category, it combines the precision, beauty, and abstraction of mathematics, coupled with the efficiency of non-class manual coding. "(-- Alex Stepanov)
My Opinion on Fault-Tolerant Systems is: such systems must be multi-level ,......, at a certain point, a unit must be abandoned, and further cleanup work should be left to a "higher level" unit.
To provide some features so that a single program can be restored from all the errors, this is completely misleading and will make the error handling policy very complex, it will become the root cause of new errors.
The core of the exception handling design is actually resource management.
Therefore, we can use an object of a class with constructors and destructor to handle resource request and release issues as appropriate ....... In any case, (this object) will be destroyed at the end of its own scope, and its destructor will release related resources ....... I call this technology "resource acquisition is initialization ".
(IF) an error occurs in the construction function..., exception handling provides a universal solution:
Fileprt: fileptr (const char * n, const char * A) <br/>{< br/> If (P = open (n, a) = 0) {<br/> // OPPs! Open failed <br/> throw open_failed (n, a); <br/>}
More importantly, the C ++ Exception Handling Mechanism can ensure that some constructed objects are destroyed correctly, that is, the constructed sub-objects are destroyed, the child objects that have not yet been constructed will not be performed.
Void F () Throw (E1, E2) {} has the advantage of not only saving type checks, but also the most important advantage: function declaration is an interface that you can see.
C ++ Exception Handling Mechanism... so that programs that do not throw exceptions do not pay any time cost.
Exception Handling does not actually affect the layout model of objects.
**************************************** **************************************** **************************************** ******************************
I am inspired by the philosophy of designing a comprehensive programming language in the book. As the pragmatic programmer says, do not pursue perfection because there is no perfection. (Pursuing perfection is perfect -- thy)
I remember when I first learned programming, I went to the Internet to check whether C ++ is good, objective Pascal is good, VC is good, or BCB is good... I think this comparison is both right and wrong. The mistake is that the pursuit of non-existent perfection is true because for a person with a certain purpose (to implement a function and to learn a certain field ...), He must find the "perfect" language in this field to avoid detours.
As the designer and master of C ++, the author's scholar temperament, gentleman manners, the keen eyes of the researchers, and the advanced eyes Of The Thinker are deeply impressed by me.
At my level, I can only understand 30% of the content in the book. I can understand the summary above, but this has already benefited me a lot. In the future, I will have the opportunity to read the master's classics.