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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Why I moved from Rust to simpler, cleaner C

40 点作者 FascinatedBox大约 8 年前

6 条评论

gpm大约 8 年前
This appears to be a april fools joke... judging by the Repo Lily was always written in C [0].<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;FascinatedBox&#x2F;lily&#x2F;tree&#x2F;9ed9a706e0a1f99ff271cde132b73664e9bf3ff8" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;FascinatedBox&#x2F;lily&#x2F;tree&#x2F;9ed9a706e0a1f99ff...</a> (Tree at a random commit a while back)
评论 #14015436 未加载
评论 #14015478 未加载
评论 #14015537 未加载
buzzybee大约 8 年前
I liked the part about the parser not benefitting from memory safety(parsers are a classic source of CVEs).
starik36大约 8 年前
I checked out the Lily tutorial (<a href="https:&#x2F;&#x2F;fascinatedbox.github.io&#x2F;lily-site&#x2F;tutorial.html" rel="nofollow">https:&#x2F;&#x2F;fascinatedbox.github.io&#x2F;lily-site&#x2F;tutorial.html</a>) and the syntax is unusually clean. Really cool!
hawkice大约 8 年前
I mean, this is great, obviously. True spirit of the holiday.<p>That being said, rustc _is_ slow.
评论 #14015427 未加载
评论 #14015801 未加载
bascule大约 8 年前
I can&#x27;t tell if this is an April Fool&#x27;s joke or not. If it is, congratulations, troll successful. But I&#x27;m going to go ahead and reply anyway...<p>There are exactly two valid* points in this post:<p><pre><code> - rustc is slow - &quot;the circlejerk&quot; </code></pre> * i.e. not completely without merit<p>I&#x27;ll just go through these really quick:<p>1. rustc is slow<p>Rust just shipped (in beta) incremental compilation, a technique commonly used by compilers to speed up recompiles:<p><a href="https:&#x2F;&#x2F;internals.rust-lang.org&#x2F;t&#x2F;incremental-compilation-beta&#x2F;4721" rel="nofollow">https:&#x2F;&#x2F;internals.rust-lang.org&#x2F;t&#x2F;incremental-compilation-be...</a><p>This doesn&#x27;t change the fact rustc is slow, but it certainly makes the developer experience much better. Try it out!<p>That said, rustc is still slow. A valid complaint.<p>2. rust needs unions<p>Rust has two types of unions:<p><pre><code> - tagged unions a.k.a. sum types. These are preferred - #[feature(untagged_unions)]: actual C-style unions, unsafe, useful for C interop </code></pre> You probably want the first kind. Rust does have them!<p>3. linked lists are great<p>Linked lists are great! I use them in one of the main Rust programs I&#x27;m working on. The thing about Rust linked lists is how you write one will depend entirely on your memory model.<p>One of the best tutorials on Rust explains the language&#x27;s memory model in terms of linked lists. It&#x27;s a great read, a harrowing tale of &quot;fighting rustc&quot; until you achieve victory:<p><a href="http:&#x2F;&#x2F;cglab.ca&#x2F;~abeinges&#x2F;blah&#x2F;too-many-lists&#x2F;book&#x2F;" rel="nofollow">http:&#x2F;&#x2F;cglab.ca&#x2F;~abeinges&#x2F;blah&#x2F;too-many-lists&#x2F;book&#x2F;</a><p>I&#x27;m using immutable arena-allocated linked lists, which is a great pattern. This is in conjunction with tagged unions, and together I have an immutable sum type + list memory model for a sort of Lisp-alike VM.<p>I did have to implement my own linked lists. The code is not terribly complicated. It&#x27;d be nice if there were standard one-size-fits-all linked lists in e.g. the &quot;collections&quot; module, but the type system needs a bit more work before it will be generic enough for that to be a good idea. Until then, you&#x27;ll have to write your own or use a library given your unique constraints. But that&#x27;s not really different from C...<p>4. &quot;the circlejerk&quot; a.k.a. the community<p>If you dislike the community there&#x27;s not a lot to say. It&#x27;s probably a bad idea to use a language whose community you dislike.<p>I personally think Rust has a great community.<p>5. rust&#x27;s safety is overrated<p>C programmers routinely make memory safety mistakes, even if they&#x27;re experts, even if they&#x27;re using static analysis tools. You don&#x27;t have to use Rust to have a safe memory model... any JVM language or most other managed language runtimes will do.<p>If you&#x27;re writing a trivial C program it&#x27;s possible it&#x27;s safe. But it only takes one mistake for things to go from safe to catastrophic in C.
评论 #14015454 未加载
yandrypozo大约 8 年前
&gt; &quot;Every time there is a post on Hacker News or Reddit about a vulnerability in C, the strike team comes out to mention a rewrite in Rust&quot;<p>I thought it was only happening with Go posts, but I can see it&#x27;s happening with C and C++ too, which other programming language do you know is suffering Rust attacks ??