-33
Rust trojan horse
(thelemmy.club)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rust is all about changing internal state. It even has structures (Cell and others) that specifically allow you to change internal state in otherwise immutable data structures. You should probably learn rust properly before making such claims about it.
Every foreign language is unreadable until it is not foreign. Acquiring programmer socks helps, too.
Yes, but wat kind of programming socks? Thigh highs, with white, pink and blue stripes?
Changeable state in an immutable data type? Is... Is that a good idea?
I don't know Rust, but I can tell that the criticism in these image is mostly bullshit. But changing immutable state sounds like a bad idea to me. Is there something I'm missing?
Rust is often treated like it has a split between mutable and immutable state, but it's really a split between unique and shared state. Shared state can be mutated if certain invariants are held, which types that provide "interior mutability" as its called enforce.
https://doc.rust-lang.org/reference/interior-mutability.html
"We spent two decades making sure the compiler will never produce memory-unsafe code. It requires a lot of nigh-illegible boilerplate code to even compile and adds massive cognitive load, but the effort will be worth it.
Anyway, here's a type whose only purpose is to disable all of that shit."
Cell doesn't disable memory safety, though? It comes with additional restrictions such as being unable to share between threads (statically enforced) obviously, it's not an unsafe feature. You also can't read from it unless your type can be bitwise copied, etc.
Interior mutability is mostly for making immutable interfaces that for some reason or another benefit from storing a bit of mutable state, such as for lazy evaluation. It's also used for cross thread communication in some cases since you have to use shared (immutable) references to share things between threads.
this is the entire source code for an app that performs a rather complex function, note the absence of boilerplate
from https://codeberg.org/Mycellf/wordjoinI have a guess that it was added as a workaround the moment Rust was marketed as a general C++ replacement, and as people started to realize overusing the FP paradigm also has its downsides, it's not unique to OOP.
Pure OOP without first class functions sucks fucking ass.