作为举世公认的最杰出的程序员,Linus Torvald和Richard Stallman任何关于编程和编程语言的见解都值得所有人尊重。关于C++, 他们曾经说了什么?
2007年Linus在邮件列表里评论道,原文见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认为在他的项目中(例如Linux内核项目和git项目)使用C,而不是C+,在于提高开发人员的门槛,将水平很菜的程序员挡在门外。
他认为,要用好C++,编写出高效的,可移植的,高的代码,必须保持克制,不滥用C++。然而,实际上C++里那些个好的,完全可以用C来代替。
因此,他认为C足够好,用C++来开发他的项目是纯粹添乱,自找麻烦。
在上世纪九十年代Richard Stallman是这么评论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站在他领导的项目角度评论C++。假如你从事的项目与他的项目相同或者相似,那么Linus的见解值得借鉴和参考。
Richard Stallman是在C++早期阶段评价过C++,随着C++的发展,三十年过去了,时过境迁,让Richard的话可能失去了时效性。
喜欢就点赞。 更多精彩,请关注我
今日头条号/西瓜视频/抖音:IT之州
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有