this framing feels off to me, every language forces you to model your program using the tools it gives you. In C you still have to mirror your logic with structs, unions, pointers, arrays, manual allocs, etc. You’re not magically thinking pure CPU and cache while ignoring the language’s constraints.
Rust just makes the modeling more explicit and type system heavy (enums, traits, borrow checker, ownership). It’s a real difference in cognitive load, sure but making it seem like C/Zig lets you skip modeling entirely is false.
@TheEduardoRFS then can we also say that every powerful language feature is defined by its worst use case?, we shouldn’t mix up a feature enables X vs a feature exists for X
@TheEduardoRFS ok fair, we could also argue that most language features are abused and besides, abuse isn’t really a property of early return but the code.. I guess
Single Load and store are Atomic:
What I learnt:-
In modern CPU architectures, *aligned* data accesses are atomic for single loads and stores, provided the data types are *naturally aligned*. In short, what it means is that the reader shouldn't see tearing.
On my hardware :-
I have a real issue with how most people/resources teach Rust (extends to Go, Zig etc). they barely talk about data types, memory layout, or what goes on the stack vs heap. Having the basic idea of this stuff work is what actually makes you much better at learning the language/programming.
This is why people “know Rust” but still fight String vs &str, Vec vs [T; N], Box/Rc/Arc, trait objects & lifetimes.
A better teaching style should be something like:
let s = String::from("hello");
// stack: String value = pointer, length, capacity
// heap: UTF-8 bytes: h e l l o
// move: copies the String header, invalidates old binding
// drop: frees the heap buffer owned by the final String owner
One diagram like this beats 20 abstract lifetime examples.
here's a great example of how to teach/learn rust https://t.co/a7JqSvxJKO
Nah, I think you're missing the point here.
stack vs heap isn't some fabricated lie it's a damn useful mental model for beginners. Sure, it's all virtual memory under the hood, but telling a new Rust dev just "think about registers and alignment bro" is not helpful. They need to understand why their String is 24 bytes on the stack with data on the heap, why moving it is cheap, and why dropping it frees memory. That clicks way before diving into cache lines and alignment.
My tweet wasn't shitting on the Rust Book. It's def a solid book. the complaint is that too many resources (including parts of it) gloss over these fundamentals early, so people spend months fighting the borrow checker instead of understanding it.
I have a real issue with how most people/resources teach Rust (extends to Go, Zig etc). they barely talk about data types, memory layout, or what goes on the stack vs heap. Having the basic idea of this stuff work is what actually makes you much better at learning the language/programming.
This is why people “know Rust” but still fight String vs &str, Vec vs [T; N], Box/Rc/Arc, trait objects & lifetimes.
A better teaching style should be something like:
let s = String::from("hello");
// stack: String value = pointer, length, capacity
// heap: UTF-8 bytes: h e l l o
// move: copies the String header, invalidates old binding
// drop: frees the heap buffer owned by the final String owner
One diagram like this beats 20 abstract lifetime examples.
here's a great example of how to teach/learn rust https://t.co/a7JqSvxJKO
@Biggiethelad1 Yeah, I think the Brown book is one of the best ways to teach Rust to newcomers It builds the right mental model from the start, ownership, stack/heap, moves, etc. so you don’t just learn how to satisfy the borrow checker but you actually understand it
It’s encouraged to work at the highest level of abstraction available to us. But in doing so, if we are able to, at the same time, keep in mind the underlying levels then we’ll find ourselves doing a better job every time.