Reading Notes (4)

Source: Internet
Author: User
<C ++ design and evolution> original text excerpt and self-translation and Annotation
Article 1:

1. even though support of concurrency and simula-style simulations was a primary aim of C with classes, the language contained no primitives for expressing concurrency ;................

I considered it crucial -- as I still do -- that more than one notion of concurrency shoshould be expressible in the language. there are mandatory applications for which support for concurrency is essential, but there is no one dominant model for concurrency support; thus, when
Support is needed, it shocould be provided through a library or a special-purpose extension so that a Participant Form of concurrency support does not preclude other forms.

Although the initial purpose of designing C with classes is to support concurrency and imitate the simula style, the class with C does not include the support for the primitive to implement concurrency. I think this idea is crucial (I still think so): A language should support multiple concurrency concepts. supporting concurrency is essential for many applications, but it does not provide a dominant concurrency support in languages. we should provide a class library or a specific extension to support a certain concurrency, so that the support for a special form of concurrency will not lead to rejection of other forms of concurrency.

 

Note:

C ++ was called class C when it first came out. It was designed not to be a brand new language, but to be used as an auxiliary tool to expand C functions. however, some design ideas in C with classes continue in C ++. I have mentioned concurrency many times. I think the current multi-thread should be a kind of concurrency. with the popularization of multi-core processors, concurrency becomes an increasingly important concept. the previous multi-thread concurrency is just an illusion on a CPU. In fact, the concurrency is simulated by dividing the CPU time segment. there are multiple CPUs in multiple cores, that is, real concurrency.

As mentioned above, C ++ does not support concurrent primitives. What is primitive support? This is a simple understanding. for example, C does not have a type called string, but uses a char array to simulate the string. Therefore, C does not support the String Primitive. C # has a basic type such as string, that is, primitive support.

In fact, it is advantageous and harmful to not provide primitive support for a specific function. if your language is a common programming language and you want to apply it to as many fields as possible, you need to do less primitive support. however, if you only want to target a specific domain, you must provide many primitive support for this domain. for example, MATLAB provides a lot of primitive support for mathematics. you can easily use matrices and so on. so if you want to develop a mathematical research, Matlab is definitely more advantageous than C, C ++. in addition, LISP focuses on artificial intelligence at the beginning of design. Therefore, it has a unique advantage over other languages.

In addition, stroustrup also mentions that class libraries should be used to support some form of concurrency. so many times we need to implement some functions, and the class library is also very important. The class library helps us do a lot of work, we just need to use it. therefore, when selecting a program language, you must check whether there are many third-party class libraries related to the language, except for whether the language is well designed and the compiler is good.

 

Article 2:

2. c With classes cocould be used for whatever C cocould be used. this implied that in addition to matching C in efficiency, c With classes cocould not provide benefits at the expense of removing "dangerous" or "ugly" Features of C ...........

C With classes should be applicable to all fields of C. this means that C with classes should achieve the same efficiency as C, and some "dangerous" or "ugly" Features in C should not be removed, because removing these features will lead to performance loss.

 

Note:

We can see that C ++ almost retains all the features in C. What features mentioned above are "dangerous" or "ugly" in C? In my opinion, various numeric types can be implicitly converted to one another. for example, unsigned int, long, float, and double can be implicitly converted to each other. the result of such a conversion is sometimes only different in precision. If there is a signed or unsigned result, it may be completely incorrect. in fact, you can perform some checks at runtime. If there is a loss of precision and errors in the conversion, it may be treated as an error. although it is much safer to do so, additional checks will certainly result in a certain amount of space and time efficiency. therefore, C ++ has not made any improvement in the value type check. in C #, we checked the value type conversion. implicit conversion is not allowed in Case of Loss of precision.

So when we use some advanced languages, it seems that some areas are safe and convenient. but in fact, it is often at the cost of a part of efficiency. as computer hardware resources become cheaper, sometimes such performance costs can be borne. however, for the sake of universality, we cannot afford this price. for example, we need to use embedded systems with insufficient resources.

 

 

Article 3:

3. in C with classes (as in C ++), a class is a type. this is a key notion in C ++. when class means user_defined type in C ++, why didn't I call it type? I chose class primarily because I dislike inventing new terminology and found Simula's quite adequate in most
Cases.

In C with classes (the same in C ++), a class is a type. this is a key concept in C ++. so since the class in C ++ is a user-defined type, why not call the class type directly? One of the main reasons why I chose class as a keyword is that I hate to invent new terms, and the other is that the class In simula is suitable for most scenarios.

 

Note:

In the simula language, class has been used as a keyword. Although we often mention type, it is not used as a keyword. stroustrup says that he didn't introduce type as a keyword because he didn't want to invent new terms. I think this idea is more pragmatic and very considerate for users. people are always lazy and want to remember less if they can remember less. in addition, there is a rejection psychology for some completely unfamiliar transactions (of course, the human psychology is actually complicated, and the rejection psychology and curiosity for unfamiliar things are close to the coexistence of psychology ). therefore, many c ++ students are new to MFC and will be disgusted when encountering a pile of unfamiliar keywords and terms. it may take a long time to get used to it. in addition, we will find that when talking about something more professional, people with low levels are often full of obscure terms. those masters can be easy-to-understand, without obscure terms.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.