News for hackers. Stuff that matters.
Re:Was Rust Worth It? by adastra22 on Wednesday October 25, 2023 @07:39PM (#38019784)
It’s pretty much the same issue all languages have, that async functions are colored. I don’t think it is unique to rust.

Algebraic effects would solve this, but I don’t know any language other than OCaml that is working on that approach.

Re:Was Rust Worth It? by adamgordonbell on Wednesday October 25, 2023 @08:05PM (#38019982)
Can't scala, haskell, (kotlin?) you just lift functions into Async?

You can convert colors simply but only one way, and practically that works, functional core imperative shell, etc.

Re:Was Rust Worth It? by subarctic on Wednesday October 25, 2023 @08:11PM (#38020018)
I mean... that's not really the pain that people are referring to when they are struggling with async Rust, especially when you compare it other languages like JavaScript that also have a difference between async and regular functions.
Re:Was Rust Worth It? by vlovich123 on Wednesday October 25, 2023 @08:13PM (#38020036)
It’s not just that. There’s a few big problems with Rust async aside from the normal coloring problem that is inherent to async and not worth talking about.

* The async runtime and async functions are decomposed but tightly coupled. That means while you could swap out runtimes, a crate built against one runtime can’t generally be used with another unless explicitly designed to support multiple. I believe C++ has a similar problem but no other major language I’m aware of has this problem - that’s typically because there’s only a single runtime and it’s embedded in the language. Things like timers and I/O are not interoperable because the API you use has to be for the runtime you’re running under. I believe there’s work ongoing to try to remedy this although in practice I think that’s difficult (eg what if you’re using a crate relying on epoll-based APIs but the runtime is io_uring).

* async in traits. I believe that’s coming this year although the extra boxing it forces to make that work makes that not something 0-cost you can adopt in a super hot path.

* async requires pinned types which makes things very complex to manage and is a uniquely Rust concept (in fact I read a conceptually better alternative proposal for how to have solved the pin/unpin problem on HN not too long ago, but that ship has long sailed I fear).

* The borrow checker doesn’t know if your async function is running on a work stealing runtime or not which means there’s a lot more hoop jumping via unsafe if you want optimal performance.

* async functions are lazy and require polling before they do anything. That can be a bit surprising and require weird patterns.

Don’t get me wrong. The effing-mad crate is a fantastic demonstration of the power of algebraic effects to comprehensively solve coloring issues (async, failability, etc). But I think there’s stuff with runtime interop that’s also important. I don’t think anyone is yet seriously tackling improving the borrow checker for thread per core async.

Re:Was Rust Worth It? by Alyan on Thursday October 26, 2023 @04:01AM (#38022982)
Async in traits feature doesn’t use boxing (which is coming in 28 December), only async-trait crate use boxing.
Re:Was Rust Worth It? by vlovich123 on Thursday October 26, 2023 @12:52PM (#38028318)
Really? When I read the GitHub issue it seemed like even the standardized implementation results in boxing…
Re:Was Rust Worth It? by fwip on Wednesday October 25, 2023 @08:55PM (#38020375)
Unison [1] has algebraic effects as a first-class feature. They call them "abilities" there. You can make async about as transparent/opaque as you want it. Docs on abilities in [2].

[1]: https://www.unison-lang.org/

[2]: https://www.unison-lang.org/learn/language-reference/abiliti...

Re:Was Rust Worth It? by adastra22 on Wednesday October 25, 2023 @11:04PM (#38021197)
Does anyone actually use unison in real life?
Re:Was Rust Worth It? by fwip on Thursday October 26, 2023 @12:01PM (#38027472)
I don't know that anybody is running a company on it yet, no. They've got a couple big milestones coming down the pike, which might make it more attractive to people.