急性肠胃炎吃什么食物| 慢阻肺是什么病| 鸡头上长痘痘用什么药| 诺如病毒吃什么药最有效| 胰腺炎吃什么食物| 阑尾是干什么用的| 精益求精下一句是什么| 张属于五行属什么| 369是什么意思| 69年鸡是什么命| 内敛是什么意思| 梦见碗是什么意思| 看见乌鸦有什么预兆| 潮喷是什么意思| 外阴灼热用什么药| 慰安妇是什么| 96年的属什么| 木字旁加差是什么字| lch是什么病| 福建岩茶属于什么茶| pcl是什么意思| 下面有味道用什么药| 疱疹不能吃什么| 秋五行属什么| 小宇宙是什么意思| 低血压是什么原因| 梦见吃樱桃是什么意思| 黑洞是什么| 什么是花胶| 7月15日是什么节日| 肺部结节是什么原因引起的| 吃万艾可有什么副作用| 补血补气吃什么好| 黯淡是什么意思| 怀孕6个月吃什么好| 喝水牙疼是什么原因| 棉条是什么| 今年67岁属什么生肖| 海松茸是什么| 离婚带什么证件才能办理| 腺癌是什么癌| 气场是什么意思| 胡萝卜吃多了有什么坏处| 水乳是什么| 铁皮石斛可以治什么病| 左腹下方隐痛什么原因| 手腕关节疼痛什么原因引起的| 天天喝可乐有什么危害| 阴道里面痒是什么原因| 孩子铅高有什么症状| 白发用什么染发最安全| 里正是什么官| 梦见捉黄鳝是什么意思| 去心火喝什么茶好| 生姜能治什么病| 政委是干什么的| 一清二白是什么意思| 86年属什么的| 出汗少的人是什么原因| 七月份出生是什么星座| 动员是什么意思| 什么叫肾阴虚和肾阳虚| C反应蛋白高是什么原因| 液金是什么| 浓鼻涕吃什么药| 9月24号是什么星座| 蒲公英的种子像什么| 什么是性生活| 高大的动物是什么生肖| 神采奕奕是什么意思| 奥美拉唑治什么病| 无穷是什么意思| 异口同声是什么意思| 口吃什么意思| 时光如梭是什么意思| 产后抑郁一般发生在产后什么时间| 上海市市委书记是什么级别| 钥匙代表什么生肖| 蚊子喜欢什么| 少字加一笔是什么字| 什么是耐药性| 光明会是什么组织| 什么养胃| 放疗什么意思| 梦见很多棺材是什么征兆| 什么是热伤风| 做噩梦是什么原因| 疝囊是什么| merry是什么意思| 什么是ntr| 42是什么生肖| o型血父母是什么血型| 鼻炎会引起什么症状| 抽烟对身体有什么危害| 肺结节不能吃什么食物| 寒潮是什么| 可乐不能和什么一起吃| 子宫腺肌症吃什么药| 月经期间肚子疼是什么原因| 海柳什么颜色最贵的| 过敏性紫癜是什么原因引起的| 曼珠沙华是什么意思| 西洋参跟花旗参有什么区别| 艾滋病初期什么症状| 梦见好多动物是什么意思| 镜里观花是什么生肖| 总是头疼是什么原因| hpv什么病毒| 月经不正常去医院检查什么项目| 蚯蚓喜欢吃什么| 胃潴留是什么病| 染色体是由什么组成的| 辛属什么五行| 产后复查都查什么| 米老鼠叫什么名字| 什么鞋穿着舒服| 喝酒为什么会吐| white是什么意思颜色| 跛脚是什么意思| 做梦梦到搬家什么意思| 眼睛肿了是什么原因| abc是什么药| 女人的网名叫什么好听| 老掉头发是什么原因| 为什么一热脸就特别红| 七夕节吃什么| napoleon是什么酒| 经血粉红色是什么原因| 动脉导管未闭对宝宝有什么影响| 豆工念什么| 梦到发大水是什么意思| 胃酸胃烧心吃什么药| 檀木手串有什么好处| 减肥最快的运动是什么运动| 神经系统是由什么组成的| 禅心是什么意思| 什么食物养胃又治胃病| 硼砂是什么东西| 金钱骨是什么部位| 拉疙瘩屎是什么原因| 2013属什么生肖| 提供什么| hpv是什么症状| 朱顶红什么时候开花| 南音是什么意思| 什么情况下要打破伤风针| 虚岁28岁属什么生肖| 蚕丝衣服用什么洗最好| 无畏布施是什么意思| 梦见抓甲鱼是什么意思| 送老师什么花好| 早上眼屎多是什么原因| 风热火眼是什么意思| 扶苏是什么意思| 嘚儿是什么意思| 梦见发大水是什么意思| 棒打鸳鸯什么意思| 吊人什么意思| 梦见挖坟墓预示什么| 肠溶片是什么意思| 身份证后六位代表什么| 23号来月经什么时候是排卵期| dw什么意思| 淋巴结肿大吃什么药| 老是饿是什么原因| 青岛有什么山| 什么样的男人不能嫁| 泽五行属什么| 甲壳素是什么东西| 血糖高应该吃什么水果| 肾挂什么科室| 耸是什么意思| 什么叫活检| 宫颈非典型鳞状细胞是什么意思| panerai是什么牌子| 煤油是什么油| 反物质是什么东西| 巩膜是什么部位| 亦的意思是什么| 高血压吃什么| ed是什么病| 世界上最长的蛇是什么蛇| 业力是什么意思| 麦冬长什么样子图片| 黑舌头的狗是什么狗| 肺结节是什么症状| 凝血酶原时间是什么意思| 总蛋白偏高有什么危害| 青春痘用什么药膏擦最好呢| 血糖高是什么原因引起| 5月29日是什么星座| 仰天长叹的意思是什么| 急性上呼吸道感染吃什么药| 丝状疣用什么药膏最好| 孙悟空叫什么名字| 狗奴是什么意思| 胆汁是什么颜色| 结婚六十年是什么婚| 小腿红肿是什么原因引起的| 胃炎能吃什么水果| 喝啤酒尿多是什么原因| 寻找什么| 梦到女朋友出轨是什么意思| 东南方是什么生肖| model什么意思| 天津副市长什么级别| 上火便秘吃什么药| 抵抗力差吃什么| 湿气重看中医挂什么科| 小资生活是什么意思| 八月十五是什么日子| 为什么吃火龙果会拉肚子| 自学成才是什么意思| 头发长的快是什么原因| 老夫老妻什么意思| 1893年属什么| 无锡机场叫什么名字| 什么水果减肥最有效| 阴道口痒是什么原因| 脸过敏用什么药膏效果最好| bang什么意思| 二级医院是什么意思| 女票什么意思| 五月十三是什么星座| 什么运动使人脸部年轻| 接踵而至是什么意思| 高湛为什么帮梅长苏| 脚上长水泡是什么原因引起的| 黑豆熟地水功效是什么| 抹布什么意思| 有什么有什么| paris什么意思| pi是什么意思| 粒子是什么| 精子像果冻是什么原因| 脚出汗多是什么原因怎么办| 火字旁的字有什么| 素鸡是什么| 刘晓庆为什么坐牢| 肺肾两虚吃什么中成药| 净身出户什么意思| 雪碧喝多了有什么害处| 佐匹克隆片是什么药| 痛风喝酒会有什么后果| 糖尿病人喝什么茶最好| 卤什么东西好吃| 心脏为什么会突然刺痛| 93什么意思| 大姨妈来吃什么水果好| 舌头裂缝是什么原因| 手脚热是什么原因| 耳膜穿孔有什么症状| 属猪的跟什么属相最配| 骨瘤是什么病| 对节木是什么树| 从革是什么意思| 附件炎吃什么药好| 扁桃体发炎不能吃什么东西| 紫米和小米什么关系| cosplay是什么意思| eso是什么意思| inv是什么意思| 淘宝和天猫有什么区别| 杀破狼是什么意思| 百度
|
|
Subscribe / Log in / New account

