My blog has long focused on the technology and details of C++, which even made some readers and applicants feel embarrassed. However, in May, an article titled "How Should You Learn C++" received over 30,000 reads, becoming the most read article on the blog (far exceeding the second-highest). Why did this single article provoke so many responses? It must be that the domestic C++ community has been suppressed by C++ for too long, or more precisely, by C++ education. In fact, whether on major domestic forums, international C++ forums like comp.lang.c++.moderated, or even on Douban groups, those interested can see that attention to C++ language details has never stopped. Similarly, complaints about these details have also never ceased. For example, James Kanze, a technical expert on comp.lang.c++.moderated, mentioned that he has been working with C++ for ten years and still needs to refer to the C++ standard from time to time. No wonder Eric Raymond's boss once said, "C++ is anti-compact" in "The Art of Unix Programming." There are too many details in C++, and even if you've seen them, you might not remember them. More importantly, even if you do remember, it doesn't necessarily make you a good programmer.
Many people attribute too much detail (or "too many dark corners" in a derogatory sense) to the essence of C++, believing all evils stem from it. Because of this, around September, Linus stated on a mailing list, "C++ is a thought-provoking language; just to keep programmers away from C++, I also use C." This short sentence caused a big reaction in China. Initially, Liu Jiang interpreted Linus's words, then Yunfeng and Meng Yan both expressed their opinions. I also wrote an article called "Why C++" (which was later published and Bjarne provided friendly comments on it).
However, after this sudden flood of reactions, I believe the changes caused may not be significant. Most original opponents can find reasons for their opposition, thus being more opposed; most original supporters can find reasons for their approval, thus agreeing more; and the rest have no clear opinions, and both sides have their own reasons, which may still leave them confused.
Getting rid of self-serving bias - the premise of rational thinking
An interesting and true story is mentioned in "Decision and Judgment": One day in 1980, the computer of the US Air Combat Command suddenly issued an alarm - a nuclear bomb from the Soviet Union was flying to the United States. The commander immediately dispatched troops and quickly prepared for a nuclear war. However, after three minutes, the engineers found that a small component of the computer had malfunctioned. After this false alarm, the public's reaction was really interesting: the original supporters of nuclear weapons now felt safer (because "the facts prove that such failures are completely overcomeable"), while others felt less secure (because "such false signals may cause the Soviet Union to overreact and trigger a real nuclear war"). A similar situation occurred after the Three Mile Island nuclear leak incident. Opponents believed ("This shows that management has no way to manage nuclear energy safely"), while supporters believed ("This shows that such danger is not as serious as it might be, and it is overcome"). Social psychology summarizes such phenomena as "self-serving bias." Unfortunately, "the more the truth is clarified," it only applies to rational thinkers.
Why is it so big? It is because the real reason behind the "language dispute" that has been rampant in the programmer community is not the quality of the language, but the eyes of the observer. In the eyes of the observer, language is not a tool, but the skill that he spent more than N (especially C++ is the most) to "cultivate." For such skills, being denied is undoubtedly equivalent to being denied. So, psychologically speaking, language is not a tool (although there has always been such an appeal), but a belief. Such a belief is more intense in the language that takes longer. Interestingly, almost all the "hot" communities have this phenomenon, Java, Python, Ruby... not so much; because even if the language itself is not complicated, programmers still have to invest a lot of energy to learn all kinds of things. Framework class library (think of those frameworks for Java?). So the beliefs of these language communities are not necessarily stronger than the C++ community.
However, once we understand why we think of language as a belief, it is very helpful to get rid of the "self-serving bias" when looking at language and to look at the problem from an objective perspective. - "When you see evidence supporting an opinion, try to think about what evidence does not support it."
So why should you get rid of self-service bias? To be small is to become a better programmer (no one wants to use an inefficient language or even an inappropriate language because of prejudice). To say it is to save lives (because prejudice can lead to deeper and deeper, wasting time).
So, if you can reasonably think about the issues we are going to discuss, avoid self-service bias (just when you never spend time on C++). Then we can start to discuss the real problem.
Now, almost every C++ learning knows that the core problem of C++ is its complexity; even if it is not in the C++ community itself, it is a fact. The eyes of the masses are sharp, not to mention the fact that it is too obvious.
But I have read countless articles on the complexity of C++, and the spit-stars that argue about the complexity of C++ (including the two C++ summaries I wrote some time ago). I always have a feeling - not analyzed, just like the blind person. As a reader of "Why C++" criticized, I did not write in the article what is the "non-essential complexity" of C++. Of course, I can know by myself, and people who have been exposed to C++ for a while can generally know, but novices and even non-newbies do not have a specific understanding of what I call "non-essential complexity." "Why C++" breaks away from the original intent - for all C++ users and learners.
For the same reason, after writing the article "How Should You Learn C++", when Mr. Meng Yan invited me to write a series of articles for "Programmer" to introduce my attitude and understanding change in the process of contacting C++, Although I was very happy to agree, but until now, 3 months have passed. why? Because I feel that the real essential problem has not been clearly touched; so I have not used the pen until now, so as not to say a lot of nonsense, besides being able to read as a novel, really consider whether to learn or even use C++. People may not have any practical use.
However, such a thought has always been placed in the subconscious. I talked to Bjarne a while ago and talked about some of the ideas about the complexity of C++. I summed up the source of C++ complexity in the email, and I feel a lot clearer. The purpose of this article is to convey a concrete and clear understanding of the complexity of C++. With this understanding as a support, we can deduce the best (practice) approach to learning C++.
Why study (and use) C++
Obviously, if you can't find a reason to learn C++, then talking about "correct learning methods" is equivalent to nonsense.
First, repeat Bjarne's words: "Our system is extremely complex. To avoid the complexity of C++ and simply not use C++ (Linus's approach), it is tantamount to ruining." In all areas where C and C++ are available, C++ They are all better languages than C. When I say "better," I am talking about C++ having a more secure type check than C, a better abstraction mechanism, and a better library. Of course, there are exceptions to everything, if the project you are doing 1) is not big. 2) There is no abstract mechanism used in coding. Even ADT (abstract data types, such as std::complex, which does not contain polymorphism and inheritance) is not used. RAII is also not used, and exceptions are not used. 3) You don't need even the base library (for example, smart pointers that simplify resource management, smart containers). Then maybe you have no problem with C; so if your situation is so, don't argue with me because I can't refute you. The areas we are talking about here are roughly those places that Bjarne listed in the "C++ Application List."
The bottom line is: If you remove the unnecessary complexity in C++, leave those essential, important language features, simplify the language model, and eliminate historical burdens. Even C++ opponents may find it hard to find a reason to say "I still don't need C++." In my opinion, there is only one reason for a person who is rationally opposed to using C++ in practice: the confusion caused by the complexity of C++ is even more than the abstraction mechanism and library of C++ (in his specific project). benefit.
It is worth noting that there is a need to avoid a trap here, that is, once people have identified "C++ is not good," then the reason will "grow their own feet," that is, even if we take the complexity of C++, they may also Will insist on or not C++, and find a bunch of reasons for it. I assume that you are not such a person. However, perhaps most likely he would say: "The problem is that C++ we use today is not so (simple), your assumptions are not true." Yes, my assumptions are not true. But while we can't eliminate complexity, we can actually avoid complexity and avoid growth. This is also the main point of this article, let me elaborate later.
Of course, you may still say it until now. I still don't need C++ because I can use D; or if you don't need C++ for the project you're doing, you might say that I use Python. First of all, if your project can be done in Java/Python or even Ruby, then C++ is a bitter to eat. Because the language that can represent your project is not very efficient in terms of efficiency, what is the value of a language that does not have much benefit in efficiency and is more complex in complexity? Second, if your project efficiency is important, you might say that you can use D. However, the reality is that D is used very little in industry, especially in China, and there is almost no. C++ has a large number of existing code. Companies that have used C++ to do their products are almost impossible to rewrite code in other languages for a long time. As Joel said, he decided to rewrite one. Non-trivial code base == suicide. Therefore, we must at least pay attention to the following two obvious facts:
Fact 1: C++ still has a stable core market in industry.
This fact probably does not need to be elaborated. The core technology of many large companies is still supported by C++ (see the C++ application list on the Bjarne homepage). The so-called facts are not necessarily the conditions that everyone is most willing to admit, but they have to admit. C++ has accumulated a huge code base, which can not be overturned overnight. D is indeed better than C++ from a linguistic point of view, but the most important thing is that it has not yet penetrated into industry (perhaps the root cause is that there is no money to support it, but this is not the focus of our discussion). And C, according to Bjarne himself, his observation is that the trend in the mainstream industry has always been "from C to C++", not the other way around, at least in Europe and America. In China, we can get a similar information through the recruitment situation on CSDN.
Fact 2: C++ programmers often enjoy competitive pay.
Yes, this is not a technical article that does not eat human fireworks. The logic on which this fact is based is simple: things are rare. When Andrei Alexandrescu came to China's SD2.0 conference this time, he also said in an interview: "The most profitable software (such as MS Office) is written in C++." Meng Yan also mentioned this fact on the blog. I think he is the technical editor of CSDN. The industry observation is definitely clearer than me. So I don't have much nonsense here.
Of course, the above logic does not mean that you are going to learn C++, everything depends on your interest. So if you are not in the field of application where C++ is, then this article is not written for you.
"The complexity of C++ is the root cause" - a flawed reasoning
Once we know that C++ is in need (learning and mastering) in some areas, we can discuss the core issue of "How to learn and master C++ correctly."
In fact, Bjarne has been promoting this issue for ten years. As early as 1999, Bjarne wrote "Learning C++ as A New Language" and mentioned in several technical interviews (here, here, here and here) how to correctly treat and use the various types supported in C++. The problem of abstract mechanisms. Andrew Koenig also wrote a modern C++ tutorial called "Accelerated C++" (which will be mentioned later in this book). However, has the situation of the C++ community improved over the years? As far as I know, even if there is improvement, it is very small. Learners are still blindly drilling the language details, only to see the trees are not seen in the forest; the Internet is still filled with a variety of "technical" articles and unreliable "XX recommendations for learning C++"; some industry experts with identity are still One book after another, the language of the language, and the writing of some of the common programmers' eight-life skills and the corners that can't be touched. The company that really uses C++ in the industry always asks some corners during the interview. The details of the problem, not the basic literacy of programming (no, mastering all the language details can not make you a qualified programmer). The interview idea is wrong. It is estimated that the reasoning behind it should be "If this guy doesn't know the details, then he is not familiar with the language. If he knows, then he may not be a good programmer. , but we can still further test the latter question. The problem with this concept is that the language is familiar to a certain extent (what degree will be specifically suggested later), it can be well programmed (the rest is only to look up Documentation); and many companies go too far when testing "familiarity with the language" (for example, asking the temporary object lifetime and destructor order is of course understandable, but ask how to avoid a class being copied or how to avoid it Is it built on the heap?); Of course, some language knowledge must be mastered in advance, and what will be mentioned later. When interviewing, you can't ask the language details. The key is "what to ask."
so:
Fact 3: The entire ecosystem of C++ has not improved much in the philosophy of learning C++ over the years.
why? Is it because the learning method introduced by Bjarne is technically not mentioned? Is Andrew Koenig's writing not good enough? No one can believe it. Because in fact, the reason here is not technical, but non-technical.
It is a well-known fact that, at the most basic level, the most serious problem with C++ is that it takes too much time for learners in the language learning phase. Turn over your C++ bookshelf or e-book directory, and most C++ "classics" are speaking languages. In our usual sense, to "get in" C++, it takes two or three years to spend the language. To be "proficient in" C++, it takes ten years and eight years to do it. (This is not the same thing as Peter Norvig's "ten years of learning programming". People say programming skills in general sense, not to be a language lawyer.)
Then why do I say that "the complexity of C++ is the root cause" is a flawed reasoning? Because, to let people spend a lot of time learning the complexities of language before using a language to do things, in addition to the fact of the complexity of the language itself, there is an important fact, that is, the learner's Attitude and (more important) methods. What are the attitudes and methods of most C++ learners? ——Before you actually use C++, read a linguistic book (the daily programming is not necessarily used for eight lifetimes). And why is there such a learning attitude? This is the question that really needs to be explained. In fact, there are two reasons:
Fact 4: The vast majority of C++ books on the market (including many that are widely known as “must read classicsâ€) are actually negative textbooks.
In other words, if you pick up any C++ books (including many that are widely known as "must read classics"), then there is a great possibility that the content of this book is not what you should learn, but that you are not Should learn. There are two reasons why I say this because I was a victim. Second, and more substantial reasons, these so-called must-read classics are full of traps in C++ and various workarounds for C++ flaws (good to call Idioms or techniques); Because there are so many pitfalls and flaws in C++, a "long tail" is drawn; such books exist in all languages ("C Defects and Traps", "Effective Java", "Effective C#", etc. Etc.) However, in C++ this tail is particularly long, resulting in countless such books. Third, the defects and traps listed in these books do not distinguish the common level. For a programmer, you should want to see the order from "the most common problem to the least common problem". However, these books are all mixed together, or the content is introduced according to the technical classification of "resource management, class design, generics", which is not helpful at all. (If I see the content of a chapter, I certainly know what it says. Is it a class design or resource management, and is it nonsense?) that makes it impossible for a learner to distinguish and spend the most important time on the most common problems.
The most important thing is that the contents of these books have nothing to do with being a good programmer. They can only tell you at most - hey, be careful to fall into this trap. Or tell you - hey, you know that when you (the eight lifetimes don't necessarily meet) meet this need, can you solve this problem with this technique? After reading one book after another, in addition to the "forbidden", "alert" and "bulb" symbols in your head, the true programming quality is not growing. Or there is such a book, eager to explain the mechanism behind language implementation, but what is the nature of language features? It is used to abstract in the actual coding (speaking well, "design"), not to tell you how this feature is supported. For example, I have seen the following scenario: The interviewer asks: "Do you know virtual functions?" The answer is a bunch of explanations about the virtual function table mechanism. The interviewer asked again: "What are the benefits of the virtual function?" Why do you want virtual functions? The answer is: "Well... ah... that is... polymorphism" (at this time, I feel that the answer is not deep enough). Ask again: "What is the polymorphism?" Dumbless.
Fact 5: Even remembering all the details of a language doesn't make you a qualified programmer.
Fact 6: Understanding language implementation has its practical meaning (the hacking method in extreme situations and the rapid positioning of problems when there are underlying bugs), but if you understand the language mechanism in order to understand the language mechanism, it is out of the original meaning of learning the language.
This is often the case in C++: knowing the underlying mechanisms of language implementation, but not knowing where the meaning of the language features themselves is. The cart before the horse is upside down. why? The book is harmful. Second, all the scenes introduced in this kind of book add up to only those 20% (the 28th rule), or even 20% of the scenes (what books are, will be introduced later, I will not directly list the title, hit The face is too big, but I will list the book I think is essential). That's why I said "I don't need to use it for eight lifetimes."
Fact 7: 80% of C++ books (including some "classic") involve only 20% (or less) of the scene.
You might say, aren't these books worth watching?
My answer is yes. Not worth seeing at all. - But it's worth putting it aside as a reference when necessary (remember to flip from the index or directory, just look at the strictly necessary parts), if you are a serious programmer. Because whether you admit it or not, the power of Murphy's Law cannot be ignored - if there is a trap that you may encounter, you will always encounter it. Similarly, the cleverness of C++ is not unfounded, and sometimes it will be needed. But you don't need to put all the details and techniques of C++ in your mind before you can program it, namely:
Recommendation 1: C++ books that are discerningly read (including those widely known as "classics").
If a piece of content introduced in the book is not basically used in daily programming (belonging to 20% of the scene), then perhaps the best thing to do is to take a very general look and make an impression instead of following this line. Let's go deeper. What books should be read at the beginning of the course will be mentioned later.
In fact, in addition to language-independent programming (which you will read later), for C++, a specific language, to start programming with it, you only need to know some basic but important language knowledge (required) Read which books will be mentioned later) and the fact that there are many flaws and pitfalls in C++, and -
Recommendation 2: Develop the habit of accessing materials and documents at any time.
"Checking documents" can be said to be the most important ability (yes, ability) of a programmer; it is so important that there is a special abbreviation in English - RTFM. Why this ability is so important, the reason is simple: the knowledge of programming is too much. Not only is the amount of knowledge huge, but the details of knowledge are simply unparalleled in any discipline (just look for a framework library to look at its API documentation). Therefore, it is not only unrealistic to put such a huge amount of information in the mind, but it is also self-defeating. What you need is "meta-capacity", which is the ability to check documents - starting with the problems you are having, doing the right and reasonable analysis, predicting where the solution to the problem might be, finding information about the latter, reading Understand and apply.
Again, the same is true in C++. If you have this attitude from the very beginning of learning C++, then even if you are asked about a language detail when you are interviewing, you can confidently say that you don’t know the details. However, when you encounter the corresponding problem in the actual coding, you will definitely find the appropriate reference materials and solve the problem quickly (solving the problem is the ultimate goal). Of course, the bigger possibility is that you have already touched the 80% of the most common traps and tricks in the usual coding. Because you are using a practical and guiding way of learning, you need to learn. The traps and tricks are almost certainly in the common scene. It is more efficient to use a C++ "classic" to catch a C++ "fine study" method, because you have no practical experience, because you have no practical experience. It is likely that each of these techniques, each trap, will have the same probability of attack.
Why are C++ books on the market passionate about the details and techniques?
You opened a beer bottle with a tool that was used to open a beer bottle. Not only did you have a sense of accomplishment, but no one would think you were a cow. However, if you invent a way to open a beer bottle with two chopsticks, or if you just have a good tooth to open the bottle, it may be quite different. People will think that you are very good and powerful.
Fact 8: Everyone likes to dance with their ankles.
That is to say, if you use a tool that is natural for a purpose to do what he should do, no one will applaud, and you will not feel great. But if you combine new features with two tools that are not themselves for a certain purpose, you are an "innovator" (although perhaps there is a ready-made tool available).
And C++ is the soil of these "innovations", yes, I am talking about endless workarounds and idioms. But the problem is that these "innovations" are not innovation at all. What you must realize is that they are nothing more than a replacement solution that can't be tossed without a first-class solution. Yes, they can be called innovation to some extent, and even researching viable solutions is a very interesting thing in itself, but –
Fact 9: I know they are interesting, but in reality they are just patching solutions.
Yes, don't let go of these "innovation" schemes. The reason why you find it interesting is that when you are familiar with C++ to a certain extent, everything in C++, including defects, becomes a "established fact" for you, a background, a thing that you are used for (people are very Strongly adaptable). Therefore, when you find that there is a new possibility in this accustomed environment, you will certainly be happy. (For example, when I read Modern C++ Design, I once read from early to late, and didn’t have lunch. Eat), but actually? Other languages may have been supported by first-class, and other languages may not need this idiom at all, because they do not have these defects. In addition, from a practical point of view, more importantly, these "solutions" may not be used by your usual programming.
No, of course I am not saying that these patches are not important. As mentioned earlier, the cumbersome techniques in C++ are not unfounded, and there are always practical problems behind them. But the problem is that for our daily programming, these "real problems" are simply not able to beat eight. It is not necessary to charge 80% of the first time to put things that are used 20% of the time in your head. When you use it, you can check the documents or books.
Seeing this, another reason to shape the specific philosophy of mind in C++ must be known to you. In fact, this reason is really fundamental. One of the reasons mentioned earlier is made by the C++ book market (education), but why do people like to write these books? Further, why do people like to read these books? (I admit, I have read it with gusto.) The answer is simple: psychological. Everyone likes to dance with ankles (fact 8). Recognizing this is not to promote it, but only when we realize why we are going to delve into a bunch of patching solutions, we can really get rid of their attraction.
All in all, the complexity of C++ is only a necessary condition, not the root cause of the problem. The crux of the matter lies in the human mind. Everyone likes to dance with their ankles and thinks it is "innovation." Being aware of this can help us avoid taking unnecessary time with a wide variety of language details and techniques.
However, the complexity of C++ is always an unavoidable reality. There are a lot of pitfalls and pitfalls in C++, which leads to an amazing number of idioms and workarounds. Inadequate, pre-learning is a very bad practice. It is not only inefficient, but it is not necessary at all. It is a waste of life. Einstein once said, "I just want to know the design concept of 'he' (the universe), the others are the details." However, as other readers have pointed out, if there is no concept in advance of these details in C++, then if you encounter it in the actual code, you will become a headless fly, and you may not know where to go to RTFM. That's why so many C++ interviews take the trouble to ask some representative language details.
It’s not good to put the details in the head, but it’s not a good idea to know nothing about the details. So for C++ programmers, what kind of attitude and learning method should be used to deal with the complexity of C++? In fact, the answer is very simple. First of all, there are some important and necessary language details & features that need to be mastered. Then we only need to know where there are complexities (traps, defects) in C++, then when problems are encountered. Naturally, I know where to find the answer. Specific recommendations are given later.
C++ complexity classification
Originally, this section is intended to be a C++ complexity index. However, the complexity of C++ is too much. Secondly, there are already many materials on the Internet (for example, Bjarne Stroustrup's own C++ Technical FAQ is a good document). In most C++ books on the market, language details are kept incessant; therefore, we are not lacking in information, but lack a way to index such information, and a modular way of thinking to control these complexities.
For the above reasons, the complexity of C++ is not listed in detail here, but a classification standard is provided.
There are two classification methods for the complexity of C++. One is divided into non-essential complexity and essential complexity; non-essential complexity is divided into defects and traps. Another classification method is to classify by scene: the complexity under the library development scenario and the complexity of daily coding. From the perspective of practitioners engaged in everyday coding, the latter classification allows us to quickly grasp the complexity of 80% of the scene.
The twenty-eighth rule
The following is an explanation of this taxonomy by listing some common examples:
Complexity in 80% scenarios:
1. Resource management (the main source of C++ daily complexity): deep copy & shallow copy; four special member functions of the class; use STL; RAII idiom; smart pointer and so on.
2. Object lifetime: local & global object lifetime; temporary object destruction; object construction & destruction order, and so on.
3. Polymorphism
4. Overload resolution
5. Exceptions (unless you don't use exceptions): the stack-unwinding process; when an exception is thrown; at what abstract level an exception is thrown, and so on.
6. undefined&unspecified&implementation defines the difference between the three behaviors: i++ + ++i is undefined behavior (that is, "problem, bad behavior, theoretically anything can happen"); the order of evaluation of the parameters is Unspecified (unspecified - "you can't rely on a particular order, but its behavior is well defined"); when a double is converted to a float, if the value of the double variable cannot be accurately expressed in a float, then The choice of the next close discrete value or the last close discrete value is implementation defined (that is, "you can find the description in the implementation vendor's compiler documentation"). These issues can affect your ability to write portable code.
(Note: The above is just an incomplete list to demonstrate the meaning of this taxonomy - in fact, if we only consider the "complexity in 80% of the scenes", the burden of memory and learning will be greatly reduced.)
Complexity in 20% scenarios:
Object memory layout
2. Template: partial specialization; non-type template parameters; template parameter derivation rules; instantiation; two-stage name lookup; metaprogramming and so on.
3. Name Search & Binding Rules
4. Various defects and defect-derived workarounds (called "techniques" in C++): does not support concepts (boost.concept_check library); type-transparent typedefs (true-typedef idioms); weakly typed enumerations (Strong enumeration idiom); implicit bool conversion (safe-bool idiom); custom type does not support initialization list (boost.assign library); weak metaprogramming support (type-traits idiom; tag-dispatch idiom) ; boost.enable_if library; boost.static_assert library); right-valued defects (loki.mojo library); does not support a variable number of template parameter lists (type-list idioms); does not support native alignment specification.
(Note: The above is just an incomplete list. You will find that these details or techniques are rarely used in everyday programming, especially workarounds derived from various language defects, which constitute a huge long tail, whether in C++ or not. The books still account for a large proportion of the literature, the authors call them technology, but in fact most of these "technologies" are only needed in library development.)
Non-essential complexity & essential complexity
In addition, it is helpful to consider another classification, which is divided into non-essential complexity and essential complexity.
Non-essential complexity (incomplete list)
1. Defects (referring to problems that can be overcome, but the solution is awkward; C++'s book refers to workarounds that overcome defects as techniques, which I find very misleading): The examples have been listed in the previous section.
2. Trap (refers to an insurmountable problem, can only be carefully bypassed; if you fall into it, it means that you do not know this trap, then there is a great possibility that you do not know where to solve this problem): Generally speaking As a qualified programmer (whether or not a C++ programmer), the language trap in 80% of the scenes needs to be remembered. For example, deep copy & shallow copy; base class destructor should be virtual; default generated class member function; evaluation order & sequence point; class member initialization order & declaration order; resulting in non-portable code implementation related issues.
Essential complexity (not complete list)
Memory management
2. Object lifetime
3. Overload resolution
4. Name lookup
5. Template parameter derivation rules
6. Abnormal
7. OO(动æ€ï¼‰å’ŒGPï¼ˆé™æ€ï¼‰ä¸¤ç§èŒƒå¼çš„应用场景和交互
总而言之,这一节的目的是è¦å‘Šè¯‰ä½ 从一个较高的层次去把æ¡C++ä¸çš„夿‚æ€§ã€‚å…¶ä¸æœ€é‡è¦çš„ä¸€ä¸ªæŒ‡å¯¼æ€æƒ³å°±æ˜¯åœ¨å¦ä¹ çš„è¿‡ç¨‹ä¸æ³¨æ„ä½ æ£å¦ä¹ 的技术或细节到底是80%场景下的还是20%场景下的(一般æ¥è¯´ï¼Œè¯»å®Œä¸¤æœ¬ä¹¦â€”—åŽé¢ä¼šæåˆ°â€”—之åŽä½ 就能够很容易的对æ¤è¿›è¡Œåˆ¤æ–了),如果是20%场景下的(有大é‡è¿™ç±»å¤æ‚性,其ä¸å°¤æ•°å„ç§å„æ ·çš„workaroundsä¸ºå·¨ï¼‰ï¼Œé‚£ä¹ˆä¹Ÿè®¸æœ€å¥½çš„åšæ³•是åªè®°ä½ä¸€ä¸ªå¤§æ¦‚,ä¸åŽ»ä½œä»»ä½•æ·±ç©¶ã€‚æ¤å¤–,一般æ¥è¯´ï¼Œä¸ç®¡ä½¿ç”¨å“ªé—¨è¯è¨€ï¼Œè®¤è¯†è¯è¨€é™·é˜±å¯¹äºŽç¼–程æ¥è¯´éƒ½æ˜¯ä¸€ä¸ªå¿…è¦çš„æ¡ä»¶ï¼Œè¯è¨€é™·é˜±çš„ç‰¹ç‚¹æ˜¯å¦‚æžœä½ æŽ‰è¿›åŽ»äº†ï¼Œé‚£ä¹ˆå¾ˆå¤§å¯èƒ½æ„味ç€ä½ 本æ¥å°±ä¸çŸ¥é“这有个陷阱,åŽè€…很大å¯èƒ½æ„味ç€ä½ ä¸çŸ¥é“如何解决。
å¦ä¹ C++:实践者的方法
在上é¢å†™äº†é‚£ä¹ˆå¤šä¹‹åŽï¼Œå¦‚何å¦ä¹ C++è¿™ä¸ªé—®é¢˜çš„ç”æ¡ˆå…¶å®žå·²ç»å¾ˆæ˜Žæ˜¾äº†ã€‚æˆ‘ä»¬æ‰€æ¬ ç¼ºçš„æ˜¯ä¸€ä¸ªä¹¦å•。
第一本
å¦‚æžœä½ æ˜¯ä¸€ä¸ªC++程åºå‘˜ï¼Œé‚£ä¹ˆå¾ˆå¤§çš„å¯èƒ½æ€§ä½ 会需è¦ç”¨åˆ°åº•å±‚çŸ¥è¯†ï¼ˆç¡¬ä»¶å¹³å°æž¶æž„ã€ç¼“å˜ã€æŒ‡ä»¤æµæ°´çº¿ã€ç¡¬ä»¶ä¼˜åŒ–ã€å†…å˜ã€æ•´æ•°&浮点数è¿ç®—ç‰ï¼‰ï¼›è¿™æ˜¯å› 为两个主è¦åŽŸå› ï¼šä¸€ï¼Œäº†è§£åº•å±‚çŸ¥è¯†æœ‰åŠ©äºŽå†™å‡ºé«˜æ•ˆçš„ä»£ç 。二,C++è¿™æ ·çš„æŽ¥è¿‘ç¡¬ä»¶çš„è¯è¨€ä¸ºäº†é™ä½Žè¯è¨€æŠ½è±¡çš„æ•ˆçŽ‡æƒ©ç½šï¼Œåœ¨è¯è¨€è®¾è®¡ä¸Šä½œäº†å¾ˆå¤šæŠ˜è¡·ï¼Œæ¯”如内建的有é™ç²¾åº¦æ•´åž‹å’Œæµ®ç‚¹åž‹ï¼Œæ¯”如指针。这就æ„味ç€ï¼Œç”¨è¿™ç±»è¯è¨€ç¼–程容易掉进Joelæ‰€è°“çš„â€œæŠ½è±¡æ¼æ´žâ€ï¼Œéœ€è¦ä½ 在è¯è¨€æä¾›çš„æŠ½è±¡å±‚é¢ä¹‹ä¸‹åŽ»æ€è€ƒå¹¶è§£å†³é‡åˆ°çš„é—®é¢˜ï¼Œæ¤æ—¶çš„åº•å±‚çŸ¥è¯†ä¾¿èƒ½å¸®ä¸Šå¤§å¿™ã€‚å› æ¤ï¼Œä¸€æœ¬ä»Žç¨‹åºå‘˜ï¼ˆè€Œä¸æ˜¯ç”µå工程师)的角度去介ç»åº•层知识的书会éžå¸¸æœ‰å¸®åŠ©â€”â€”è¿™å°±æ˜¯æŽ¨è《Computer Systems:A Programmers Perspective》(以下简称CSAPP)(ä¸è¯‘本《深入ç†è§£è®¡ç®—æœºç³»ç»Ÿã€‹ï¼‰çš„åŽŸå› ã€‚
第三本(是的,第三本)
å¦ä¸€æ–¹é¢ï¼ŒC++ä¸åŒäºŽC的一个关键地方就在于,C++在完全ä¿ç•™æœ‰C的高效的基础上,增添了抽象机制。而所谓的“现代C++é£Žæ ¼â€ä¾¿æ˜¯å€¡å¯¼æ£ç¡®åˆ©ç”¨C++的抽象机制和这些机制构建出æ¥çš„现代C++库(以STL为代表)的,Bjarne也很早就倡导将C++当作一门ä¸åŒäºŽC的新è¯è¨€æ¥å¦ä¹ (就拿内å˜ç®¡ç†æ¥è¯´ï¼Œä½¿ç”¨çް代C++的内å˜ç®¡ç†æŠ€æœ¯ï¼Œå‡ 乎å¯ä»¥å®Œå…¨é¿å…newå’Œdeleteï¼‰ï¼Œå› æ¤ï¼Œä¸€æœ¬ä»Žè¿™ä¸ªæ€è·¯æ¥ä»‹ç»C++çš„å…¥é—¨ä¹¦ç±æ˜¯éžå¸¸å¿…è¦çš„——这就是推è《Accelerated C++》
SC/APC Fiber Optic Fast Connector
Sc/Apc Fiber Optic Fast Connector,Fiber Optic Adaptor Fast Connector,Fiber Quick Connect Kit,Sc Fiber Optic Fast Connector
Ningbo Fengwei Communication Technology Co., Ltd , https://www.fengweicommunication.com