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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Rust Criticism from a Rustacean

55 点作者 nikbackm将近 2 年前

16 条评论

jcranmer将近 2 年前
When it comes to linking against the kernel, it is worth remembering that of the major operating systems, there is but one where the stable kernel interface is the syscalls directly--Linux. If you use Windows, the stable interface is linking against kernel32. If you use Darwin or the BSDs, your stable interface is libc (and for some of them, there&#x27;s no stable <i>ABI</i>, only a stable C <i>API</i>). Note that Go has given up trying to avoid using libc on these systems, which should be a sign of how fantastical the idea of a pure, non-C system is for the foreseeable future.
评论 #36240932 未加载
评论 #36240972 未加载
评论 #36240893 未加载
jstx1将近 2 年前
The worst thing about Rust is easily the community - lots of drama and arguments, people building their personalities about something trivial like which programming language they use because it makes them feel superior, and many fans of Rust refusing to listen to any criticism of the language. It&#x27;s a designed-by-committe language with a cult around it which might be the worst possible combo.<p>The second worst thing is how difficult to use it is which makes it not worth it for problems where you can use a higher-level garbage-collected language.
评论 #36240861 未加载
评论 #36240764 未加载
评论 #36240796 未加载
insanitybit将近 2 年前
&gt; Your systems programming language should be capable of interop with other languages but probably shouldn&#x27;t require calling into C just to provide full functionality, such as interacting with the kernel.<p>Why tho? Like, that&#x27;s how C and C++ do it, right?<p>&gt; All you can do is live with it and realize that if you are that low on memory, the OS is likely going to be killing processes anyway. That said, I don&#x27;t like the way Rust is inconsistent here. Rust normally enforces correctness, yet turns around and treats memory as an inexhaustible resource, ignoring or handicapping a lot of potential use cases for the language.<p>I think it would be more accurate to say that this is an issue of the standard library, not the language. And it&#x27;s true, if you want to write certain types of software you need to throw away std.<p>&gt; You can, at least in this particular case, have your cake and eat it, too.<p>Emphasis on &quot;in this particular case&quot; ? &quot;Macros are a mistake&quot; is a very broad, sweeping statement. I think it would be more accurate to say &quot;Macros should not be a replacement for other forms of metaprogramming&quot;.<p>Having a native, supported language for compile time reflection is a powerful thing. If Rust one day gets it, that will be cool. I don&#x27;t think macros are going to be a mistake on that day, they have gotten us extremely far at a very low implementation cost.]<p>&gt; But at this point I just don&#x27;t see anyone realistically switching to a std-2.0.<p>Well, to be fair, I think the vast majority of developers using Rust do not care about linking to libc or handling allocation errors and actually prefer things this way.<p>I agree that comptime would be cool. Personally, I don&#x27;t think I&#x27;d want the other changes - I definitely prefer Rust stays on Github, for example.
评论 #36241063 未加载
tialaramex将近 2 年前
I can&#x27;t tell whether the author doesn&#x27;t know, or is pretending to have no idea, that most systems do not offer a stable system call ABI.<p>Windows is the most obvious example. Microsoft does not officially document most of their system calls, and makes no promises that they work how you think they do&#x2F; how your unofficial documentation claims they do, or that what worked yesterday will keep working, the official documented APIs are to userspace code that you didn&#x27;t write.<p>But this is also common on the other Unix systems besides Linux. You define the libc API as what you&#x27;re promising and then you deliver or don&#x27;t deliver features in your syscall ABI and the libc handles the slack.
thadt将近 2 年前
Coming from outside, the take on macros resonates. Working with modern &#x27;Rust&#x27; The Language is rather nice. But when one of my first main projects was to add support for a serialization format with Serde, running into macros feels like running into a wall. It&#x27;s a whole next level of complexity and poor tooling support (at least at the time).<p>Granted, I&#x27;ve had similar feelings about C++&#x27;s template shenanigans, so take it with a grain of salt. Zig&#x27;s comptime feels like a breath of fresh air in comparison.
评论 #36243754 未加载
EscapeFromNY将近 2 年前
The article skips directly from #4 to #6, so I&#x27;ll nominate something for #5: ranges should not be iterators. Instead they should impl IntoIterator and the iterators should be separate types. That way ranges can impl Copy without any issues. <a href="https:&#x2F;&#x2F;kaylynn.gay&#x2F;blog&#x2F;post&#x2F;rust_ranges_and_suffering" rel="nofollow">https:&#x2F;&#x2F;kaylynn.gay&#x2F;blog&#x2F;post&#x2F;rust_ranges_and_suffering</a>
评论 #36243725 未加载
JodieBenitez将近 2 年前
Not a Rust user, so not some intelligent criticism... but boy how Rust source codes hurt my eyes ! Things like this:<p><pre><code> &lt;&#x27;_&gt; #[] stuff::thing::blah @gloop(gloop) if(fizz) |buzz| .Meh =&gt; |wtf| </code></pre> I know, I know... you probably get used to it once you understand the semantics and it&#x27;s subjective anyway and and and... but still, not all languages I know repel me visually.
评论 #36241106 未加载
评论 #36241534 未加载
评论 #36241049 未加载
orf将近 2 年前
Interesting article, but:<p>&gt; Then there&#x27;s the issue that the crates.io registry is on GitHub, and only GitHub, and in order to publish on crates.io you have to have a GitHub account<p>This isn’t true. Crates.io publishes metadata to a GitHub repo, but that’s decoupled from them only supporting Github as a SSO.
评论 #36240597 未加载
jmull将近 2 年前
&gt; ...I&#x27;m actually looking for &quot;the next language&quot; to come after [Rust].<p>It would really be a better approach to work on getting Rust to adopt the features of Zig you&#x27;re looking for. The work it goes into developing a language into a mature option is absolutely massive. Developing a full-featured language, building a (healthy) community around it, building dev mindshare&#x2F;marketshare, building trust that it&#x27;s sustainable, etc is a many-years effort by many talented and dedicated people. It&#x27;s a huge amount of work when you could achieve the same output by adding a certain feature or two to rust.<p>Of course the leadership is a bit broken right now, but they may (or may not) be able to fix it.<p>There&#x27;s also the Typescript approach. That is, extend rust with a comptime feature wrapper. Not nearly as elegant, but you don&#x27;t need to work with broken rust leadership to develop it and, if it gains traction, you may then have the leverage to get it rolled in to the real thing (if you even want to at that point).
评论 #36241172 未加载
noelwelsh将近 2 年前
&gt; &quot;The concept of generics is only possible with some sort of compile time reflection in any language&quot;<p>This is not true.<p>* The standard implementation technique is to box everything (have a uniform in-memory representation for all types). Monomorphization[1], which is the compilation strategy used by Rust, C++, and I guess Zig, requires type knowledge at compile-time.<p>* Generic functions should not have any knowledge of the concrete types of the values they are passed, as this breaks an abstraction boundary. Theorems for free[2] is about this idea.<p>[1]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Monomorphization" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Monomorphization</a><p>[2]: <a href="https:&#x2F;&#x2F;www2.cs.sfu.ca&#x2F;CourseCentral&#x2F;831&#x2F;burton&#x2F;Notes&#x2F;July14&#x2F;free.pdf" rel="nofollow">https:&#x2F;&#x2F;www2.cs.sfu.ca&#x2F;CourseCentral&#x2F;831&#x2F;burton&#x2F;Notes&#x2F;July14...</a>
评论 #36241358 未加载
einpoklum将近 2 年前
&gt; In the meantime, you can and should use Rust. In spite of any shortcomings it&#x27;s still the best language that has come so far in terms of enforcing memory access safety and overall correctness<p>1. I don&#x27;t think programming languages can &quot;enforce correctness&quot;. (Although I will say that my general experience is that functional languages, not Rust, tend make it more difficult to get things trivially incorrect.)<p>2. I&#x27;m not sure that&#x27;s a good enough reason to use Rust. I mean, sure, Rust is usable, people do things with it, but - my biased experience is that at some point you just go C++ for some reason, and stay there.
sam0x17将近 2 年前
As an avid rust proc macro crate author, the zig macro example is quite humbling. I would welcome this kind of reflection and comptime stuff in place of (or more likely, in addition to) the existing macro systems (decl macros, and proc macros) that we have in rust.<p>Proc macros are particularly awkward because of the requirement that they must be defined in a separate proc macro crate. There are all sorts of things one could do if it were possible to instead make proc macros that generate proc macros _in place_ like one can with decl macros.<p>Then there is also the issue of macro expansion... the rustc framers openly admit that with an expression like foo!(bar!(..)) it is often preferable to have bar!(..) expand _before_ foo!(..) expands, because they have hacked in this behavior for several of the built-in macros like `concat!`, however this behavior is completely unavailable for custom macros. In fact, this one little issue is the ONLY blocker to all kinds of exotic and powerful behavior, the lack of which is holding the ecosystem back, for example the ability to eagerly expand a series of macro calls would enable the following things:<p>* the ability to determine the column, line, and source file in which a macro is being called, at compile-time<p>* the ability to determine the module path of the caller of your macro, at compile time<p>* the ability to determine the name of the crate in which a macro is being called, at compile-time<p>* the ability to implement complex compositional behavior purely in proc macros<p>* (very important) the ability to determine the `CARGO_MANIFEST_DIR` of the crate in which a macro is being called. Without this key ability, it is impossible to reliably determine where we are executing so we can do things like read metadata configuration values from _the caller&#x27;s_ `Cargo.toml` at compile-time.<p>So yeah, really hoping at least eager expansion stabilizes sometime soon, but this zig stuff would be even better.<p>Some of my crates that would benefit from this:<p>* docify: <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;docify" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;docify</a><p>* macro_magic: <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;macro_magic" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;macro_magic</a><p>* crate-settings (non-functional until this comes out): <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;crate-settings" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;crate-settings</a><p>* proc-utils: <a href="https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;proc-utils" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;proc-utils</a>
eviks将近 2 年前
Comptime on its surface is such a better alternative to macros, the fact that you don&#x27;t need to learn another DSL is huge (and all the tooling works at is)<p>Would it be a major challenge to add it to Rust?
anon23432343将近 2 年前
For me it is the crates not having something like a namespace.<p>Something like this: @org&#x2F;axum @user&#x2F;axum
评论 #36240684 未加载
评论 #36240695 未加载
titzer将近 2 年前
I think Rust should be bold and stop depending on C for anything. It&#x27;s gaining enough momentum that eventually it should force kernels to be like Linux and adopt a stable ABI. In practice, most kernels have a &quot;fairly stable&quot; ABI just because coordinating kernel changes with userspace libc changes is tricky.
评论 #36246958 未加载
评论 #36241325 未加载
hurril将近 2 年前
Who&#x27;s going to tell him that comptime functions is what macros are?
评论 #36244071 未加载