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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: What was your biggest mental shift when learning Rust?

4 点作者 mrburton超过 5 年前

1 comment

sudeepj超过 5 年前
Ownership. There are other things but this is the single biggest adjustment one will have to make.<p>In other languages say C++&#x2F;Go&#x2F;Python, you have a shared buffer in two threads. Both threads have mutable access to it but you <i>know</i> only one of them is modifying it at any point of time (because you wrote it :) ). This is not good enough in Rust. You will have to <i>prove</i> it to the Rust compiler at <i>compile time</i> that this invariant is true. In Rust you express this using its type system. Syntactically &amp; semantically it is very different than other languages.<p>The implication of the above is that in Rust you will have think a lot about your code structure &amp; data-flow upfront compared to other languages else you will hit the wall very frequently. Some people say this is how it should be anyway &amp; others think it as impediment to the productivity. Both points are valid in my opinion ... it more of a question of cost vs benefit.