作為舉世公認(rèn)的最杰出的程序員,Linus Torvald和Richard Stallman任何關(guān)于編程和編程語言的見解都值得所有人尊重。關(guān)于C++, 他們?cè)?jīng)說了什么?
2007年Linus在郵件列表里評(píng)論道,原文見http://harmful.cat-v.org/software/c++/linus
C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C. In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with. C++ leads to really really bad design choices.
You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes: - infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full of BS that it's not even funny) - inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app. In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap. So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake.
歸納起來就是兩句話。
Linus認(rèn)為在他的項(xiàng)目中(例如Linux內(nèi)核項(xiàng)目和git項(xiàng)目)使用C,而不是C+,在于提高開發(fā)人員的門檻,將水平很菜的程序員擋在門外。
他認(rèn)為,要用好C++,編寫出高效的,可移植的,高的代碼,必須保持克制,不濫用C++。然而,實(shí)際上C++里那些個(gè)好的,完全可以用C來代替。
因此,他認(rèn)為C足夠好,用C++來開發(fā)他的項(xiàng)目是純粹添亂,自找麻煩。
在上世紀(jì)九十年代Richard Stallman是這么評(píng)論C++的。原文見https://stallman.org/stallman-computing.html
I find C++ quite ugly.
The flaws of C++, as I recall from when I studied the matter around 1990, include syntax and semantics. As for syntax, its grammar is ambiguous, and it is gratuitously incompatible with C, which blocks the smooth upgrade path from C to C++.
As for semantics, the abstract object facility of C++ is designed around the case where the real type of an object is known at compile time. However, in that case, abstract objects are equivalent to a naming convention for functions to call. The case where abstract objects add real power to a language is when the type is not known until run time. C++ does handle that, but it seems to be an afterthought, a poor relation.
I suspect that I would find plenty of ugliness in the template library, but I don't know. That was added to C++ after I studied it.
Linus站在他領(lǐng)導(dǎo)的項(xiàng)目角度評(píng)論C++。假如你從事的項(xiàng)目與他的項(xiàng)目相同或者相似,那么Linus的見解值得借鑒和參考。
Richard Stallman是在C++早期階段評(píng)價(jià)過C++,隨著C++的發(fā)展,三十年過去了,時(shí)過境遷,讓Richard的話可能失去了時(shí)效性。
喜歡就點(diǎn)贊。 更多精彩,請(qǐng)關(guān)注我
今日頭條號(hào)/西瓜視頻/抖音:IT之州