5
jestdotty
32d

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.
  • 0
    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!
  • 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
  • 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
    @jestdotty Tokio is pretty high quality in general

    Make sure to read the docs, docs.rs really is fantastic. https://docs.rs/tokio/latest/... says it requires the rt-multi-thread feature to be enabled

    Just curious, what editor and rust support are you using?
  • 1
    @jestdotty Tokio has it's own set of primitives which are async aware, like you noticed. Though it's not always advisable to use a tokio mutex for example like the doc explains: https://docs.rs/tokio/latest/...

    Tokio can't be part of the standard library because it's just one implementation of an async runtime. Tokio is the biggest and most well known, but there are others too, which differ in big and small ways

    And yeah... Async rust is definitely a bit of a mess. I wouldn't recommend beginning with it as it's one of the hardest parts of Rust
  • 1
    @jestdotty 429 is a 400 code, so I would assume it's treated as an error

    I've read a bit about that hyper error and that sounds pretty bad. Though it seems that's just a "normal" thing that happens, so I wonder how other libraries solve that?

    reqwest is fine I guess, haven't used it too much. The docs definitely need some improvement. Keep in mind that reqwest is meant to be a simple way to send some requests without a lot of bells and whistles
  • 1
    @jestdotty Yeah I'm not much of a web dev, right now I mostly do low level game engine development
Add Comment