4 ms·
I'm surprised Rust went with a Scala-inspired async/await considering it wasn't well-liked outside of PLT enthusiasts. JavaScript adopted it as I don't think yo
by spamizbad 6y ago
I'm surprised Rust went with a Scala-inspired async/await considering it wasn't well-liked outside of PLT enthusiasts. JavaScript adopted it as I don't think you could bolt any other type of sugar on top of the event loop in browsers... but Rust shouldn't suffer from such baggage.
- nynx 6y agoWhat's an alternative to async/await that's explicit about runtime costs?
- thu2111 6y agoHow explicit do you want? The loom model is VM managed thread stacks with user space context switching. The costs are all quantifiable and a suspended "virtual" thread uses memory directly proportional to the amount of stuff on the stack, same as any coro implementation. However there is no async/await or coloured functions. The VM just makes threads super cheap
- roca 6y agoRust started off with user ("green") threads. The problem is interop with other code via FFI --- it gets really painful and potentially expensive. That's not good for a systems language. So they ripped it out.
- pshc 6y agoDo you have a source on people generally disliking async/await? I've become a fan of it in JS.
- spamizbad 6y agoThere's the function coloring issue: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ https://journal.stuffwithstuff.com/2015/02/01/what-color-is-... Where your sync functions have X considerations and your async functions have separate Y considerations - BUT, async/await sugar makes these widely different behaviors look nearly identical - so you get "clean" sync code aesthetics on your asynchronous code and are sort of on your own when tracking the behavior of its implication.
- xiphias2 6y agoRust was the first language that made it efficient, abstraction without overhead (which took many years of work). It’s just a state machine with an enum holding the state, but of course it means that the memory model is harder to understand than with JavScript.
- roca 6y agoC# and C++ adopted basically the same model.
- CodeArtisan 6y agoNote that C++ offers async as a library and not as a programming language feature which Bjarne Stroustrup is strongly against. He talk more about why in "The Design and Evolution of C++" but i don't have the material at hand. As far as i remember, his main argument was that there is no concurrency model to fit them all and thus it doesn't worth to add new syntax and semantics for a specific model except to make the PL more complex and harder to implement.
- roca 6y agoThe main piece is stackless coroutines which definitely aren't a library.
- xfer 6y agoNo without compiler support you can't do async in a library. Rust also does async in library so to speak.
- jcelerier 6y ago> Note that C++ offers async as a library and not as a programming language feature which Bjarne Stroustrup is strongly against. https://www.modernescpp.com/index.php/c-20-coroutines-the-first-overview https://www.modernescpp.com/index.php/c-20-coroutines-the-fi...
- tick_tock_tick 6y agocoroutines themselves have nothing todo with async/await.
- jcelerier 6y agoI wonder what that co_await keyword is for then
- blackoil 6y agoIsn't async/await from F#/C# world, or Scala has a different variant?
- kelnos 6y agoI'm confused... Scala doesn't have async/await.