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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Zig vs. Rust at work: the choice we made

94 点作者 qouteall11 个月前

13 条评论

jedisct111 个月前
&gt; &quot;WASM support was just as smooth in Rust as in Zig&quot;.<p>There are still way too many Rust dependencies that don&#x27;t support WebAssembly, and even functions in the standard library that compile but will crash at runtime on WebAssembly. And if a dependency requires C code, `cargo-zigbuild` is required to compile it anyways.<p>My experience with Zig is that pretty much everything compiles out of the box to all the supported targets, and works the same way. This includes code using SIMD.<p>I also like the fact that the code can be optimized for the runtime&#x27;s feature: adding -mcpu=baseline+simd128 compiles everything for wasm runtimes with support for SIMD, including the C library (&quot;wasi-libc&quot;). This is not specific to the wasm target, but the fact that even the libc is recompiled with the same optimization flags as the rest of the code is neat. You can really optimize the code for speed, size or a specific target.<p>WebAssembly modules compiled from Zig code are also very small and memory efficient, without being forced to use a &quot;[no_std]&quot; mode. That can make a big difference if you have to distribute them, or are billed according the resource usage.<p>&gt; The Zig build system is amazing and 100x better than our makefiles.<p>This.<p>People often think Zig is just a language. But it&#x27;s a toolchain, that can be used even for code not written in Zig.<p>It&#x27;s a fantastic replacement for makefiles &#x2F; CMake &#x2F; ccache &#x2F; hacky shell scripts, with seamless cross-compilation and webassembly support.
zer00eyz11 个月前
I have written some rust I like it. I prefer GO for day to day but I wont turn my nose up at Rust...<p>Cargo on the other hand... I saw someone say &quot;Rust is turning into the language that tokio ate&quot; ... and this is a cargo shortcoming.<p>Zig dependency management feels more Go like, and in my book thats a good thing. I like decentralized.<p>Zig is going to be what I build my next &quot;fun&quot; project in. Im actually excited to spend that time when I find it. I haven&#x27;t felt that way about something new in a long time.
dureuill11 个月前
This feels very shortsighted to me.<p>&quot;Easy to learn&quot; and &quot;easy to hire for&quot; are an advantage in the first few weeks. Besides, we now have data indicating that ramp up time in Rust is not longer than in other languages.<p>On the other hand, serving millions of users with a language that isn&#x27;t even v1 doesn&#x27;t seem very reasonable. The advantages of a language that is memory safe in practice and also heavily favors correctness in general boosts productivity tenfold in the long term.<p>I&#x27;m speaking from experience, I switched from C++ to Rust professionally and I&#x27;m still not over how more productive and &quot;lovable&quot; the language in general is. A language like zig isn&#x27;t bringing much to the table in comparison (in particular with the user-hurting decisions around &quot;all warnings are errors, period&quot;)
评论 #40737566 未加载
评论 #40736350 未加载
rapsey11 个月前
These kinds of posts can pretty much always be summerized down to that is what we wanted to use. The arguments are very weak and unconvincing.<p>People love to say, use the right tool for the job but no one actually does it.<p>Developers will use what they know or what they feel comfortable using.
samwillis11 个月前
I think it&#x27;s interesting to observe the development speed of Bun vs Deno when comparing Zig and Rust.<p>Bun is written in Zig and links to the WebKit&#x27;s JavaScriptCore.<p>Deno is written in Rust and links to V8.<p>It seems to me that the development of Bun is significantly faster than Deno, how much of that is down to the easy of interoperability of Zig and C&#x2F;C++ vs some of the hoops you have to jump though when using Rust with a C&#x2F;C++ lib?<p>(I may be wrong on this an the Bun team are just exceptionally quick)
评论 #40736366 未加载
evmar11 个月前
&gt; Zig works with debuggers our developers know out of the box.<p>Is this not true of Rust? I use lldb via terminal and VSCode with Rust, I am not sure what I&#x27;m missing.
评论 #40736109 未加载
评论 #40736085 未加载
sedatk11 个月前
Zig is basically a more ergonomic C while Rust is an entirely different memory-safe language. I don&#x27;t see why Rust would ever get picked over any other language if high-performance memory safety isn&#x27;t a priority. And, if it IS a priority, I don&#x27;t see why anyone would pick any language other than Rust.
评论 #40736159 未加载
评论 #40736573 未加载
评论 #40736181 未加载
评论 #40736185 未加载
greenavocado11 个月前
The author redacts so many interesting details about his employer which apparently serves hundreds of millions of requests per day. How peculiar.
评论 #40736113 未加载
评论 #40736162 未加载
devnull311 个月前
C-interop while certainly more involved in Rust compared to Zig, it is generally a one-off effort (for most projects). wards it&#x27;s generally an incremental effort to map additional C code. I am not sure I would make this an important factor but to each his own.
vander_elst11 个月前
&gt; Memory safety and &quot;no undefined behaviors&quot; (obviously untrue, but that was the belief and part of the conversation we had to have<p>Trying to better understand this claim, is it because also unsafe rust exists?
评论 #40736175 未加载
jpc011 个月前
A question for those who are in the Zig camp.<p>I&#x27;ve heard talks that zig is now mostly stable and there are no big api changes expected but I haven&#x27;t been able to find any official statement on that, is this true?
评论 #40743586 未加载
l5870uoo9y11 个月前
Zig language mentioned in the post: <a href="https:&#x2F;&#x2F;ziglang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ziglang.org&#x2F;</a>
评论 #40736056 未加载
评论 #40736117 未加载
评论 #40736303 未加载
OutOfHere11 个月前
How did you learn Zig if it has no book?
评论 #40737847 未加载
评论 #40737685 未加载
评论 #40750302 未加载