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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Criticizing the Rust Language, and Why C/C++ Will Never Die

6 点作者 pyprism超过 7 年前

1 comment

topspin超过 7 年前
Myopic rant.<p><pre><code> &quot;If your C++ code is not good enough or Java code is painfully slow, it&#x27;s not because the technology is bad - it&#x27;s because you haven&#x27;t learned how to use it right.&quot; </code></pre> More &#x27;program better and you don&#x27;t need Rust.&#x27; This was said of C++ by C programmers and it regresses until we&#x27;re programming punch cards in octal.<p>At one point the argument is (indirectly) made that Rust is on the &quot;innovative yet too idealistic&quot; side of the ledger. This is bogus; Rust is pragmatic. Otherwise release code would pay the cost of detecting integer overflows and unsafe wouldn&#x27;t exist. Rust just doesn&#x27;t cop out on all the stuff that _can_ be dealt with in a reasonable manner.<p><pre><code> &quot;static and dynamic analyzers [exist for C++]&quot; </code></pre> Dismissing the obvious value of providing one uniform and precise analyzer integrated into the compiler is just bad thinking.<p><pre><code> &quot;But these are actually two dialects of one language&quot; </code></pre> Unsafe changes a small and finite set of rules. It is an outrageous exaggeration to claim a new &#x27;dialect&#x27; is created by unsafe.<p>At one point the following construct rears it&#x27;s ugly head again. It&#x27;s become a favorite for Rust haters:<p><pre><code> Vec&lt;Rc&lt;RefCell&lt;Box&lt;Trait&gt;&gt;&gt;&gt; </code></pre> The cause of this somewhat unergonomic construct was dealt with over two years ago[1], and a workable alternative using Cell&lt;&gt; existed at the time. Also, how does a C++ advocate look at that type and somehow imagine it to be worse that the utterly incomprehensible line noise that C++ templates routinely devolve into? Hell, almost any given pointer to function in C is that bad or worse.<p><pre><code> &quot;it doesn&#x27;t have a decent inheritance and exceptions&quot; </code></pre> C++ doesn&#x27;t have &#x27;decent&#x27; inheritance either; most C++ programmers don&#x27;t even understand how inheritance in C++ actually works. Arguing that the lack of exceptions in Rust is somehow a problem is deeply wrong; better and well defined alternatives are provided. C++ exceptions are a failed language feature and an enormous fount of UB. In all likelihood you&#x27;re reading this using a browser written by developers that have banned C++ exceptions from their code bases (Google and Mozilla.)<p><pre><code> &quot;Rust is safe indeed but, unfortunately, far from fast&quot; </code></pre> The one Computer Language Benchmarks Game benchmark cited here is cherry picked. Rust does very well against C++ in that set of benchmarks, winning 6 of 10 at the moment and only a little less well against C. And we all know the sort of issues inherent to those benchmarks; citing them without qualification is either poor thinking or an insult to your intelligence. Two terrible alternatives.<p><pre><code> &quot;Macros used as a crutch to make up for the excessive verbosity caused by the absence of normal exceptions&quot; </code></pre> That doesn&#x27;t make sense. <i>mic drop</i><p>[1]<a href="https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;24619" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;pull&#x2F;24619</a>
评论 #15789128 未加载