202209 | 锋芒毕露
TOC
- [Zig VS Rust 火花]($section.id(‘Zig VS Rust 火花’))
- 观点/教程
- 项目/工具
- Zig 语言更新
[Zig VS Rust 火花]($section.id(‘Zig VS Rust 火花’))
在 9/10 号左右,在 Twitter 上牵起了一小波关于 Zig VS Rust 的小火花,以至于最后 Zig 创始人 Andrew Kelley 发推表示 Let us exist。这里稍微整理下这件事情的过程: 本次事件主要涉及两个人:
- Rust 核心贡献者: Patrick Walton
- Zig 社区 VP: Loris Cro
- 8/26 号,一篇关于 wasm 2 Game Jam 的分析报告中,使用 Zig 的人数最多
- 9/9 号,这篇报告在 HackerNews 上引起了热烈讨论,其中 Walton 在多处回复中表示 Zig 语言的劣势,并称 > It’s perfectly reasonable to take the position that it’s deeply problematic for a language aiming for wide use in 2022 to not be memory safe. There’s no requirement that you “focus on tradeoffs”, especially since real people get hurt by memory safety problems.
- Loris 回复到: > I think you’re actively hurting the project that you care about in your ineffective crusade, but hey, don’t let me stop you.
- 9/10 号,有人发推对 tigerbeetle 内存分配方式表示好奇:所有内存必须在启动时静态分配好
- Walton 回复到: > The weird thing is that this is used as an example of why you supposedly don’t need language-enforced memory safety. > > But that literally is language-enforced memory safety! Just way more restrictive than what Rust has: if you hate the borrow check, try the “no heap” check… > > This is wrong because you can still have UAF from freed stack frames.
- Loris 针对 Walton 的回复说了句“What a boring, useless take.(原推的回复已经被 Loris 删除了,可以在这里看到历史):
- Walton 发推表示在 2022 年,所有语言都应该是内存安全,应该算是『编程语言界的共识』,并称 Zig 是行业的一大退步 😅
- Loris 专门发了一个 Twitter thread 来阐述『软件的目标不仅仅是内存安全,更重要的是正确』。比如 tigerbeetle 这里提到的。而且即便内存安全,也可能发生 OOM
上面的链接比较多,这里稍微总结下这次争论的问题:
Rust 用户觉得 Zig 不是内存安全的语言,Zig 认为 Rust 的语言过度复杂,这反而会导致程序复杂度挺升,导致程序产生错误行为
使用 Zig 的人大概率也是 Rust 用户,之所以有了安全的 Rust,还来选 Zig,笔者觉得大概率就是本次争论的观点,Rust 过于复杂,导致程序员不仅仅要考虑业务行为,还需要按照 Rust 的风格来编程,这加剧了程序出错的可能性。