Expose the true face of C + +! Netizen: This is the real programming language boss “C + +”!

Time:2020-12-3

C + + language is a mixed language (rising in 1980s). It retains all the advantages of C language and adds object-oriented programming mechanism. We can regard C + + language as an improvement and extension of C language.

The C + + language based on C language is compatible with C language, so the program written in C language can be used in C + + without any change. Compared with C language, C + + language expands the function of C language and adds object-oriented programming mechanism. The main purpose of introducing object-oriented programming mechanism is to improve the development efficiency.

This is the real c + +!

 

✪ many of the early C + + work is to strengthen and purify C, and fully compatible with C as a mandatory requirement. Many improvements in C89 and C99 are introduced from C + +.

It can be seen that Stroustrup has made great contribution to C language. Today, no matter what you think of C + +, C + + does extend and evolve C, and has a profound impact on C.

 

✪in the process of C + + compatible with C, we have encountered a lot of design and implementation problems; and the conservative K & R C programmer criticized stroustrip.

Many people say that the nightmare of C + + is to be compatible with C, which is not unreasonable (Java does a lot more than C + +), but this is not considered by Stroustrup. Stroustrup makes every effort to be compatible with C, on the other hand, it is trying to optimize C.

 

✪ the biggest competitor of C + + is C. his purpose is to do what C can do, and C + + must do it better.

Do you think it has been done? How many have done it and how many haven’t?

 

✪ for programmers who focus on both operational efficiency and development efficiency, Stroustrup repeatedly emphasizes that the goal of C + + is to “strengthen the organization of programs while ensuring the efficiency is equivalent to that of C language; C + + is shorter and smaller for programs with the same function”, which is the core idea of shallow encapsulation. It’s not OO of transition design.

 

✪ C + + evolution and design gives many examples in response to those who criticize that C + + has performance problems.

In the second version of C + +, virtual function mechanism is introduced, which is the biggest bottleneck of C + + efficiency. However, I personally think that virtual function is one more addition operation, but it can make our code better organized, which greatly increases the program reading and reduces the maintenance cost.

(Note: Lippman’s “exploring the C + + object model” also shows that C + + programs are not inferior to C programs. Bruce’s think in C + + also says that the performance difference between C + + and C is only 5%)

 

✪ this book also tells about some painful trade-offs of C + +. The most impressive one is multiple inheritance, which is proposed, removed, and then put forward. Many times, we constantly debate and choose between gains and losses.

The biggest gain from this process is – a) for any kind of design, there are both good and bad, and only one side can be stressed. B) it is not a good mentality to criticize completely negative, and a good attitude should be constructive criticism.

 

Compared with the virtual machine language, C / C + + compiles the source program into the machine code of the target platform in static form. Generally speaking, C / C + + programs have the most abundant optimizations when compiling and linking, the fastest at startup, and the least extra memory overhead at runtime.

The dynamic detection of C + + is also reduced. In addition, the running behavior of C / C + + is deterministic, and there will be no additional behavior or uncertain delay caused by garbage collection (GC). Moreover, the layout of C / C + + data structure in memory is also determined.

Sometimes, some functions of C + + can make the program performance better than C, among which inline and template are the most prominent. These two functions make the sort() of C + + standard library usually much faster than qsort() of C standard library (C can use macro or manual coding to solve this problem).

On the other hand, C / C + + can directly map machine code, and there is no other layer of intermediate language between them, so it can do the bottom level optimization, such as using internal functions and embedded assembly language. However, many of the performance advantages of C + + are not free lunches. The cost includes longer compile link time and error prone, which increases development time and cost.

This is the real c + +!

 

The most important thing to learn programming is to write code, read code written by others, and write code again. No matter how many books you read, if you don’t write code, you still can’t program.

But you should also pay attention to the method of writing code step by step. You can’t just learn grammar for a few days and just want to write an operating system or something. Setting up such unrealistic goals will only severely damage your self-confidence and lose yourself.

Expose the true face of C + +! Netizen: This is the real programming language boss

If you want to learn C + + programming——Programming learning exchange Club[worth entering]!

It involves:C language, C + +, windows programming, network programming, QT interface development, Linux programming, game programming, hackers, etc

Expose the true face of C + +! Netizen: This is the real programming language boss

 

Introduction to programmer programming:

Expose the true face of C + +! Netizen: This is the real programming language boss

 

Programmers recommend learning books:

Expose the true face of C + +! Netizen: This is the real programming language boss

 

An active, high-level, high-level programmer programming learning hall; programming introduction is only by-pass, the improvement of thinking is valuable!

Recommended Today

Summary of recent use of gin

Recently, a new project is developed by using gin. Some problems are encountered in the process. To sum up, as a note, I hope it can help you. Cross domain problems Middleware: func Cors() gin.HandlerFunc { return func(c *gin.Context) { //Here you can use * or the domain name you specify c.Header(“Access-Control-Allow-Origin”, “*”) //Allow header […]