Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
kamen699563dWhat is it that is so convoluted and there's no workaround - and takes three fucking months?
-
Lensflare1716063dIn 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. -
b2plane639563drust is bullshit but i have to learn it cause Solana is fucking built on rust! anchor framework too! such total shit!
-
12bitfloat930862dHang 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! -
12bitfloat930862d@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 -
12bitfloat930862d@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
-
AlgoRythm5092162dI’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. -
12bitfloat930862d@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/... -
12bitfloat930861d@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? -
12bitfloat930860d@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 -
12bitfloat930859d@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 -
12bitfloat930859d@jestdotty Yeah I'm not much of a web dev, right now I mostly do low level game engine development
Related Rants
-
CozyPlanes53*i am a teenager* *i don't have credit card* *can't buy anything* *sees unixstickers is $1* *pulls out a d...
-
Dedomaripope9The one arcade game that I could never beat
-
leanrob10Sometime I’m developing in Rust and I do something wrong. Then I look at the terminal and it says... “Yo...
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
rant
rust
impossible