Cultivatar Thinking on C ++ Complexity

xiaoxiao2021-03-06  117

This paper we wrote it before the month, did not undertake the rotation and paragraph of paramount, and the view is not scrutinized. for reference only. -------------------------------------------------- ---------------------------------------- C surface dilemma comes from two aspects, one is The development efficiency is low, but it is easy to make mistakes, and the maintenance is difficult. The two are all likelihood, essence is one - excessive complex. Or some people say that the key flaws of C are uniform complete class library support, and Bjarne Stroustrup emphasizes this factor. However, this is actually just a result, not the reason. It is because the language is too complex, and it is not possible to develop high quality large-one libraries in the validity period.

C is complex, not the huge volume of its bulk. Complex is a description of the disorder of structural confusion, large scale, and the structure is not necessarily complicated.

C is complicated, and it is not as many as many people who are complicated with a number of programming paradigms. In fact, there are at least 2-3 models of modern practical programming language to go to the Championship. The paradigm is more than C in new dynamic languages ​​such as paradigm, Python and Ruby, etc., but they are highly known as simple and development efficiency.

C complex roots lies in three constraints: complete compatibility with C, static type check, and highest performance. Under the three contracts, C failed to improve the support for object-oriented ideas, failed to build strong dynamic capabilities, so that C has essential defects on the single item of OO. In fact, the process of C , the OB model is quite mature and stable, and the generic model, in addition to the syntax, there is no big problem except for the geometry ugly. The defect is reflected in the implementation of the OO model, and therefore interferes with the integrity of other paradigms. However, OO's defects are not paranoid for the designer, why is the reason for the three constraints. If you adhere to the three contracts, even if you re-design it, the results are not far from today. Stroustrup said in a variety of occasions, there is no big regret for C design, meaning this. Mr. Houjie said in early 2001, C did not have Java in OO. At that time, the experience was not deep, and it was not a big unified single class library to make the design more flexible. Beyond, now it seems that even not impossible, this road will inevitably be difficult, success or failure is difficult to expect. And because all of the above factors, the construction of the C basic class library can only be stopped at a very low height, because it will face a heavy dilemma and endless debate. The C standard library is actually a quite distant very basic library applied, with the main part of only two SYSTEM and UTIL two packages in Java. And C would rather stop in such a low level, nor will it be willing to give up any of the three bindings. This persistence makes the high-level standard library facilities are extremely difficult, and it is not easy to use. The ease of use of partial components in the BOOST library is poor.

The complex syntax of the template has a direct relationship with the three contracts. Another reason is that BJarne is simply a target when the invention template. When C # and Java joins the generic mechanism, there is no inheritance of C best experience, but inherits the worst part of the C template mechanism, the grammar, in the short term, and lost a good opportunity for reform. In the long run, it will become a cumbersome.

The imperfect abnormal mechanism is the designed design in the case of wood.

Multiple paradigms in C are parallel, and it is some of the most complex problems. So that Doug Lea recommends only one paradigm in a project. But this is still just a look. In the final analysis, it is due to the defect of OO, making it difficult to play with other paradigms. Therefore, since I have accepted Doug Lea Thought, my C (and even other modern languages, especially Python and other multi-model languages) are: 1. First selected a way of thinking (ie, model), as much as possible A way of thinking to solve problems; 2. If there is a problem with other ways to do other ways, after careful consideration, another style can be packed to be partial, solve local problems. But the entire system appears to be uniform on a level. General C development should be based on OB. Unless there is a huge and mature OO library similar to MFC, it should not be rained to use OO style as a whole. 3. Mixing in a variety of styles unless there is a solution that has been fully discussed and verified (ie, ripe mode), a large advantage that the single style cannot be provided, otherwise it should be avoided. Of course encourages exploration in research, but practice is another thing. C can get rid of C at C , then simplify template syntax, improve the abnormal model, accept the optional GC, establish a complete single class library, and pay the performance of the performance, the overall upgrade is implemented. However, C chose another road, three contracts insisted on, stick to the system level, to replace C as its own responsibility. It is a blessing is a disaster, and it is difficult to discriminate. If you choose to upgrade in the early 1990s, winning Java in the cradle, the defeat is not guaranteed. However, the victory should be slightly larger with C . Today, it seems that Calficit C is already possible.

In 1994, the STL delay standard was held for four years. Nowadays, I will also have a conference. Do not say that the gold timing is not said, the STL is typed in one, and the library design is changed. However, in solving the application problem, the generic OO is more expensive, and it is difficult to apply difficult.

In short, the three constraints of C are both elements of their rise, but also their origin of fading, and it is an important cornerstone that is inseparable today. It is not a merit, it is difficult to cover it.

Supplement: The significance of C / CLi on October 20, 2004, is not that C will re-win the opportunity to win Java or C #, but in consolidating C as a status of system language on the .NET platform. From this, the development of C / CLi is indeed, such as Stan Lippman, is a continuation of C consistent development ideas. The three bindings have already given up, but their spiritual substance is still in, and the attack will be realistic. In the future, it will serve as the only strongest system language on the .NET and lives for a long time. C / CLI is never simple, but in most, it can be more simple than traditional C performance. This is what Andrew Koenig is said, and it is simple to achieve complicated.

C # and Java's prosperity, depending on how people have persisted more about the middle-level language of the big one. These two languages ​​are not most preferred in system development or in application development. At present, there are some signs of C #, introducing some dynamic language features such as cmdlet, and strengthen system programming capabilities, and want to go up and down. This is a non-return, it will make C # become more complex.

转载请注明原文地址:https://www.9cbs.com/read-102032.html

New Post(0)