this post was submitted on 14 May 2025
30 points (96.9% liked)

Rust

6921 readers
35 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
top 8 comments
sorted by: hot top controversial new old
[–] [email protected] 13 points 4 days ago (1 children)

Turn on all clippy lints on day one – even the pedantic ones. Run the linter and follow the suggestions religiously. Don’t skip that step once your program compiles.

There's a bunch of clippy groups to enable, but IME the pedantic ones can be kinda … not what you want. Especially the one about unnecessary moves annoy me, as it suggests what I consider an unnecessary long lifetime for a value instead.

[–] [email protected] 3 points 4 days ago

TIL about clippy::cargo. Thanks!

[–] [email protected] 7 points 4 days ago (1 children)

As someone whose only other language was very beginner-level Python before learning Rust, the part about not treating the borrow checker as an adversary, but as a companion, mirrors the point at which I began rapidly improving.

I like to say that the Rust compiler rules are like having a senior engineer over your shoulders to help you avoid writing (certain kinds of) bad code.

There are still times when the borrow checker becomes my adversary (like needing to share data in threads), and it is painful, but they become less frequent over time.

[–] [email protected] 5 points 4 days ago* (last edited 4 days ago) (1 children)

Yep. One reason why those situations become less frequent over time is that one learns to avoid such designs. Thought process: "Sharing data across threads is annoying. So I'd rather avoid it. Maybe message passing can solve the same problem as well?"

[–] [email protected] 2 points 4 days ago* (last edited 4 days ago)

I just use Arc::clone() now that I know I can just throw the problematic data types on the heap easily. I'm sure there are "better" ways to do it, but ¯\_(ツ)_/¯

[–] nous 8 points 4 days ago

Some people might dismiss Rust as being “unelegant” or “ugly”, but the verbosity actually serves a good purpose and is immensely helpful for building large-scale applications:

Here rust is trying to be unambiguous by forcing you to write just enough context when needed. It is not unnecessarily verbose at all and is not trying to be absolutely explicit about everything. When there could be more ambiguity, rust errs on the side of being more explicit which increases the verbosity. But when it is less ambiguous then it favors being less explicit. Hence why you can omit types and lifetimes in most situations but require them when it is not obvious what they should be.

[–] [email protected] 4 points 4 days ago

I'm not new to Rust, but still a novice. And already loving the first point you make. This article is great (so far).

[–] [email protected] 1 points 3 days ago* (last edited 3 days ago)

Pretty good read. Nothing very surprising and I might make the same kind of recommendations. I would have tried to phrase several things with less prejudice, though.