My two cents
Adam Wilson
flyboynw at gmail.com
Tue Oct 24 04:26:42 UTC 2017
On 10/23/17 17:27, flamencofantasy wrote:
> On Monday, 23 October 2017 at 22:22:55 UTC, Adam Wilson wrote:
>> On 10/23/17 08:21, Kagamin wrote:
>>> [...]
>>
>> Actually I think it fits perfectly with D, not for reason of
>> performance, but for reason of flexibility. D is a polyglot language,
>> with by far the most number of methodologies supported in a single
>> language that I've ever encountered.
>>
>> [...]
>
> There is a lot of misunderstanding about async/await. It has nothing to
> do with "conservation of thread resources" or trading "raw performance
> for an ability
>> to handle a truly massive number of simultaneous tasks". Async/await
>> is just 'syntactic sugar' where the compiler re-writes your code into
>> a state machine around APM (Asynchronous programming model which was
>> introduced in .NET 2.0 sometime around 2002 I believe). That's all
>> there is to it, it makes your asynchronous code look and feel
>> synchronous.
The only parts of Async/Await that have anything to do with APM are the
interop stubs. C#'s Async/Await is built around the Task Asynchronous
Programming model (e.g. Task and Task<T>) the compiler lowers to those,
not APM. A common misunderstanding is that Task/Task<T> is based on APM,
it's not, Task uses fundamentally different code underneath. On
Linux/macOS it actually uses libuv (at the end of the day all of these
programming models are callback based).
Yes, C#'s async design does make code look and feel synchronous, and it
was intentionally designed that way, but that is not *why* they did
Async. That misunderstanding arises from an interview that Anders did in
which he was asked why they held Async back for three years after
announcing it at PDC08. In that same talk Anders specifically says that
the purpose of the Async is to free up threads to continue execution,
his example is a Windows Desktop Message Pump and fetching pictures from
the internet (long-wait IO), but the principal applies to any thread.
They held back async for three years because they needed to refine the
language syntax to something that people could learn and apply in a
reasonable amount of time. IIRC there is a Channel9 video where Anders
explains the evolution of Async Await.
Source: I was at Build 2011 and sat in on the Anders Hejlsberg (C#
language designer) and Stephen Toub (Async/Await implementer) talks
where they discussed Async in detail. I also work for MSFT, I can email
them directly if you want further clarification on anything. :)
--
Adam Wilson
IRC: LightBender
import quiet.dlang.dev;
More information about the Digitalmars-d
mailing list