4

in any other language anything is possible

in rust?

"no"

and you spend 3 months on it and turns out it's a no

this is like project #13 for me where I fail at it. the others I didn't try as long. but now I'm sure

good night

Comments
  • 3
    What is it that is so convoluted and there's no workaround - and takes three fucking months?
  • 3
    In JS and many other languages it’s impossible to write code which is guaranteed to be free of null pointer bugs.

    In Rust it‘s trivial.
  • 1
    rust is bullshit but i have to learn it cause Solana is fucking built on rust! anchor framework too! such total shit!
  • 1
    Hang in there, most people are over the frustration phase in a few weeks. You'll get there!

    Some tips: Don't over engineer. Most beginners overuse the fuck out of references thinking that since their faster they should always be used. No!

    Also as a good alternative to having reference spaghetti (possibly using Rc/Arc which then requires interior mutability), it's not a bad idea to store objects in a context object of sorts and use indices to reference other objects. Now you just pass your context by mutable reference to functions and temporarily borrow your objects from the context obj based on the indices.

    Doesn't work always though!
  • 0
  • 1
    @12bitfloat yeah my useless threadpool exploded in everything is a Arc Mutex now

    I can't even keep track of this in my head

    then I asked the AI to write something with some libraries and it actually could so today whenever I don't feel annoyed looking at my IDE I'm gonna mock up a prototype doing that instead of trying to make my own async runtime
  • 1
    @jestdotty Arc<Mutex<>> is almost always a bad idea. Sometimes when you actually need to have persistent, shared objects then it's necessary, but even then I prefer having the mutex (or multiple! or something else like OnceLock!) encapsulated inside the struct instead of wrapping the entire struct.

    Way more ergonomic

    But like I said, storing your objects in a more centralized place (inside a slotmap!) like a Ctx object is often way more sane. This way you have clear ownership and can give that out to other functions as needed

    But it really depends. Code architecture in Rust really is no easy feat
  • 1
    @12bitfloat it's cuz I did OnceLock on something so every member of it now has to be Arc Mutex

    mutex gave them sync, otherwise the oncelock complained stuff wasn't sync

    I'm sick and my brain ain't what it used to be so I can't tell how much of things is rust or my own brain issues rn but ye I suck rn. found some drugs which may fix it but gonna have to wait for a while

    I feel like I keep grasping at advanced topics too quickly and they're too advanced for me to finish. SHOULD JUST MAKE SOME CALCULATORS
  • 2
    @jestdotty Don't feel to bad about it. Honestly I think trying to do things out of your league is the best way to learn. It's painful but you gain valuable experience of what works and what doesn't
  • 2
    I’ve never personally used Rust as a Zig guy but from my understanding, Rust is meant to be the answer to “compile time success guarantees runtime success”.

    You make a few trade offs for that and some things are simply not possible. I read an article recently about how German strings (aka “short string optimization”) isn’t possible due to the memory-level hackery involved.
  • 1
    @AlgoRythm Small string optimization not working is actually not true. I've heard that too, but I think that was a misunderstanding somewhere

    This is what I'm using right now for example: https://docs.rs/smallstr/latest/...
  • 0
    @12bitfloat ok so here's a question

    my problem would be solved with tokio, request and egui / eframe

    the AI wrote me a simple sample app. cool.

    turns out you can create a tokio Runtime without annotations. cool. I don't like the annotations, it adds too much unknowns for me so this is inspiring

    well the Runtime docs say you can initialize it with new() or Builder(). AI used new(). the code and compiler themselves don't recognize either of these methods. and yet the docs in the IDE on Runtime mention them. the docs also say hey click this link to read more about using this thing. so I did. and it went to a 404 page

    this is exactly why I didn't wanna use tokio. it looks like a mess. presumably this is industry standard and everyone uses it. am I misunderstanding something fundamental here and incorrect that tokio is a mess, or what? like how can an ecosystem for something so basic be so bad at it. I don't get it
Add Comment