Live data from Hacker News

Why asynchronous Rust doesn't work

eta.st

61–70 of 305 posts

Re: Why asynchronous Rust doesn't work

#61
post #20
post #13

Excellent post. Async ruins everything even in GC languages. It's just making things needlessly hard for programmers in an attempt to save effort from computers. Erlang shows how to do massive scales of slow IO if you really need it (most programs don't).

Hold on now. Even in GC’ed languages? Which ones? It is another programming paradigm. It has its uses. It has its drawbacks. “Ruining everything” is a big stretch.

What about Java 17?

Re: Why asynchronous Rust doesn't work

#62
Maybe I'm stupid.

But why is Rust so much harder than any other newish programs language.

Dart is like all of my dreams come true at once, Rust still gives me nightmares. I seriously tried to learn it multiple times and failed repeatedly.

I've created several Dart/ Flutter projects for myself and friends. Multiple C#/Unity projects. Python and JavaScript have paid my rent for the better part of a decade.

But Rust, I can't grasp basic concepts.

Re: Why asynchronous Rust doesn't work

#63
post #32

Earlier quoted context omitted.

Frontend or backend js? Because in the frontend everything is just scheduled to a single thread, so you only deal with concurrency, not parallelism.

I think this whole thread is about woes of asynchronous programming (concurrency) not parallelism which is another can of worms.

Depends on your scheduling runtime. In Rust you can schedule everything to a single thread or to multiple threads. That could change the correctness of your asynchronous code or at least make certain bugs non-deterministic

Re: Why asynchronous Rust doesn't work

#64

Maybe I'm stupid. But why is Rust so much harder than any other newish programs language. Dart is like all of my dreams come true at once, Rust still gives me nightmares. I seriously tried to learn it multiple times and failed repeatedly. I've created several Dart/ Flutter projects for myself and friends. Multiple C#/Unity projects. Python and JavaScript have paid my rent for the better part of a decade. But Rust, I…

I've found the opposite. Everything around the language is very ergonomic, people have written tools and libs for everything, nothing is hard to integrate.

The language itself seems ok too. If I didn't have the IDE tools to tell me what was wrong I'd be screwed, but once you run into your first few borrow checker issues you'll read up on what's actually going on and you can fix the problem.

Even the async stuff that the guy is writing about, I don't recognize. Normally async causes all sorts of issues, especially ones where you're totally stumped and the errors make no sense.

With Rust it's just been a breeze. Write some code and at some point the compile will heavily hint not to go that way. Especially with shared state type systems, a borrowing this way and that, you'll find that it's smarter to rethink the arch rather than add yet another Arc>.

Re: Why asynchronous Rust doesn't work

#65
post #12
post #6

In summary asynchronous programming without a GC is a pain in the a*. That's somewhat expected isn't it?

It’s a pain with GC as well, coming from a C# background. It’s incredibly easy to write something that intermittently doesn’t work in weird and impossible to debug ways.

Hmm, C# is my main language, and I don't think I've had an issue like you describe since back when async/await was new and I was still learning about it. And nowadays, Roslyn analyzers, like those in VS and Rider, will warn you about many problems.

Re: Why asynchronous Rust doesn't work

#66

Earlier quoted context omitted.

It's really bad in Python, because the baseline awaitable of Python is a coroutine — same as Rust but without compiler support. The issue of coroutine-based async is that a coroutine does not do anything until it's awaited (and the chain goes up to the reactor), so in Python when you create a coroutine nothing happens. This is unlike Javascript or C# (IIRC) where the baseline awaitable is a task , with tasks awaiting…

No one believes that Python does it correctly.

GP is apparently unaware given they asked.

Re: Why asynchronous Rust doesn't work

#67

Maybe I'm stupid. But why is Rust so much harder than any other newish programs language. Dart is like all of my dreams come true at once, Rust still gives me nightmares. I seriously tried to learn it multiple times and failed repeatedly. I've created several Dart/ Flutter projects for myself and friends. Multiple C#/Unity projects. Python and JavaScript have paid my rent for the better part of a decade. But Rust, I…

It worth the reward to keep trying.

You must be intentional about both coding and systemically learning at the same time how it works. Watch YouTube videos plus build a real world project.

My first attempt to learn rust failed. My second attempt was much better.

Re: Why asynchronous Rust doesn't work

#68

Earlier quoted context omitted.

From my very limited expeirience with Rust I noticed that it becomes way more easy and laid back language when you just skip using references and lifetimes nearly completely and just wrap everything in Rc . Then you are getting expeirience of fairly high level language with a lot of very cool constructs and features like exhaustive pattern matching and value types with a lot of auto-derived functionality. Does Rc hel…

`Rc` freezes the value as long as it's shared unless you use interior mutability. It's fine when you want to share immutable data, but if you ever need to mutate its contents you will have to deal with awkward cases and situations, and at runtime! Wrapping everything in `Rc` is not a good default strategy. Instead figure out an architecture that works well with the borrow checker! This normally means thinking hard ab…

Are there any good resources for design patterns in Rust? I've gone through Rust by example and am writing mid-size rust programs now but would love to check my work against the experts.

Re: Why asynchronous Rust doesn't work

#69
post #30

Guess I'll just go back to erlang.....

Did that, ended up writing more C for performance critical code than I thought.

Rust + Erlang/Elixir is a fantastic combo. Rust is safer than C, so there's a smaller risk that it ends up crashing and taking the entire VM with it. Rustler[0][1] makes the integration a breeze.

[0]: https://github.com/rusterlium/rustler

[1]: https://hexdocs.pm/rustler/readme.html

Re: Why asynchronous Rust doesn't work

#70
post #7

The article glosses over async Rust and is mostly a rant about how closures are difficult in Rust. Most of the difficulty comes from Rust not having a GC yet wishing to keep track of object lifetimes precisely: a GC'ed language needs no distinction between an ordinary function pointer and a closure that captures the environment. But Rust being a low-level systems language chose not to have a GC. Another popular langu…

From my very limited expeirience with Rust I noticed that it becomes way more easy and laid back language when you just skip using references and lifetimes nearly completely and just wrap everything in Rc . Then you are getting expeirience of fairly high level language with a lot of very cool constructs and features like exhaustive pattern matching and value types with a lot of auto-derived functionality. Does Rc hel…

Then you are essentially introducing a verbose, unoptimized garbage collector?
Post reply on HN