(评论)
(comments)

原始链接: https://news.ycombinator.com/item?id=43691856

这篇 Hacker News 帖子讨论一篇关于两年 Rust 经验总结的博文。评论者关注几个关键痛点。一位用户指出了原文中的一个错别字。另一位建议构建一个借用检查器可以作为很好的本科生项目。几位评论者批评了 Rust 的模块/板条箱系统,认为将代码分割成单独的板条箱很麻烦,并渴望 Go 更简单的依赖管理。一位用户详细介绍了 Rust 的各种“万物类型”(值、引用、原始指针)以及理解这些类型如何帮助解决借用检查器问题。最后,提到了 `build.rs` 可能是 Cargo 相关挫折的来源,这与作者的积极评价相矛盾,并附上了 Bevy 在改进 Rust 构建性能方面工作的链接。整体基调是建设性的批评,并希望改进开发者工具和清晰度。

相关文章
  • (评论) 2025-03-14
  • (评论) 2025-04-09
  • (评论) 2024-08-25
  • Rust 值得吗? 2023-10-27
  • (评论) 2024-07-22

  • 原文
    Hacker News new | past | comments | ask | show | jobs | submit login
    Two Years of Rust (borretti.me)
    22 points by todsacerdoti 1 hour ago | hide | past | favorite | 5 comments










    Please don't take this the wrong way, it's just the editor in me.

    There's a typo at the end of the Error Handling section:

    When you need to explicitly handle an error, you omit the question mark operator and use thw Result value directly.



    > Personally I didn’t have borrow checker problems, but that’s because before I started using Rust at work I’d designed and built my own borrow checker. I don’t know if that’s a scalable pedagogy.

    Yeah... maybe not, but I can see this being a project in an undergraduate course.



    My biggest issue with rust after two years is just as you highlight: the mod/crate divide is bad!

    I want it to be easier to have more crates. The overhead of converting a module tree into a new crate is high. Modules get to have hierarchy, but crates end up being flat. Some of this is a direct result of the flat crate namespace.

    A lot of the toil ends up coming from the need to muck with toml files and the fact that rust-analyzer can’t do it for me. I want to have refactoring tools to turn module trees into crates easily.

    I feel like when I want to do that, I have to play this game of copying files then playing whack-a-mole until I get all the dependencies right. I wish dependencies were expressed in the code files themselves a la go. I think go did a really nice job with the packaging and dependency structure. It’s what I miss most.



    Gripes about the borrow checker I think would be cured with the following surprising fact, and interesting "problem solving" approach to the language's design:

    In Rust there's at least 5 types of everything, in order of strength:

    - Value / unqualified

      - Generically, T
    
      - Optionally mutable
    
    - Mutable Reference

      - &mut T
    
      - you can only have one of these for a given value
    
    - Reference / Shared reference

      - &T
    
      - you can have arbitrarily many for a given value
    
    - Raw constant pointer

      - *const T
    
      - you can have arbitrarily many, and they're not liveness checked
    
    - Raw mutable pointer

      - *mut T
    
      - you can have arbitrarily many, and they're not liveness checked
    
    Now I say at least because things get appreciably more complicated when you find yourself dealing with lifetimes which apply to "References", those are indeed themselves types, but ultimately represent a compiler-executed calculus regarding liveness relative to some Value.

    They also can 'fan out' like a multiple-dereference pointer, but the tricky part is how the APIs for Types conform to these, for example;

    Since there are 3 different types of things in a collection, then there are 3 different ways to iterate over them `iter()`, `iter_mut()`, `into_iter()` in increasing order of strength. Most of the breadth or early complexity arises from the urge to treat these as a distraction, rather than a fundamental aspect of systems code.

    Crates / modules are a bit of a meme: https://www.reddit.com/r/rust/comments/ujry0b/media_how_to_c...

    Bevy has done some work investigating build performance: https://bevyengine.org/learn/quick-start/getting-started/set...



    > with cargo you praise the absences: there’s no gotchas, no footguns, no lore you have to learn in anger, no weirdness, no environment variables

    Suppose the author doesn't use build.rs, which appears to have been composed of the listed things almost entirely.







    Join us for AI Startup School this June 16-17 in San Francisco!


    Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact



    Search:
    联系我们 contact @ memedata.com