The father of Linux is not rough-CvsC ++

Source: Internet
Author: User
The father of Linux is not rough-CvsC ++-general Linux technology-Linux programming and kernel information. The following is a detailed description. Linus Torvalds tried to use C ++ to develop the Linux kernel more than a decade ago. due to various reasons, it quickly failed. Since then, he has expressed dissatisfaction with C ++ from time to time. The incident recorded on Liu Jiang's blog was only the last one. Despite the fierce rhetoric, the words are not rough.

Today, in general, C and C ++ are mainly used for system-level software development. Specifically, the C/C ++ write platform, tool, and basic library support high-level languages to complete application logic. In an article about programming language development published by Microsoft architects in programmer magazine in September, Brian Beckman bluntly said, C ++ is mainly used to develop other languages. This is one-sided. If it is changed to "C ++ language, which is mainly used to support other languages", then it is generally correct.

When developing system software, it is important to understand how the system operates. The beautiful abstract techniques and advanced features are secondary.

There is an interesting phenomenon. Many experienced system software engineers have returned to C after using C ++ for a while. At this level, the advantages of C ++ for C are not prominent. Those advanced abstract structures are often unnecessary. Rather, the improvement of the abstract level makes it difficult for developers to figure out what actually happens below. Therefore, many veterans actually think that the C language is more controllable and more handy. A real C language expert is familiar with both the language and compiler. Basically, when writing C, I already know what the compilation code will look like after Compiler optimization, you can even change the C code to guide the compiler to produce the optimal machine code. C ++ has many mechanisms, many of which are prepared to meet the needs of high-level applications and frameworks. At this level, the clarity is sacrificed. Most of the time, what will happen behind a simple statement, even a veteran cannot tell. For example:

Std: string s ("Linux Torvalds ");
Std: string scopy = s;

The above Code creates two copies of strings with the same content, but no one can clearly describe what is happening in the background without learning more information, different STL has different implementation methods for string, so the performance of copy assignment is also different. Some may be simply copying string objects, and some may have the ref-counting mechanism, you need to create an object, set the object value, and increase the reference count. Some do not consider thread security, some consider thread security, and you have to lock and unlock. Sorry, there are also many ways to unlock. When creating a new string object, you sometimes need to call the memory distributor, and the implementation of this item is varied. Some directly use new char [], and some apply from the built-in memory pool, is memeory pool thread-safe? Sorry, this may involve the issue of adding and unlocking again. Will the memeory pool be full? Do you want to call new/malloc next time to apply for a new memory block? In short, there are too many complex things to follow, and there is not enough skill to understand the platform deeply. It is difficult to say a word about it.

The same is true for a string, not to mention other advanced features. Therefore, it is understandable that many people would rather bother than use C ++.

Personally, I am willing to use C ++, especially when I write realloc again and again in C, I think of string: operator + = () benefits. STL gave me a deep impression. When I write an algorithm program, I feel uncomfortable without using STL. A transform can solve the problem and I have to use a for loop, this makes me feel uncomfortable. In general, I still use C ++ to solve a problem. For me, Torvalds is actually very pertinent. Even with C ++, we should try our best to figure out what happened behind it, in this way, you can be sure when writing a low-level program. If you are designing an application-level program, try not to use C/C ++, and forget the underlying things. It is the right way to concentrate on designing the application layer.

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.