Asynchronous programming in F# (QCon 2012)

18
Asynchronous programming on the server and the client in F# Tomas Petricek @tomaspetricek

description

Asynchronous programming on the server (using F# agents) and on the client (using Pit framework to translate F# to JavaScript).

Transcript of Asynchronous programming in F# (QCon 2012)

Page 1: Asynchronous programming in F# (QCon 2012)

Asynchronous programming on the server and the client in F#

Tomas Petricek @tomaspetricek

Page 2: Asynchronous programming in F# (QCon 2012)
Page 3: Asynchronous programming in F# (QCon 2012)

In Visual Studio since 2010

Page 4: Asynchronous programming in F# (QCon 2012)

Asynchronous programming

On the server side On the client side

Page 5: Asynchronous programming in F# (QCon 2012)

Demo: Social drawing app

Page 6: Asynchronous programming in F# (QCon 2012)

Demo: Social drawing app

Server Agents Browser Client

Page 7: Asynchronous programming in F# (QCon 2012)

Async on the Server

Reactive programming without the inversion of control

Page 8: Asynchronous programming in F# (QCon 2012)

Async on the Server

Reactive model is important

Node.js and C# 5.0

F# asynchronous workflows

Keep standard programming model

Standard exception handling and loops

Sequential and parallel composition

Page 9: Asynchronous programming in F# (QCon 2012)

Agents and message-passing

Protected * ( Behaviour + State )

Page 10: Asynchronous programming in F# (QCon 2012)

F# and the Browser

F# and Silverlight

Both compiler and libraries

Interactive Try F#

F# and JavaScript

Translating since 2006!

Open-source Pit, commercial WebSharper

Page 11: Asynchronous programming in F# (QCon 2012)

Event handling in F#

Data flow using combinators and control flow using async

Page 12: Asynchronous programming in F# (QCon 2012)

Asynchronous GUI

User interactions = State machines

Page 13: Asynchronous programming in F# (QCon 2012)

Asynchronous GUI

Updating rectangles Drawing rectangles

waiting

after 500ms

waiting

drawing

down up

Page 14: Asynchronous programming in F# (QCon 2012)

Asynchronous GUI

Updating rectangles Drawing rectangles

waiting

after 500ms

waiting

drawing

down up

move

Page 15: Asynchronous programming in F# (QCon 2012)

What else is there?

F# Interactive in your web browser www.tryfsharp.org

Type providers in F# 3.0

Integrating data in the language

Bridges an important mismatch

Data and services use REST, XML, …

Languages use types and objects

Page 16: Asynchronous programming in F# (QCon 2012)

Type providers

Page 17: Asynchronous programming in F# (QCon 2012)

Where to learn more?

Functional and F# trainings

http://functional-programming.net

In London and New York

Functional Programming eXchange

http://skillsmatter.com

Next Friday (March 16th)

Page 18: Asynchronous programming in F# (QCon 2012)

Summary

Asynchronous programming

Writing non-blocking code

Without the inversion of control

Application areas

Server-side – reactive request processing

Client-side – encoding state machines