|
8 | 8 |
|
9 | 9 | ## [Zig VS Rust 火花]($section.id('zig-vs-rust-spark')) |
10 | 10 |
|
11 | | -### [时间线]($section.id('timeline')) |
| 11 | +在 9/10 号左右,在 Twitter 上牵起了一小波关于 Zig VS Rust |
| 12 | +的小火花,以至于最后 Zig 创始人 Andrew Kelley |
| 13 | +[发推](https://twitter.com/andy_kelley/status/1568679389113757698)表示 |
| 14 | +Let us exist。这里稍微整理下这件事情的过程: 本次事件主要涉及两个人: |
12 | 15 |
|
13 | | -### [总结]($section.id('summary')) |
| 16 | +- Rust 核心贡献者: Patrick Walton |
| 17 | +- Zig 社区 VP: Loris Cro |
14 | 18 |
|
15 | | -## [观点/教程]($section.id('viewstutorials')) |
16 | | - |
17 | | -- [How (memory) safe is zig?](https://www.scattered-thoughts.net/writing/how-safe-is-zig/) |
| 19 | +## [时间线]($section.id('timeline')) |
18 | 20 |
|
19 | | -- [Hacked std.PriorityQueue for constant time update](https://www.reddit.com/r/Zig/comments/x8fxqr/hacked_stdpriorityqueue_for_constant_time_update/) |
| 21 | +- 8/26 号,一篇关于 wasm 2 Game Jam |
| 22 | + 的[分析报告](https://wasm4.org/blog/jam-2-results/)中,使用 Zig |
| 23 | + 的人数最多 |
| 24 | +- 9/9 号,这篇报告在 HackerNews |
| 25 | + 上引起了[热烈讨论](https://news.ycombinator.com/item?id=32777636),其中 |
| 26 | + Walton 在多处回复中表示 Zig |
| 27 | + 语言的劣势,[并称](https://news.ycombinator.com/item?id=32782842) \> |
| 28 | + It’s perfectly reasonable to take the position that it’s deeply |
| 29 | + problematic for a language aiming for wide use in 2022 to not be |
| 30 | + memory safe. There’s no requirement that you “focus on tradeoffs”, |
| 31 | + especially since real people get hurt by memory safety problems. |
| 32 | +- Loris [回复到](https://news.ycombinator.com/item?id=32785380): \> I |
| 33 | + think you’re actively hurting the project that you care about in your |
| 34 | + ineffective crusade, but hey, don’t let me stop you. |
| 35 | +- 9/10 号,有人发推对 |
| 36 | + [tigerbeetle](https://github.com/tigerbeetledb/tigerbeetle/blob/main/docs/TIGER_STYLE.md#safety) |
| 37 | + 内存分配方式表示好奇:所有内存必须在启动时静态分配好 |
| 38 | +- Walton |
| 39 | + [回复到](https://mobile.twitter.com/pcwalton/status/1568498326496247809): |
| 40 | + \> The weird thing is that this is used as an example of why you |
| 41 | + supposedly don’t need language-enforced memory safety. \> \> But that |
| 42 | + literally is language-enforced memory safety! Just *way* more |
| 43 | + restrictive than what Rust has: if you hate the borrow check, try the |
| 44 | + “no heap” check… \> \> This is wrong because you can still have UAF |
| 45 | + from freed stack frames. |
| 46 | +- Loris 针对 Walton 的回复说了句“What a boring, useless |
| 47 | + take.([原推](https://mobile.twitter.com/kripken/status/1568428308131622913)的回复已经被 |
| 48 | + Loris |
| 49 | + 删除了,可以[在这里](https://archive.ph/jq3kw#selection-1275.0-1275.30)看到历史): |
| 50 | +- Walton |
| 51 | + 发推[表示](https://mobile.twitter.com/pcwalton/status/1568302065851707392)在 |
| 52 | + 2022 年,所有语言都应该是内存安全,应该算是『编程语言界的共识』,并称 |
| 53 | + Zig 是行业的一大退步 😅 |
| 54 | +- Loris 专门发了一个 [Twitter |
| 55 | + thread](https://twitter.com/croloris/status/1568573729940164608?s=21&t=v2Dj_F2f_kUzZDQps5KjtQ) |
| 56 | + 来阐述『软件的目标不仅仅是内存安全,更重要的是正确』。比如 tigerbeetle |
| 57 | + 这里[提到的](https://github.com/tigerbeetledb/tigerbeetle/blob/main/docs/DESIGN.md)。而且即便内存安全,也可能发生 |
| 58 | + OOM |
20 | 59 |
|
21 | | -- [Flutter/Dart + FFI + Zig](https://github.com/zigcc/forum/discussions/21) |
| 60 | +## [总结]($section.id('summary')) |
22 | 61 |
|
23 | | -- [Building a Tiny Mutex](https://zig.news/kprotty/building-a-tiny-mutex-537k) |
| 62 | +上面的链接比较多,这里稍微总结下这次争论的问题: |
24 | 63 |
|
25 | | -- [Perfecting WebGPU/Dawn native graphics for Zig](https://devlog.hexops.com/2022/perfecting-webgpu-native/) |
| 64 | +> Rust 用户觉得 Zig 不是内存安全的语言,Zig 认为 Rust |
| 65 | +> 的语言过度复杂,这反而会导致程序复杂度挺升,导致程序产生错误行为 |
26 | 66 |
|
27 | | -- [Cross-Compiling and packaging C, Go and Zig projects with Nix](https://flyx.org/cross-packaging/) |
| 67 | +使用 Zig 的人大概率也是 Rust 用户,之所以有了安全的 Rust,还来选 |
| 68 | +Zig,笔者觉得大概率就是本次争论的观点,Rust |
| 69 | +过于复杂,导致程序员不仅仅要考虑业务行为,还需要按照 Rust |
| 70 | +的风格来编程,这加剧了程序出错的可能性。 |
28 | 71 |
|
29 | | -- [Revisiting the design approach to the Zig programming language](https://about.sourcegraph.com/blog/zig-programming-language-revisiting-design-approach) |
| 72 | +## [观点/教程]($section.id('viewstutorials')) |
30 | 73 |
|
31 | | -- [Zig ⚡ Improving the User Experience for Unused Variables](https://vimeo.com/748218307) |
| 74 | +- [How (memory) safe is |
| 75 | + zig?](https://www.scattered-thoughts.net/writing/how-safe-is-zig/) |
| 76 | + 作者重点介绍了在内存安全方面,Zig 的优劣势。尽管 Zig 相比 C |
| 77 | + 有了明显的改进,但相比 Rust |
| 78 | + 这种在编译期就能发现程序问题来说,显得有些鸡肋,但在一些可控的环境下,比如 |
| 79 | + WASM、嵌入式环境中,Zig 还是有发挥的空间 |
| 80 | + - [How (memory) safe is zig? (UPDATED) | |
| 81 | + Lobsters](https://lobste.rs/s/nw7hsd) |
| 82 | + - [How safe is Zig? | Hacker |
| 83 | + News](https://news.ycombinator.com/item?id=31850347) |
| 84 | +- [Hacked std.PriorityQueue for constant time |
| 85 | + update](https://www.reddit.com/r/Zig/comments/x8fxqr/hacked_stdpriorityqueue_for_constant_time_update/) |
| 86 | +- [Flutter/Dart + FFI + Zig: Flutter 使用 FFI 调用 Zig |
| 87 | + 示例](https://github.com/zigcc/forum/discussions/21) |
| 88 | +- [Building a Tiny |
| 89 | + Mutex](https://zig.news/kprotty/building-a-tiny-mutex-537k) |
| 90 | +- [Perfecting WebGPU/Dawn native graphics for |
| 91 | + Zig](https://devlog.hexops.com/2022/perfecting-webgpu-native/) |
| 92 | +- [Cross-Compiling and packaging C, Go and Zig projects with |
| 93 | + Nix](https://flyx.org/cross-packaging/) 介绍如何基于 |
| 94 | + [Nix](https://nixos.org/) 来进行交叉编译 |
| 95 | +- [Revisiting the design approach to the Zig programming |
| 96 | + language](https://about.sourcegraph.com/blog/zig-programming-language-revisiting-design-approach) |
| 97 | + Sourcegraph 的一档播客,对 Zig 创始人的采访,介绍了 Zig |
| 98 | + 的由来,其中提到一个性能优化点是:untagged |
| 99 | + union,这里有它的一些介绍:[Andrew Kelley claims Zig is faster than |
| 100 | + Rust in |
| 101 | + perfomance](https://www.reddit.com/r/rust/comments/s5caye/comment/hsz6uf0/?utm_source=share&utm_medium=web2x&context=3) |
| 102 | +- [Zig ⚡ Improving the User Experience for Unused |
| 103 | + Variables](https://vimeo.com/748218307) |
32 | 104 |
|
33 | 105 | ## [项目/工具]($section.id('projectstools')) |
34 | 106 |
|
| 107 | +- [Zig |
| 108 | + 开发常用类库](https://github.com/zigcc/forum/discussions/28),如果读者的 |
| 109 | + Zig 项目托管在 GitHub,推荐加上 |
| 110 | + [zig-package](https://github.com/topics/zig-package) |
| 111 | + 这个标签,这样可以自动被 https://zig.pm/ 收录 |
| 112 | +- https://zig.run/ - 在线运行 zig 代码 |
| 113 | +- [Zig Support plugin for IntelliJ and CLion version 0.0.7 |
| 114 | + released](https://zig.news/marioariasc/zig-support-plugin-for-intellij-and-clion-version-007-released-1en8) |
| 115 | +- [zig-napigen](https://github.com/cztomsik/zig-napigen) Automatic N-API |
| 116 | + bindings for your Zig project. |
| 117 | +- [Dart 通过 FFI 调用 Zig |
| 118 | + 库示例](https://github.com/better-dart/learn-dart/blob/main/packages/ffi-binding/example/main.dart#L31) |
| 119 | +- [zig-gamedev](https://github.com/michal-z/zig-gamedev) |
| 120 | +- [loc in Zig](https://github.com/jiacai2050/loc) 代码行数统计工具 |
| 121 | +- [Grep in Zig](https://github.com/EclesioMeloJunior/zig-grep) |
| 122 | +- [randomutils](https://gitlab.com/hdante/randomutils) Generate 64-bit |
| 123 | + random numbers |
| 124 | +- [zig-pico](https://github.com/paperdev-code/zig-pico) 树莓派 [Pico |
| 125 | + SDK](https://github.com/raspberrypi/pico-sdk) 的 Zig 绑定库 |
| 126 | +- [stm32f4.zig](https://github.com/moonxraccoon/stm32f4.zig) STM32F4(ARM |
| 127 | + Cortex M4 的高性能 32 位微控制器) 固件抽象层 |
| 128 | + |
35 | 129 | ## [Zig 语言更新]($section.id('zig-updates')) |
| 130 | + |
| 131 | +[相关链接](https://github.com/ziglang/zig/pulls?q=+is%3Aclosed+is%3Apr+closed%3A2022-09-01..2022-10-01+) |
0 commit comments