29 ms·
C# continues its tradition of stealing the good stuff from other languages. I'm really impressed. Pattern matching and immutable objects? This is great!
by danielvf 10y ago
C# continues its tradition of stealing the good stuff from other languages. I'm really impressed. Pattern matching and immutable objects? This is great!
- hd4 10y ago“Good artists borrow, great artists steal.”
- matthewwarren 10y agoIt doesn't always steal, AFAIK is was the first language to introduce "async" and the compiler magic that goes with it, i.e. so you don't have to use callbacks everywhere.
- yareally 10y agoAsync/await started with F# and was added to C# later.
- soulbadguy 10y agoWhile booth F# and C# have the same aim, they have totaly unrelated implementation and are quite different beats. IMO the C# design wasnt derived from F#.
- edgyswingset 10y agoThey are similar in that F# was the first .NET language to say, "what could language constructs for asynchrony look like?" and implement it. They are fundamentally different models, though. F# uses a "cold task" model where invoking an async function returns a specification of work, which you must then start. You can start this work in different ways so that you have control over the semantics of how it executes. C# uses a "hot task" models, where invoking the async method returns a handle to background work that has already been "kicked off". This is actually an oversimplification, because the semantics of what is actually the asynchronous thing you're awaiting can differ. But the overall concept follows this pattern.
- algorithmsRcool 10y agoI think F# had similar syntax prior to C# with Async Workflows. But C#'s refinement of this syntax seems to have caught a lot more attention. I can't wait to have Async + ValueTask in C# 7 to help reduce the penalty of Async a bit more.
- PeCaN 10y agoAlice ML¹ had that in 2000², and the idea of promises/futures dates back to the 70s. async/await to flatten promise hierarchies is decidedly _not_ a new idea. ¹ http://www.ps.uni-saarland.de/alice/manual/futures.html http://www.ps.uni-saarland.de/alice/manual/futures.html ² Well, it used "spawn" instead of "await". The semantics are very similar though.
- soulbadguy 10y agothe semantic and working implementation of spawn/away are quite different from async/await. While they might be related, i think it's kinda of stretch to call them prior arts...
- PeCaN 10y agoThey're really not all that different. Both are implementations of concurrency based on data-flow synchronization. Alice ML is explicit about running concurrent promises (it has other types of promises as well) in “threads”, but they're lightweight userspace threads. C# AFAIK doesn't specify any particular execution model for await.
- Const-me 10y agoThe innovation was to combine async/await to flatten promise hierarchies with asynchronous callback-based IO under the hood to implement those promises without using background threads. That was the new idea that suddenly made those decades-old promises useful for the software industry, as it allowed both blocking-style code simplicity and callbacks-style IO scalability. The ML link says “evaluates the expression exp in a new thread and returns immediately with a future of its result” which translates to “not scalable”.
- PeCaN 10y agoAlice ML “threads” are more like Erlang threads than C# threads. They're lightweight userspace threads and you can have thousands of them. That's quite scalable. Also, that's not a new idea. Blocking-style code with async I/O scaling was pioneered by Oz in 1991. (It did it a little bit differently from Alice ML.)
- deleted 10y ago[deleted]
- ahartman00 10y agoAFAIK, linq didnt exist anywhere else
- Analemma_ 10y agoIMO, C# is the language that best hits the sweet spot of evolution pace: not so slow that it becomes stagnant and outdated, but not so fast that people feel adrift and confused. C# 6 may not have had any show-stopper features like Linq or async/await, but the syntactic sugar all aimed at immutable/functional styles have let me clean up my code tremendously, and it looks like 7 is going to be more of that. Looking forward to it very much. Edit: I stand by my statement even though I guess pattern matching and immutable types will have to wait for C# 8. The Python-esque tuples allowing for multiple return values without out params or Tuple<> is enough to keep me happy :)
- biot 10y agoI'd say they added a dash of Erlang to C# with the tuples and pattern matching.
- Const-me 10y agoThis is a two-way street. For example, many languages (Python, JavaScript, Scala, C++) already “stole” async-await stuff from C#. As long as they don’t break IP or patent laws, I don’t see any problems with that.
- merb 10y agodefinitly not. Python was late too the game yes, but I guess all the others had it way before C# (since 2012) https://en.wikipedia.org/wiki/Futures_and_promises https://en.wikipedia.org/wiki/Futures_and_promises The only one that "stole" it was maybe Swift.
- Const-me 10y agoAsync-await isn’t just futures or promises. It’s compile-time + runtime mechanism that builds those promises from the code that looks like blocking calls (i.e. easy to read, write and debug), but uses asynchronous IO under the hood (i.e. scalable). BTW, have you read the article you linked? Because among other things, it currently says the following: Several mainstream languages now have language support for futures and promises, most notably popularized by the async and await constructions in .NET 4.5 largely inspired by the asynchronous workflows of F#, which dates to 2007. This has subsequently been adopted by other languages, notably Dart (2014), Python (2015), Hack (HHVM), and drafts of ECMAScript 7 (JavaScript), Scala, and C++.