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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Mojo vs. Rust: is Mojo faster than Rust?

54 点作者 samuell超过 1 年前

11 条评论

pornel超过 1 年前
They have some promising features, but they need to learn Rust before dissing it. Their explanations have inaccuracies, and examples have novice mistakes.<p>• There&#x27;s no implicit string copying in Rust. Even when passing String ownership, it will usually be passed in registers. It&#x27;s idiomatic to use &amp;str by default.<p>• Rust doesn&#x27;t do eager drop, but their explanation is clumsy. The borrow checker doesn&#x27;t influence destructors. &amp;String and usize can&#x27;t have a destructor, and can be forgotten at any time.<p>• Their benchmark intended to demonstrate tail call cost compiles to a <i>constant</i>, with no `factorial()` calls at run time. They&#x27;re only benchmarking calls to black_box(1307674368000). Criterion put read_volatile in there. Mojo probably uses a zero-cost LLVM intrinsic instead.
评论 #39354163 未加载
devit超过 1 年前
Rust uses all zero-cost abstractions except for bounds checking and integer overflow checking, so no language can be faster than Rust (assuming equal quality implementations) unless it either isn&#x27;t memory safe or it can statically prove bounds more frequently, which pretty much requires dependent types (but current languages with dependent types box everything AFAIK so they are terrible performance-wise).<p>Mojo seems to not only not lack dependent types but also lack first-class references with lifetimes and no lifetime kind, only having borrowed function arguments.<p>So the answer is no, it is going to be slower since some patterns cannot be expressed and would require costly abstractions.<p>For example, it looks like that in Mojo an hash table lookup requires to copy the value, while Rust just returns a reference to the value inside the hash table, which it can do since it can express that the return value has the same lifetime as the self parameter because Rust has first-class lifetimes and references (although in this case they can be elided).
评论 #39359608 未加载
评论 #39354236 未加载
lazzlazzlazz超过 1 年前
How is Mojo going to handle dependencies? This is something that Rust handles much better than Python with essentially no debate. Copying from Python here would be a huge error. How can we guide Mojo toward something closer to Crates?
评论 #39354245 未加载
minraws大约 1 年前
I am interested in Mojo but this is not the way of comparing languages. The author seems to be novice Rust user with no practical experience in serious Rust projects.<p>They are comparing orthogonal components and features. CoW works in Rust as well, you can use impl Into for much greater performance and ease of use. dbg macro being questioned is just farcical, it&#x27;s use of T is justified cause it returns T back. You can&#x27;t accept &amp;T and return T in Rust.<p>Furthermore I am not sure what they are trying to prove with this article. I would use Mojo if it was open source, and even just 10-20x faster than Python rather than 100x if it supported entirety of Python ecosystem.<p>And I work in Open Source AI Platforms as my day job. Why write this nonsensical post, is this for clicks??<p>If I see another post like this I might just stop caring about Mojo from now on.<p>Why pay attention when devs are more interested in flexing than making their work open source? Is this some sort of scam? Will you make it Business Source License? Will and when will it support all of Python ecosystem? Are alot more important questions for me.<p>Also perhaps improve Python&#x27;s tooling while at it. Astral.sh folks made ruff and uv, Prefix folks made rip, pixi and rattler-build... Maybe now improve something else?
alchemio超过 1 年前
I’m excited to try mojo. I just don’t wanna create an account just to try it.
评论 #39351668 未加载
评论 #39352663 未加载
wolfspaw超过 1 年前
Nice, Mojo seems awesome.<p>It has better ergonomics than Rust, and the same performance ballpark (or better?)<p>I Just don&#x27;t trust closed source PLs...
DrMeepster超过 1 年前
You don&#x27;t actually explain why Mojo doesn&#x27;t need Pin, you just say that it works. Does Mojo automatically fix up self referential pointers on moves or something?
az09mugen超过 1 年前
One thing I don&#x27;t like about Rust is its verbosity in writing code. It&#x27;s nice it borrowed some concepts from functional programming and other niceties but heck, why make the syntax so long and complex ? Same as Java in a way, it&#x27;s like people love to create 3 km-long function names in a standalone file lost inside 4 levels of folders. Why ? I&#x27;d rather prefer the syntax of Mojo which reminds me the simplicity of Python&#x2F;Julia&#x2F;Ruby&#x2F;Haskell. I&#x27;m not saying all the languages should look like these and for example PHP, Scala, Kotlin, Golang are quite OK in my opinion. I&#x27;m not talking about performance, but ease of use, readability, conciseness, have no non-sense,... Programming languages should be built for humans in the first place, at least I think.<p>&lt;&#x2F;rant&gt;
评论 #39354216 未加载
hulitu超过 1 年前
&gt; Mojo vs. Rust: is Mojo faster than Rust?<p>The better question will be: Can you compile mojo ? Because for rust you seem to need (i was never able to do it) specific rust compiler versions to compile the current one.
samuell超过 1 年前
I know the last couple of Mojo posts have sparked some controversy, but thought this post at least clarified a few things so worth a read I think.
johnwick666大约 1 年前
no