首页 > 应用开发 > IT综合 > 对c/c++之争的看法
最近的c/c++之争
Linux之父Linus Torvalds最近对c++进行了前所未有的炮轰,原文如下:
From: Linus Torvalds
torvalds
Subject: Re: [RFC] Convert builin-mailinfo.c to use The Better String
Library.
Newsgroups: gmane.comp.version-control.git
Date: 2007-09-06 17:50:28 GMT (1 week, 12 hours and 54 minutes ago)
On Wed, 5 Sep 2007, Dmitry Kakurin wrote:
>
> When I first looked at Git source code two things struck me as odd:
> 1. Pure C as opposed to C++. No
idea why. Please don't talk about portability,
> it's BS.
*YOU* are full of bullshit.
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. The fact that
we also piss off people who cannot see
that is just a big additional
advantage.
If you want a VCS that is written in
C++, go play with Monotone. Really.
They use a "real database".
They use "nice object-oriented libraries".
They use "nice C++
abstractions". And quite frankly, as a result of all
these design decisions that sound so
appealing to some CS people, the end
result is a horrible and unmaintainable mess.
But I'm sure you'd like it more than git.
Linus
最近的编程语言排行榜:摘自《csdn》
|
Position |
Position |
Delta in Position |
Programming Language |
Ratings |
Delta |
Status |
|
1 |
1 |
|
21.701% |
+0.17% |
A |
|
|
2 |
2 |
|
14.908% |
-3.15% |
A |
|
|
3 |
4 |
|
10.748% |
+0.12% |
A |
|
|
4 |
5 |
|
10.204% |
+1.08% |
A |
|
|
5 |
3 |
|
9.938% |
-0.82% |
A |
|
|
6 |
6 |
|
5.416% |
-0.01% |
A |
|
|
7 |
8 |
|
3.583% |
+0.59% |
A |
|
|
8 |
7 |
|
3.025% |
-0.12% |
A |
|
|
9 |
9 |
|
2.722% |
+0.28% |
A |
|
|
10 |
13 |
|
2.065% |
+1.13% |
A |
计算机界巨人的pk带来了网络热评,小字辈的我也斗胆对其也发表一下个人感想:
以前本科时用c++做过一些东西,选用的开发工具基本上是微软的产品,整体的感觉确实不错,(这里要声明一下c++不等于mfc)但本人对MFC到现在对还持怀疑态度,用别人的东西难免会对内部的实现产生迷惑,我不想用别人的东西而毫不知情,也不想冒着在不知情的情况下被人欺骗,固然MFC很出色,但是同时也让人担心,我不想盲目崇拜,除了我自己我很少相信别人;MFC让很多人对c++产生了误解,MFC不属于C++的范畴,它只是一种商业工具。C++的设计思想是一种”思维上的艺术和革命”,如果没有java出现的话我想今天的上层设计应该还是c++的天下。
上研以来,项目需要,就迷上了C,说不出的感觉,写出来的东西让人放心,即使错了我也知道到底错在什么地方,并且用c语言编程能锻炼人的思维,要求人对操作系统及硬件的底层都要熟悉,但是不要以为能用好c++的人就能用好c,也不要以为c就排斥面向对象技术,也不要以为c语言就强于c++。
我不知道当时Bjarne Stroustrup设计c++的时候为什么不和c斩断关系?也许他认识到C语言可移植,灵活性强的特点,也可能是没有想到什么方法用来消除语言中指针内存的痕迹,还有可能是出于将一些C语言工程师拉到C++阵营的考虑,但是事后诸葛,不可否认的是c++现在弄得不上不下,底层设计比不上c,应用设计被java所压制。
说了这么多,其实编程语言的争论无止无休,纯属个人信仰的问题。每一种语言都有他的优点和缺点,我们的目的是”在合适的项目中选择最优的语言”.语言的演变代表了程序员对完美的追求,主流设计语言的演变ASM->C->C++(java),其中c++(不是java)思想只是这个时代的一个里程碑。我们可以想象:计算机的演变就好比一个被慢慢来装饰的灰姑娘,我们不断的为她描眉涂粉,为她披金戴银,使她看起来更像是一个女人,漂亮的雍容大方的女人,我想这个时候一些男人见到这个女人的第一感觉就是想把她娶回家,研究一下她的内部结构,我们要去除多余的饰物之至能摸到她的脉搏!编程语言也是这样,我们不能只是满足于c++,java,固然他们为这个女人增添了美感,但是同时也为这个女人增加了神秘的感觉,让那些试图走进他的男人望而却步,”只可远观而不可亵玩焉”。可以大胆的说:一个对c,ASM
语言一知半解的程序人员永远抹不到计算机的脉搏,永远也得不到技术的真谛,当我们一步一步地剥掉层层面纱我们可能会说:这也不过如此!
In one word,这个语言的争论完全没必要,C语言是计算机领域无所不能的”王”(夸张了一点,还需要ASM),而C++的思想却为这个领域增加了前所未有的美感,两者之间并不排斥,在用c语言进行底层设计的时候,面向对象技术也时常可以用到。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7280904/viewspace-969429/ ,如需转载,请注明出处,否则将追究法律责任。