News for hackers. Stuff that matters.
Re:How to think about `async`/`await` in Rust by AndrewDucker on Wednesday July 05, 2023 @03:50AM (#36597093)
It began in C# in 2012 - 5 years before JavaScript. And C# does threads. And made its way to JavaScript via Typescript (whose creator also created C#).
Re:How to think about `async`/`await` in Rust by S04dKHzrKT on Wednesday July 05, 2023 @04:06AM (#36597226)
Maybe I'm misunderstanding what you mean by "It began in C#", but F# introduced async about five years before C# 5 was released.
Re:How to think about `async`/`await` in Rust by AndrewDucker on Wednesday July 05, 2023 @04:38AM (#36597525)
I know it influenced the async await design, but I didn't think it was quite the same. Will go do some reading!
Re:How to think about `async`/`await` in Rust by q8840 on Wednesday July 05, 2023 @04:43AM (#36597557)
could be wrong about c#, but c# and f# are comes from same parent
Re:How to think about `async`/`await` in Rust by louthy on Wednesday July 05, 2023 @05:30AM (#36597913)
async in F# is not a language feature, it’s a library that leverages F# computation expressions (monads).

It’s possible to do async like behaviour in C# using LINQ, so you could argue C# has had the capability (like F#) since LINQ was released.

But, I believe C# was the first mainstream language to implement the async/await method-splitting state-machine (as a language feature)

Re:How to think about `async`/`await` in Rust by gpderetta on Wednesday July 05, 2023 @07:45AM (#36598973)
Async is a special case of continuations. If you have fist class continuations (and monads do notation in practice gives you that), you hardly need async as a language feature.
Re:How to think about `async`/`await` in Rust by louthy on Wednesday July 05, 2023 @08:11AM (#36599251)
That's exactly my point. It's not a language feature, it's a library. Haskell, F#, and any other language that supports monads (or as you say, first class continuations), have the ability to do async/await - in a way that appears first-class - but actually is just regular code.

C#, and other languages that have taken the C# approach [to async/await], don't have first class continuations (well, C# does with LINQ, but that compromises most ways the average OO dev works). They implement async/await with first-class keywords that indicate where to slice a method in two.

In my language-ext [1] project I have added the LINQ operators to `Task<T>` which allows C# tasks to be used in the same way that Async is done in F#.

[1] https://github.com/louthy/language-ext/blob/main/LanguageExt...

Re:How to think about `async`/`await` in Rust by gpderetta on Wednesday July 05, 2023 @08:38AM (#36599554)
Do-notation is a language feature though, and that's a superset of async/await.

Incidentally there are papers that are trying to improve on async in C++ by trying to sneak in generalized do-notation.

Re:How to think about `async`/`await` in Rust by pjmlp on Wednesday July 05, 2023 @05:52AM (#36598090)
It began in 1970's with programming languages like Concurrent Pascal.

https://en.wikipedia.org/wiki/Concurrent_Pascal

Simula,

https://en.wikipedia.org/wiki/Simula

And plenty of other ones,

https://en.wikipedia.org/wiki/Coroutine#Implementations

Re:How to think about `async`/`await` in Rust by mpawelski on Wednesday July 05, 2023 @01:05PM (#36603390)
Yes, I remember when my head was blown when I finally understood what this new async/await thing is doing in C#. It was nice to observe other language adopt it with basically the same syntax (Javascript, Python, Hack, then Rust with slightly different syntax). I had some satisfaction that my language got it first

C# really helped to popularized asyc/await as language feature, even though F# had something similar first.