贴出者为 macolex
编程开发 macolex写著 '在最近的一个关于LKML的讨论中,Linus给出了为什么不用C++来写Linux内核的理由:
在最近的一个关于LKML的讨论中,Linus给出了为什么不用C++来写Linux内核的理由:

"In fact, in Linux we did try C++ once already, back in 1992. It sucks. Trust me - writing kernel code in C++ is a BLOODY STUPID IDEA.

“事实上,我们曾经尝试过用C++来写,是在1992年的时候。很糟糕。相信我--用C++来写内核代码是一个非常愚蠢的想法。”

"The fact is, C++ compilers are not trustworthy. They were even worse in 1992, but some fundamental facts haven't changed: 1) the whole C++ exception handling thing is fundamentally broken. It's _especially_ broken for kernels. 2) any compiler or language that likes to hide things like memory allocations behind your back just isn't a good choice for a kernel. 3) you can write object-oriented code (useful for filesystems etc) in C, _without_ the crap that is C++."

“实际上,C++编译器是很不可靠的。在1992年的时候情况就很差了,而且一些基础的东西到现在还没有改变:(1)整个C++对Exception的处理根本就是不完整的,特别是在写内核的时候。(2)任何喜欢把跟内存分配有关的功能匿藏起来的编译器或者程序语言对于编写内核来说都是错误的选择。(3)在C里面你也可以写面向对象的代码(写文件系统的时候很有用),是不需要C++的。

Linuxbyte.net 新闻报道力求为您提供国内最快,最新,最务实的Linux业界新闻,欢迎转载.请转载时注明新闻出处, 作者名称并保留此声明. 谢谢您的合作.

发布人:wangxiaohu 来自:http://kerneltrap.org/node/view/2067 '

arrow
arrow
    全站熱搜

    戮克 發表在 痞客邦 留言(0) 人氣()