BTW I think some anti-Rust people are more annoying than the worst Rust evangelists - seen some of them calling people not using Rust as "murderers", because "memory leakage can kill at the right time" - but that's due to them being evangelists to right-wing politics.

you are viewing a single comment's thread
view the rest of the comments
[–] 24 points 2 months ago (15 children)

Tbh the borrow checker isn't a problem for 75% of cases. If you actually need the performance/memory optimization then yes you will have to deal with it... Otherwise just .clone()

And if you find the borrow checker annoying in async rust, that's mostly a tokio issue. Look into smol-rs as it offers alternatives

If you want real cons...

  • Compile times
  • easy build time arbitrary code execution
  • trait bounds spaghetti
  • source
  • hideshow 15 child comments
  • [–] 7 points 2 months ago (7 children)
    • viral async
    • viral lifetime annotations

    🫣

  • source
  • parent
  • hideshow 7 child comments
  • [–] 2 points 2 months ago (6 children)
  • [–] 7 points 2 months ago (3 children)

    When people say "async is viral" in Rust, they mean that once you make one function async, that change tends to ripple through the rest of your code. Any function that calls it usually has to become async as well so it can await the result. In turn, the callers of those functions often need to become async too.

    This propagation can continue all the way up the call stack until you reach your application's entry point. The main exception is when you introduce an explicit synchronous-to-asynchronous boundary, such as by using block_on, which drives the future to completion without requiring the caller itself to be async.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 5 points 2 months ago (2 children)

    Yeah but it's not really a problem with rust but how the language pattern is made. It's the same in JavaScript/typescript, and Python IIRC

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 months ago (1 child)

    I've done quite a bit of async programming and I can't quite figure out what people are complaining about here. Best I can tell, they just don't understand what async functions actually are.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 2 months ago

    Most of the time, async tutorial makes you learn tokio, not async. If your program can run with only tokio::main, then you learned async. If not, you learnt tokio (except if you are spawning a future that should never stop)

    For example, my pet project only uses tokio::main to do async stuff. The only instances of tokio::spawn is make sure some SQLite transactions get polled to completion. I do need to replace them with a proper mechanism now that sqlx supports smol-rs

  • source
  • parent
  • [–] 2 points 2 months ago (5 children)

    And if you find the borrow checker annoying in async rust, that’s mostly a tokio issue. Look into smol-rs as it offers alternatives

    This is great until you want to use a library which is tokio exclusive, which is most of them.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 3 points 2 months ago (4 children)
  • [–] 1 point 2 months ago (3 children)

    Huh, that pretty cool actually. I need to play around and see if this works with gtk-rs, channels get fairly annoying if you need to use them a lot.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 1 point 2 months ago (2 children)

    Keep in mind that it doesn't remove tokio from the stack tho. Don't use this to try to improve compilation time

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 months ago (1 child)

    I know, I read the description. It just looks like a nicer syntax around setting up a tokio runtime and sending code between runtimes. It'd still be nice to have a non-tokio options so stuff could be single threaded.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 2 months ago

    A lot of the time it's not about options. It's about not messing up the async pattern.

    If you have something that either:

    • requires a lot of CPU time
    • requires to run permanently, independently to the caller's future polling. Then you can spawn it on a global tokio executor.

    If not, just use future polling tricks like the futures::join!() macro or a stream with .buffered(). It won't be slower. The bottle neck is IO. Not the program.

    Personally I even try to replace the heavy reqwest library with ureq + blocking, and it works perfectly and compiles faster (you can see that in the api_bindium crate)

  • source
  • parent