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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

“I just started writing some Rust”

64 点作者 whoisnnamdi超过 6 年前

7 条评论

twic超过 6 年前
&gt; &quot;Yup, all the things you mentioned are also available in C++, and you&#x27;ve been ignoring and criticizing them for years&quot;<p>Even that&#x27;s not true.<p>One of the practically valuable things about Rust is that it has a decent and standardised package manager and build tool. C++ does not, and is nowhere close to having that.<p>Another is that the Rust libraries use iterators as a straightforward, composable, and efficient way to write operations on streams of values. The C++ standard library doesn&#x27;t have anything like that.<p>Rust has a really powerful macro system. C++ doesn&#x27;t. It has template metaprogramming, which can do most of what macros can, but it&#x27;s agony to use. C++ is getting some really powerful compile-time programming facilities, but those aren&#x27;t in a standard yet.<p>There are a lot of things in Rust that are in C++. There are things in C++ that are not in Rust (some of them even useful!). But there are things in Rust that aren&#x27;t in C++, and when C++ loyalists say there aren&#x27;t, they just look stupid.
评论 #19009775 未加载
评论 #19009733 未加载
评论 #19009911 未加载
ilovecaching超过 6 年前
Rust makes things that are technically possible to do in C++, easy to do.<p>Rust makes things that are painful to do in C++, pleasant to do.<p>Rust takes your template compiler errors, and gives you beautiful type parameter errors with underlines.<p>Rust takes your scary macro and turns it into a sanitary macro.<p>Rust takes your crazy diamond of death and towers of inheritance, and gives you traits, associated types, and composition.<p>Rust takes your runtime variant and insane union and gives you real sum types.<p>Rust takes your ASAN, Valgrind, debug alloc builds, and hopes and prayers, and gives you a compiler that let&#x27;s you use memory safely.<p>Rust is like C++ without the jagged edges, the specification no one understands, removes the dangerous bits that no one person can keep in their head, and trades the useless abstractions for nice functional abstractions that actually are an improvement over writing C.
mastax超过 6 年前
I&#x27;m a big fan of Rust, and seeing that Carmack writes it gives me warm fuzzy feelings.<p>But this link is mostly content-free, and I don&#x27;t think it&#x27;s the type of link that inspires useful discussion. I wish that HN had downvotes on posts, though I suppose it uses several other methods.
评论 #19010001 未加载
评论 #19009870 未加载
评论 #19009854 未加载
noobiemcfoob超过 6 年前
What is meant by people look to other languages more often because you can do something in C++?<p>&#x2F;My rephrasing, but I can&#x27;t parse Carmack&#x27;s point
评论 #19009624 未加载
bsurmanski超过 6 年前
For anyone else looking into Rust, I&#x27;ve been experimenting in it for the past month. Heres my thoughts:<p>It advertises itself as a systems level language for the new age, but to me it feels like a functional language in disguise. The borrow checker enforces an unchained functional style (You may have 1 unique mutable reference or may have many immutable references). This sounds bad if you&#x27;re used to pointer slinging, but once you get used to the peculiarities I find it forces me to write better quality code.<p>The package management is the most refreshing feature. It&#x27;s a pain to rewrite my personal libraries in each language I use, but I found that most of the things I needed were already available at higher quality than I would have done. (And using them is a single config line).<p>For a &#x27;low level language&#x27; they make it pretty hard to do some &#x27;low level&#x27; things. Example&#x27;s I&#x27;ve found include:<p>* writing a doubley linked-list. Consensus is &quot;don&#x27;t use linked-lists. The stdlib has better tools<p>* Reading a file into a struct. They make it surprisingly difficult to say &quot;hey, read these 10 bytes, its this struct&quot;. Consensus is to use more structured file formats like json or protobufs. There&#x27;s libraries for reading those things.<p>Error handling is similar in style to Go, but it get rid of a lot of the boilerplate. The &#x27;?&#x27; operator effectively acts as if err return err.<p>The macro system is really nice. I don&#x27;t write many macros, but it does mean I can use other people&#x27;s powerful macros. My favorite are &#x27;include_bytes!&#x27;, &#x27;lazy_static!&#x27; and &#x27;dbg!&#x27;. The new procedural macros are pretty wacky, essentially allowing you to parse or rewrite the AST. A powerful example I&#x27;ve seen is static checks; This [0] example writes a compile time check to assert that structs do not contain a member named &#x27;bees&#x27;.<p>Overall it&#x27;s been a fun language to mess around with.<p>[0] - <a href="https:&#x2F;&#x2F;tinkering.xyz&#x2F;introduction-to-proc-macros&#x2F;" rel="nofollow">https:&#x2F;&#x2F;tinkering.xyz&#x2F;introduction-to-proc-macros&#x2F;</a>
评论 #19027906 未加载
评论 #19009956 未加载
评论 #19009990 未加载
评论 #19009929 未加载
vertline3超过 6 年前
As soon as I saw it was just a quote, I had this gut instinct it would be Carmack speaking. The reason is because when DirectX was really marketing hard, Carmack did some work in OpenGL and stood up for it. It was kind of important to me since it was open.
inherentFloyd超过 6 年前
I have never done anything in Rust. Are there any benefits? Any drawbacks?
评论 #19009783 未加载
评论 #19009867 未加载
评论 #19009865 未加载
评论 #19009773 未加载
评论 #19010580 未加载
评论 #19009753 未加载