Asynchronous Programming, Monads and Continuations in C#, F# and Scala

Asynchronous Programming, Monads and Continuations in C#, F# and Scala

Technorati 标签: F#, 异步编程, Monad


作者:LiuGuangLong
出处:http://www.cnblogs.com/liuguanglong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

 

摘要:此文介绍的内容是.net framework要加入更多erlang,haskell等语言早就有的异步编程特性。

       主要技术点是支持非OS级别的线程调度。基于Event事件的异步编程一是成本重,二是编程不方便,不符合函数式编程的经典思路。

       F#基于此特性支持Monad。      

原文地址 http://lambda-the-ultimate.org/node/4117

 

Anders Heljsberg presented new asynchronous programming constructs for C# at PDC10. There is documentation, videos and a technology preview download.

When your user interface is unresponsive or your server doesn’t scale, chances are you need your code to be more asynchronous. With today’s .NET Framework and language features, though, that is easier said than done.
The Microsoft Visual Studio Async CTP proposes a new language feature in C# and VB, and a new framework pattern to go with it, that will make asynchronous programming similar to – and about as straightforward as –synchronous programming.

How is this related to F#'s asynchronous workflows, and monads in general?

We describe the asynchronous programming model in F#, and its applications to reactive, parallel and concurrent programming. The key feature combines a core language with a non-blocking modality to author lightweight asynchronous tasks, where the modality has control flow constructs that are syntactically a superset of the core language and are given an asynchronous semantic interpretation. This allows smooth transitions between synchronous and asynchronous code and eliminates callback-style treatments of inversion of control, without disturbing the foundation of CPU-intensive programming that allows F# to interoperate smoothly and compile efficiently.

What's the connection to Scala's delimited continuations by type directed CPS transform?

We describe the implementation of first-class polymorphic delimited continuations in the programming language Scala. We use Scala’s pluggable typing architecture to implement a simple type and effect system, which discriminates expressions with control effects from those without and accurately tracks answer type modification incurred by control effects. To tackle the problem of implementing first-class continuations under the adverse conditions brought upon by the Java VM, we employ a selective CPS transform, which is driven entirely by effect-annotated types and leaves pure code in direct style. Benchmarks indicate that this high-level approach performs competitively.


作者:LiuGuangLong
出处:http://www.cnblogs.com/liuguanglong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

你可能感兴趣的:(Asynchronous Programming, Monads and Continuations in C#, F# and Scala)