by gwbas1c · 5y ago · 0 comments
Big mistake! I never accomplished what I set out to accomplish.
Most of my experience is in C#, where the difference between async and threaded code is mostly syntax sugar. (Until you get into the details.) (And async code makes writing UI code much cleaner.)
Trying to write async Rust as a novice is downright hostile. The tradeoff of threads makes async code such that it's only worth it if your Rust process will have highly concurrent load; as opposed to C# where refactoring threaded code to async is housekeeping.
I'm trying to say, that mostly you problems was lifetimes and borrowing, like with other beginners, but problems were magnified to a level when beginner have no chances to make it work.
In the other languages where I used async, Javascript and C#, there is no penalty for using a variable across the async gap. The async keyword just means that something will block. (And plenty of other details, like your UI can paint itself.)
All I would say is hang in there. It gets better (from my experience).
Rust is not something you can code along as you think. There is a bit a of upfront thinking what the data-structures & data-flow look like.
At present, I can know in advance without writing code whether implementation I am thinking in Rust will work or not (work => satisfy Rust compiler)
This is my biggest gripe with Rust. I want to write code that produces the right result first and make it safe later.
Just a guess.
If you enjoy it, learn it and have fun doing high performance work at your new job.
If you’re not passionate about it, it’s OK, there are lots of work in other domains.