Discussions about C and C ++

Source: Internet
Author: User
Tags iso documentation

Discussions about C and C ++

Zhihu once had a discussion about C and C ++ languages.

Yutiansheng
The open-source community has never been very familiar with C ++. Richard Stallman, the founder of the Free Software Foundation, believes that C ++ has syntax ambiguity, which is unnecessary and trivial and may be incompatible with C, and it does not bring any great benefits.
Having ambiguous grammar and "gratuitous, trivial, incompatibilities with C (...) That are of no greatbenefit"
Linus Torvalds also said that C ++ is a terrible language, and a large group of programmers who use it many times make it even more terrible.
"C ++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it"
The C ++ syntax is good, but it is too complicated. Especially when the inheritance of these features is messy, the advantages of object-oriented will be completely lost in front of the Code with poor quality, sometimes it makes the code very confusing.
C ++, which is prone to misuse of syntax features, may become very bad. Coupled with the resistance of the two great gods, it is of course not popular in the Open Source camp.

Levski
I think @ Yu Tiansheng is already complete. However, I think your reply is still one-sided. In addition, the firepower of some replies is mainly focused on the evaluation of these two languages, and the LZ question is not answered.

First of all, from the open-source community style, "a large market" I think is a more appropriate metaphor, a noisy place, each project can decide the development method of its own project. Currently, most open-source projects that depend on each other are developed on the Linux platform. Therefore, it is easy to come up with technical solutions provided by the Linux platform.

Second, the Linux community has a lot of concerns about C ++ because leading figures in the Linux community have concerns about C ++ (not to mention whether this concern is correct.

Then, can the LZ problem be converted into the concerns of the open-source community on C ++? My opinion is both correct and wrong. The reason lies in the governance of elites.

Thanks to the Linux kernel and the core GNU software, developers are one of the best technical elites. Therefore, their product goals are slightly different from those developed by third-party companies based on the Linux platform. Elites, including Linus Torvalds, are afraid to "Destroy" an excellent work with bad code (and of course there are other factors ).

On the other hand, some software that is relatively successful in business does not over-emphasize the technical purity, but is more oriented to commercial interests, I think their success is largely due to their deep understanding that human thinking can easily break down big problems, but it is difficult to combine small solutions into big solutions. In this regard, C ++ should be more advantageous than C, and reduce the complexity of each part of the product through interfaces and encapsulation, which not only makes it easier for developers to develop, it also makes it easier for demand analysis and design to be close to the user's actual usage, without worrying too much about whether the implementation form can be carried.

In short, the bigger difference between the two languages lies in the design philosophy. It is precisely because of this philosophical disapproval that open-source projects use more C rather than C ++.

Li Yun
In chapter 2 of Expert C Programming, this is not a Bug, but a language feature:

It (C ++) has no improvement on some of the most basic problems in the C language, and it is the most important extension (class) for the C language) it is built on the fragile C-type model.

Chapter 4 "you know C, so in C ++, there is another article:

A programming language has a feature called orthogonality ). It refers to the degree to which different features follow the same basic principle (that is, learning a feature helps to learn other features ). For example, in Ada, a programmer can apply this knowledge to generic packages once he understands how package works. Unfortunately, many of the features in C ++ are non-orthogonal. A certain feature proficient in C ++ does not give you any clues or inspire you with an idea model suitable for other features. Most programmers choose to use only a simple subset of C ++.

Vczh
As a model, STL is not read by people.
C language in the C ++ coat
Java with a C ++ coat
It won't be normal for you to learn how to step on the door. This is not a good question for C and C ++. It is caused by the misunderstanding of C ++. When using C ++, do not use the C part if your level is low. All these problems are caused by the weakness of human will.

Wilson Xu