《我是大侦探》首播 “头脑的演技”震撼荧屏

From:  Linus Torvalds <torvalds-AT-linux-foundation.org>
To:  Dmitry Kakurin <dmitry.kakurin-AT-gmail.com>
Subject:  Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.
Date:  Thu, 6 Sep 2007 18:50:28 +0100 (BST)
Message-ID:  <alpine.LFD.0.999.0709061839510.5626@evo.linux-foundation.org>
Cc:  Matthieu Moy <Matthieu.Moy-AT-imag.fr>, Git <git-AT-vger.kernel.org>
Archive‑link:  Article



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



to post comments

Mostly but not totally agree..

Posted Dec 17, 2008 19:21 UTC (Wed) by Solifugus (guest, #55639) [Link] (1 responses)

I actually live in a no-man's land of being a very C-like C++ programmer. I completely agree with Linus about the problems in C++. But I take C++ as a version of C, then use what parts of C++ I do like on top of it. I basically have C but I can pick and choose to use other things, too.

The promise of class hierarchies making development faster and easier with more code reuse came as a double-edged sword. Not only does every class you make create a lot of overhead to manage (in the underlying machine code) but the common practice of requiring and returning complex objects from methods can requires a Ph.D in any library you want to use. And although the STL has safeguards greatly eliminating buffer overflows (common in C), it's very inflexible. Unless you are doing very simple coding, it can be more complex than recursive layers of pointers.

I spent a lot of time learning C++ only to learn that for every good idea, there were 10 bad ones. Theory ignores a lot of reality.

I do, however, think that C++ libraries can be well designed. This usually involves using a lot fewer C++ features but it isn't all bad. References, for example. Classes and instantiation, used minimally with only a basic set of data types passed in and out of methods can be very efficient at performance, memory footprint, and ease of learning/understanding/debugging. Sadly, this ideal is rarely the case.

Even making good use of C++ (which is rare), I think C is better for kernels and C++ better for desktop systems. With kernels, you are working damn close to bare metal and with desktop systems, you are working on a higher level and need to work with much larger scale philosophies in design.

Matthew

Mostly but not totally agree..

Posted Dec 19, 2008 13:53 UTC (Fri) by Flameeyes (subscriber, #51238) [Link]

See there are some particular issues though that you can't workaround by limiting yourself to C syntax in C++.

Since virtual classes require you to use vtables, those will always get in the way of reducing to a minimum the Copy-on-Write memory waste of your software, the amount of symbols to bind increase tremendously, and you probably have to sacrifice most of the builtins from the compiler.

The result is that C++ code can be very inefficient for fire-and-forget tools, like git is. For higher level software (like KDE) they might not be noticeable, but Linus is right in his reasoning.

Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

Posted Jan 14, 2009 23:41 UTC (Wed) by vomlehn (guest, #45588) [Link]

Here's an interesting exercise: try to find the definition of the function buffer_eopnotsupp() in the kernel. Hint: it's defined by using a macro, along with the functions set_buffer_eopnotsupp() and clear_buffer_eopnotsupp(). This is the kind of thing that object-oriented languages should be good at.

Another example that is quite common: the use of function pointers is frequently accomplishing the exact same goal as having derived objects, but less cleanly. It also limits the ability of the compiler to optimize cases where the actual function is known, and therefore could be inlined or even eliminated entirely.

Does that mean that C++ is the answer? No. And, in spite of having actually used a number of other languages for real world projects, I don't know of anything better. I do think, however, that Linux is out-growing C and that we have an opportunity and a need to figure out something better.

[Answer to the exercise: See the macro BUFFER_FNS in include/linux/buffer_head.h]

Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

Posted Jan 15, 2009 6:15 UTC (Thu) by charris (guest, #13263) [Link]

- 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.

I think this is a valid point. Trying to reuse bits of code from a project that has been extensively designed around an object hierarchy is a pain and requires tearing things apart and a lot of recoding. Some code isn't meant to be reused outside of the original project, desktops may be an instance of this. But suites of algorithms should be designed so that the individual parts are easily separated from the whole.

Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

Posted Oct 18, 2009 17:09 UTC (Sun) by jafl (guest, #36401) [Link]

I completely agree with the weed-out factor, and avoiding inefficient pass-by-value for objects requires fanatical dedication to using references. But I disagree with the claim about object models. Any time you define a struct and functions to operate on that struct, you have an object model. It's probably true that the object models in C tend to be much simpler than in C++, because C++ lets you go hog wild, but if two years down the road, you realize that your C structs need adjustments, it may still require a lot of refactoring.

Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

Posted Nov 4, 2010 10:44 UTC (Thu) by PierreG (guest, #71005) [Link] (1 responses)

I wrote G-WAN, a 160 KB Web app. server with ANSI C scripts.
G-WAN is (by far) faster than anything else ever published (in user-mode or in the kernel).

Compared to G-WAN, the BOOST C++ library is bloated, slow and its code is promoting obscurity to new heights.

That's probably for a reason:

"Within C++, there is a much smaller and cleaner language struggling to get out"
(Bjarne Stroustrup, proud MICROSOFT Windows user)

Re: [RFC] Convert builin-mailinfo.c to use The Better String Library.

Posted Oct 22, 2018 4:02 UTC (Mon) by Sir_Dogoven (guest, #128065) [Link]

I wonder if this conclusion still stands.


Copyright © 2007, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds

鸡代表什么数字 安康鱼是什么鱼 开火是什么意思 皂矾是什么 如痴如醉是什么意思
手抽筋吃什么药 伛偻是什么意思 高潮是什么 疱疹用什么药好 真菌最怕什么
甘油三酯高是什么原因引起的 hpv68阳性是什么意思 脚腿肿是什么原因引起的 血常规是检查什么的 木乐读什么
仓鼠爱吃什么东西 空调制热效果不好什么原因 耳朵出血是什么原因 怀孕两个月出血是什么原因 肾结石是什么原因造成的
凉栀是什么意思hcv7jop5ns2r.cn 三维彩超和四维彩超有什么区别bysq.com 一个人自言自语的说话是什么病hcv8jop1ns5r.cn 转念是什么意思beikeqingting.com paco2是什么意思hcv9jop2ns2r.cn
妈富隆是什么药hcv7jop9ns3r.cn 发炎是什么原因引起的hcv8jop9ns6r.cn 什么东西化痰效果最好最快mmeoe.com 魁拔4什么时候上映hcv9jop5ns7r.cn 颅内出血有什么症状hcv8jop0ns5r.cn
山药什么季节成熟xinmaowt.com 女性放屁多是什么原因hcv9jop2ns4r.cn 猪肉排酸是什么意思hcv9jop0ns0r.cn 梦见买面条有什么预兆hcv8jop4ns0r.cn 为什么心脏会隐隐作痛hcv7jop9ns2r.cn
甲功能5项检查是查的什么zhongyiyatai.com 骶管囊肿是什么意思dajiketang.com 什么是嗜睡aiwuzhiyu.com 什么是精神hcv9jop2ns3r.cn 自律性是什么意思hcv9jop6ns2r.cn
百度