编程与软件工程drewdevault.com
Rust 不是好的 C 语言替代品
Rust is not a good C replacement
2019 — 2020,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是 Drew DeVault(SourceHut 作者)2019 年的文章,论证 Rust 并不是 C 的好替代品。他认为 Rust 把 Cargo 设为准入门槛、编译器 flag 不稳定、与外部构建系统集成困难,而且 Rust 更接近 C++ 的设计哲学而非 C 的极简与长期稳定;对于多数系统程序员看重的简洁、可移植与可预测性,C 仍有其不可替代之处。文章引发了长达数年的争论,多次登上 Hacker News 首页。
为什么经久不衰:它把“该不该用 Rust 取代 C”这一至今未决的系统编程核心争论摆上台面,双方论点在评论里针锋相对,今天读来仍是理解这两种语言取舍的经典切入。
HN 评论精选
Rust 核心成员(Steve Klabnik)反驳“团队敌视外部构建系统集成”的说法,指出这是路线图上的明确目标。
这里有很多可说的,但我只回应一点:“尝试将其与其他构建系统集成,遭到了 Rust 和 Cargo 团队的敌意。”这完全不是事实。我们投入了大量工作来支持这一点——可以说设计工作做得太多、实现工作做得不够,有过几次让集成比现在更好的尝试但都没完成。但这确实是团队关心和期望的事情。它明明白白写在 2017 路线图里:“Rust 应能轻松融入大型构建系统”,我不明白这怎么被说成“敌意”。
steveklabnik查看英文原文
There's a lot of stuff I could say here, but I'll stick to > Attempts to integrate it with other build systems have been met with hostility from the Rust & Cargo teams. This is very much not true. We've put in a ton of work to support this. Arguably, we've put in too much design work and not enough implementation work; we've had a few different attempts at making this work even better than it does today, and we haven't finished them up. But this is very much something that is cared about and desired by the team. It was literally on the 2017 roadmap: https://blog.rust-lang.org/2017/02/06/roadmap.html > Rust should integrate easily into large build systems. Plans include working with large companies incorporating Rust to understand how best to equip Cargo to smooth the process. I don't know how this is framed as "hostility". As one example of the work done here: https://github.com/rust-lang/cargo/issues/5579
批评原文“不在乎安全性”的态度站不住脚,且“重写必然引入更多 bug”缺乏经验依据。
“安全性。是的,Rust 更安全。但我真的不在乎。面对这些问题,我宁愿要我的段错误和缓冲区溢出。我尤其拒绝‘重写为 Rust’——因为无论如何,从头重写整个程序引入的 bug 总比维护 C 程序更多。”这就是我们没法进步的原因。“我不在乎”别人溢出我的缓冲区来执行代码……而“引入更多 bug”也不成立,经验上完全是无稽之谈。
beders查看英文原文
> Safety. Yes, Rust is more safe. I don’t really care. In light of all of these problems, I’ll take my segfaults and buffer overflows. I especially refuse to “rewrite it in Rust” - because no matter what, rewriting an entire program from scratch is always going to introduce more bugs than maintaining the C program ever would. And that is why we can't have nice things. "I don't really care" if someone overflows my buffer to execute code... And: "going to introduce more bugs" - false. Empirically complete bollocks...
用微软 70% 安全漏洞源于内存问题的数据反问:C 社区减少安全缺陷的路线图是什么?
“但现在你知道我们为什么还在写 C 了,希望你们别再拿这事烦我们。”在 C 软件安全性改善之前,恐怕没人会停止“烦”他们。微软发现其软件中 70% 的安全漏洞是内存安全问题。像 Rust 这样的语言正在努力解决这些问题,那么 C 软件减少安全缺陷的路线图是什么?
clouddrover查看英文原文
> But now you know why we are still writing C, and hopefully you’ll stop bloody bothering us about it. I don't think anyone will stop bothering them about it until C software security improves. Microsoft found that 70% of security bugs in their software were memory safety issues: https://www.zdnet.com/article/microsoft-70-percent-of-all-security-bugs-are-memory-safety-issues/ Languages like Rust are making an effort to address these issues. What's the roadmap for reducing the number of security flaws in C software?
认为 Rust 更像 C++ 而非 C,其快速演进、社区规模与 LLVM 依赖都使其难以真正取代 C,更可能取代 C++。
我不认为有人主张为了 Rust 而彻底弃用 C。别误会,我爱 Rust,认为它是本世纪最好的语言。但第一,C 之所以是 C,是因为它根深蒂固、基础扎实、几十年几乎未变;而 Rust 变化太快,这恰恰不是你想给内核所用语言的性质。第二,Rust 社区还很小。第三,Rust 活在 LLVM 世界,我看不到它短期内进入 GCC 世界,这对“取代 C”是个大问题(许可在某些情况下可能成问题)。最后,Rust 本质上更接近 C++ 而非 C;如果它要取代什么,对 C++ 的机会比对 C 大得多。我真希望有天在招聘网站上看到 6000 个 Rust 职位,但眼下我怀疑这天会不会来。
axegon_查看英文原文
I honestly don't think anyone suggests dropping C in favor of Rust. Make no mistake, I love Rust and I think it's the best language that's been developed in this century. Firstly, C is where it is because it's well established and has solid foundations and it has remained pretty much unchanged for decades. Rust on the other hand is changing rapidly and fast, which is something you wouldn't want for a language that powers your kernel Secondly, the Rust community is painfully small. Thirdly, Rust lives in the LLVM world and I don't see it coming into the GCC world anytime soon. Which is a huge problem, as far as replacing C goes(namely licencing might be problematic in some cases). Lastly Rust, in terms of it's nature, is more closely related to C++ rather than C. If Rust was to replace something, it has a much better chance against C++ than C. I truly want to see the day I open up linkedin, go to the jobs section, type in rust and see 6000 new job offers. But at this point in doubt this day will ever come.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选