this post was submitted on 30 Jul 2024
10 points (91.7% liked)

Learning Rust and Lemmy

391 readers
1 users here now

Welcome

A collaborative space for people to work together on learning Rust, learning about the Lemmy code base, discussing whatever confusions or difficulties we're having in these endeavours, and solving problems, including, hopefully, some contributions back to the Lemmy code base.

Rules TL;DR: Be nice, constructive, and focus on learning and working together on understanding Rust and Lemmy.


Running Projects


Policies and Purposes

  1. This is a place to learn and work together.
  2. Questions and curiosity is welcome and encouraged.
  3. This isn't a technical support community. Those with technical knowledge and experienced aren't obliged to help, though such is very welcome. This is closer to a library of study groups than stackoverflow. Though, forming a repository of useful information would be a good side effect.
  4. This isn't an issue tracker for Lemmy (or Rust) or a place for suggestions. Instead, it's where the nature of an issue, what possible solutions might exist and how they could be or were implemented can be discussed, or, where the means by which a particular suggestion could be implemented is discussed.

See also:

Rules

  1. Lemmy.ml rule 2 applies strongly: "Be respectful, even when disagreeing. Everyone should feel welcome" (see Dessalines's post). This is a constructive space.
  2. Don't demean, intimidate or do anything that isn't constructive and encouraging to anyone trying to learn or understand. People should feel free to ask questions, be curious, and fill their gaps knowledge and understanding.
  3. Posts and comments should be (more or less) within scope (on which see Policies and Purposes above).
  4. See the Lemmy Code of Conduct
  5. Where applicable, rules should be interpreted in light of the Policies and Purposes.

Relevant links and Related Communities


Thumbnail and banner generated by ChatGPT.

founded 9 months ago
MODERATORS
 

The post mentions data or research on how rust usage in is resulting in fewer errors in comparison to C. Anyone aware of good sources for that?

top 8 comments
sorted by: hot top controversial new old
[–] sorrybookbroke@sh.itjust.works 3 points 3 months ago (3 children)

I've been able to find the following, but it does make sense and I've been reading articles for years saying the same thing. Memory bugs are the cause of the majority of security flaws in larger software. Rust, as it's memory safe by default, allows one to avoid this in the majority of the codebase. That link seperatly links off to google, microsoft, and a few others stating exactly that.

I haven't seen any direct "we switched to rust and now expeeriance 70% fewer errors" however, but the errors found would be impossible with rust, zig, or any other low level memory safe languages.

[–] robinm@programming.dev 6 points 3 months ago (1 children)

This post from 2022 was very interesting:

There are approximately 1.5 million total lines of Rust code in AOSP across new functionality and components [...] These are low-level components that require a systems language which otherwise would have been implemented in C++.

To date, there have been zero memory safety vulnerabilities discovered in Android’s Rust code.

https://security.googleblog.com/2022/12/memory-safe-languages-in-android-13.html

[–] maegul@lemmy.ml 3 points 3 months ago

Definitely interesting!

From the end of the article:

As Android migrates away from C/C++ to Java/Kotlin/Rust, we expect the number of memory safety vulnerabilities to continue to fall.

So have Google continued this and are generally pushing rust? With interest and support from Google, I'd imagine that'd flow into more contributions and financials etc.

[–] CHOPSTEEQ@lemmy.ml 4 points 3 months ago (1 children)

Anecdotally I converted a python app to rust and suddenly had no more runtime errors. It’s utter bliss.

[–] maegul@lemmy.ml 2 points 3 months ago (1 children)

That’s interesting. What made the difference? The type system? Or memory safety constraints forcing more correct logic?

[–] CHOPSTEEQ@lemmy.ml 4 points 3 months ago (1 children)

Both. It allowed/forced me to explicitly handle edge cases I wasn’t thinking about. That means the error doesn’t happen at run time, but at compile time (or while writing!) so technically speaking the errors didn’t go away, they moved to in my face rather than “maybe in the future.”

Most of the time the remedy was to explicitly catch whatever happened and nicely explain what happened, vs looking at empty production logs because logging is turned down.

It’s certainly a preference, but for me, I’d rather argue with the compiler all day long and push a bulletproof release than quickly ship something I thought was good and be embarrassed.

[–] maegul@lemmy.ml 2 points 3 months ago

while writing!

Yea, understated IMO how much the compiler requirements actually manifest directly in the writing process with LSPs etc.

Most of the time the remedy was to explicitly catch whatever happened and nicely explain what happened

Yea even that is making the logic more water tight.

[–] maegul@lemmy.ml 2 points 3 months ago