From the Github language ranking (https://github.com/languages), C is nearly twice as much as C ++.
Reason: For object-oriented programming languages, in addition to C ++, there are many better options, such as Ruby, Python, PHP, and Java (all ranked earlier than C ++). On the contrary, there are not many substitutes for C.

Bai shunlong
1. for historical reasons, C has a long history and many basic projects. Many scalpers in their 40 s are mostly used in C.
2 C ++ is a pioneer in experimental nature. Many things are widely used in C ++ for promotion, object-oriented, generic, and others. In addition, it inherits some bad things of C, this results in bloated and trivial, easy to use, difficult to generate high-quality code, unstable standards, and better support for compilers later.
3. Linus is right. The key is design. If some ideas of the design model are used for reference, C can be well written. If you get used to it, development efficiency may not be lower than C ++.
4 modern software design focuses on modular design. The division of labor between modules is good. The entire project does not need to use the same language, and the living space of C ++ is compressed a lot.
5 In fact, C ++ is widely used in some large projects, such as symbian, windows, llvm, zeromq, mongodb, ecos, chrome, ace, qt, when flash needs to be object-oriented, it is still a bit cool to use C. You can compare the C code in Gtk. Google and microsoft like c ++ very much
6 C ++ is easy to learn and learn, it is easy to tangle with language details, and forget the project.
7 C ++ is still very promising, and some must use native code. If it is not a master of C, it is still fast to use C ++.
8. I still forgot one piece. C language is defined by a person from the very beginning, and the Standards Board just patches a little. C ++ is the result of the Commission's compromise (commercial politics and technology), so it is chaotic and the standard-making process is slow. It comes from different ideas and does not have a strong consistent style. However, C ++ is driven by requirements, so it is still in line with the development needs.

Dion
(1) C ++ has many more features than C, making it easy to write code in C ++.
In terms of style, programmers who love C may not like it.

(2) compatibility.
Although C ++ is compatible with C in most cases, in some cases, it still has to use code such as extern C.

(3) I still think C ++ is much better than C, if you can control it well.
C ++ is also constantly improving (ANSI C99, C ++ 0x), and Boost has been available for a long time.
The C ++ master Bjarne Stroustrup has answered many people's questions, that is, "C ++ has too many features and is very bloated. Will you consider cutting down some features ". The answer is "no, whether it is exceptions, multi-inheritance, or RTTI ".
The reason is simple. If we say that multiple inheritance poses a problem, isn't the C pointer? Or that sentence, as long as you can control it well!

Bill Cheng
Personally, as a C ++ programmer, I will always be put down by C programmers, so open-source software is something that proves the honor of programmers, how can we make those arrogant people look down and use C ++ ......
Speaking of this, I bowed my head and learned from C ++ to JAVA and then to OB-C ...... More and more despised by peers ......

Ren Wei
I think it is promotion, and the acceptance of cben is better. All kinds of compilers can be compiled, any project can be used for reference, and C is easier to maintain. C is the first choice. Not only must C be preferred, but Clean-C may be required.
I think it's a promotional consideration to completely defeat linus and bearded man.

Lufei
As an open-source project, unlike a closed project, we should support more platforms as much as possible, and do not specify too many requirements for the development environment. C language is relatively simple and the compiler is stable and reliable. C ++ has a standard, but in practice, the implementations of each compiler deviate from the standard to varying degrees. This difference is annoying and brings a lot of trouble to the project. Using pure C instead of C ++ is a reasonable choice.

In addition, many open-source projects are basic class libraries, while C ++ lacks unified and stable binary interfaces on many platforms and cannot achieve binary reuse. (Unfortunately, a well-known open-source C ++ project like Boost is notorious for not respecting the Stability of binary interfaces .) Therefore, from the perspective of saving Compilation Time and environmental protection for users, it is reasonable to use pure C rather than C ++ for open-source projects.

Snow
The C ++ compiler has done a lot of extra work, such as unqualified programmers and hiding many bugs.

Anonymous user
C ++ is too complex, and most developers cannot fully master all the features of c ++ (600 pages of c ++ iso documentation have been read by you? Do you understand boost ?) Another problem with c ++ is that many programmers, including me, are using some features of the language, which leads to poor design. It is very difficult to modify it at the end. A cow said that c ++ is a mountain, the largest Sheshan in the world. I think this is why. In short, c ++ is easy to write complex, obscure, and difficult to modify code, which is not a c ++ error. But it is easy to happen in c ++. This is for iq190.
The language used by the above people, but too many iq70 people are using it, so the great bulls are not using it.

Min Xiaofeng
C ++ is too complicated, and the libraries written in c ++ are also very complicated. For example, stl and boost are not convenient for debugging. Therefore, c ++ is not clear, simple, and direct.

Song yewen
Compared with C ++, C ++ is simple, fast, and flexible. C ++ is complicated to exceed the control of most elite programmers, for them, using C can also achieve elegant inheritance, encapsulation and polymorphism. C ++ focuses on testing a person's architecture capabilities. This kind of ability has high requirements on programmers. If you are careless, it will hurt yourself. It is better to use C for perfection.

Zhenghui zhou
Shouldn't the primary cause of the answer be code accumulation/continuation? Why do people focus on comparing language features? Even if many of them have a good understanding of the complex language features, are there any projects/code that can be shared or reused.
Obviously, the open-source ancestor GNU (Gnu's Not Unix) was born out of Unix culture. C language was also widely accepted at that time, and its compatibility was also the best, using c and continuing the mature experience and code of c is the most natural thing. Almost all popular linux environments are built on this basis. If there is not enough necessity to change development tools, this inertia will last for a long time. (In fact, it is gradually changing. For example, gcc is converted to c ++ for development)
Anyone who carefully examines and studies open-source projects, or even just the GNU project itself, will find that they contain a huge treasure. In fact, everyone who has come from the Microsoft/standalone era is curious about the source code project that is suddenly exposed to the network (Fidonet/Internet, it seems that the treasure is suddenly discovered and cannot be mined.
C ++ and subsequent projects do provide more features to facilitate code writing, however, because the currently used Feng's computer architecture and the underlying operating systems are Unix-like, these features can all be implemented through the C-feng's assembly language, which is occasionally cumbersome, this status quo remains unchanged for the moment, at least before the amount of automatically generated code occupies a certain proportion.
From the perspective of Project precipitation, a language with at least abstraction and sufficient underlying support is the most suitable for open-source projects that need to be accepted and widely spread by the public. Although there are many similar projects in almost all popular languages at the moment, if a filter is made based on a certain quality/value/universal threshold value, c-based projects may have the highest probability of survival. The more trendy and advanced it is, if it is not just a toy for practice, or it is often limited to a narrow application scenario.
So some advanced things can indeed improve the development efficiency of a specific project, but the most advanced ones are those that do what you want, and the things that can be used to reuse those accumulated and accumulated will not change too much. People often find that the key to gaining popularity when advanced things are discovered is the extent to which they have accumulated, in fact, each accumulation process may be just a re-manufacturing process, although these newly created wheels may look more beautiful and smooth.

Wang Yu
It's not that complicated. It's just that c has been around for a long time. c itself is a good language, so it has been around until now. There is no reason to change the language for projects in the old age, but if you look at it far away, the open-source projects born in the Internet age basically use emerging languages. If high performance is required, c ++ is one of the few choices. In fact, c ++ 11 should not be compared with the old c ++.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!
I think this topic is a bit old. The emergence of C ++ 11 has revived C ++, and the ranking in the last two years is also good. It is true that C ++ is dangerous, but something is done by humans.
See the figure below:

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.