TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why don't we rewrite the Linux kernel in C++?

20 点作者 vinutheraj将近 16 年前

11 条评论

bobbyi将近 16 年前
Linus on C++: <a href="http://article.gmane.org/gmane.comp.version-control.git/57918" rel="nofollow">http://article.gmane.org/gmane.comp.version-control.git/5791...</a>
评论 #687835 未加载
评论 #688391 未加载
vinutheraj将近 16 年前
Actually I suggest the whole Linux FAQ because of many good explanations to questions like why isn't the linux kernel a microkernel and why aren't the gotos replaced with C style exceptions.<p>They give a pretty good answer to latter question - <i>Admittedly, all those goto's do look a bit ugly. However, they are usually limited to error paths, and are used to reduce the amount of code required to perform cleanup operations. Replacing these with Politically Correct if-then-else blocks would require duplication of cleanup code. So switching to if-then-else blocks might be good Computer Science theory, but using goto's is good Engineering. Since the Linux kernel is one designed to be used, rather than to demonstrate theory, sound engineering principles take priority.</i><p>It is definitely a <i>nice reading on a rainy afternoon</i>
评论 #687841 未加载
jongraehl将近 16 年前
It sounds like they took someone's patch, which renamed some identifiers to not conflict with the handful of new keywords added in C++, and ignored it.<p>Then they bragged about it.<p>That seems to be more political than technical.
评论 #687790 未加载
tptacek将近 16 年前
There already are projects that run C++ code in the Linux kernel; the Click Modular Router from MIT PDOS is C++, for instance. It's probably prohibitively annoying to write mainline kernel code, like a device driver, in C++. There might not be anything to prevent you from loading a whole C++ subsystem, though.<p>I'll head some other commenters off at the past and note that MacOS X xnu has a C++ device driver interface, but is still a C-code kernel.<p>Linus is right about the exception handling and allocator issues. C++ exceptions are a misfeature in userland code; it's even more important for kernel code to be able to handle problems gracefully and explicitly, and unwinding stacks through functions running at different interrupt sensitivities and holding different locks seems like an disaster waiting to happen. And, unless my C++ has gotten rusty since Alexandrescu's book came out, nobody likes the C++ allocator interfaces --- which you'd certainly have to dive into to handle the kernel's various different allocation strategies.
wglb将近 16 年前
I think it would be more interesting to do it in D.
评论 #687804 未加载
评论 #687758 未加载
Bjoern将近 16 年前
For polyglots it is interesting also to know why C/C++ got so popular in the first place.<p>JWZ - The worse is better.<p><a href="http://www.jwz.org/doc/worse-is-better.html" rel="nofollow">http://www.jwz.org/doc/worse-is-better.html</a>
评论 #687917 未加载
rbanffy将近 16 年前
I learned OOP in Smalltalk. Then I decided to learn C++. The first code snippet I saw used the overloaded shift operator to push strings to stdout. I closed the book.<p>It took me 8 years to try to learn C++ for a second time. This time I insisted and more or less got through.<p>C++ is not as bad as my first impression led me to believe, but it's not as good as its enthusiasts insist it is. For instance, and quite predictably for a Smalltalker, I find Objective-C much more elegant.<p>It seems foolish to implement something like this in C++
评论 #694695 未加载
chanux将近 16 年前
Why I see people talking about OSes a written in high level languages a lot lately?<p>Remember the C# one came on HN? <a href="http://daeken.com/renraku-future-os" rel="nofollow">http://daeken.com/renraku-future-os</a><p>I think an OS written in an OO language will demonstrate why some people were actually worried about OOP. <a href="http://www.geocities.com/tablizer/oopbad.htm" rel="nofollow">http://www.geocities.com/tablizer/oopbad.htm</a>
tybris将近 16 年前
Weird question, what's wrong with C? A simple, elegant, efficient language that is close to the metal.
评论 #687868 未加载
known将近 16 年前
Why don't we rewrite JVM in Java?
Zarathu将近 16 年前
"...and furthermore, C++ is slow as piss."
评论 #687712 未加载