Presentation is loading. Please wait.

Presentation is loading. Please wait.

An introduction to F# (part 2) Bogdan Brinzarea-Iamandi Banca Romaneasca 25 February 2010.

Similar presentations


Presentation on theme: "An introduction to F# (part 2) Bogdan Brinzarea-Iamandi Banca Romaneasca 25 February 2010."— Presentation transcript:

1 An introduction to F# (part 2) Bogdan Brinzarea-Iamandi Banca Romaneasca 25 February 2010

2 TopicCovered Today History22 february 2010 From imperative to functional22 february 2010 Fundamentals22 february 2010 Data structures22 february 2010 Pattern Matching22 february 2010 Immutability vs. Mutability22 february 2010 Object Oriented Programming22 february 2010 Async and Parallel Programming Unit testing

3

4 ProblemSolution I/O bound applicationAsynchronous processing CPU bound applicationParallel and distributed processing Freezing UIAsynchronous processing Sharing stateImmutability

5  Working with threads is difficult  Synchronizing and sharing state are difficult  Introducing bugs is easy  The code is complicated

6  Multiple active evaluations (threads computing results)  Multiple pending reactions (callbacks and agents waiting for events and messages)

7  Not useful for asynchronous operations  Imperative programming  Sharing mutable data between threads  Cancellations  Raising events in the right thread

8  Optimization opportunities  Easily transferable between threads  Reliability

9  Ease of change  Cancellation checking  Simple resource management  Exception propagation

10  Creates async objects  These tasks can be run  In the current thread  In a background thread  In parallel using fork/join mechanism  As continuations

11  Takes async objects and creates async tasks  Uses QueueUserWorkItem  Fork/join pattern  Does not report progress seq > -> Async

12  Runs synchronous computation  Waits for the result  Batch processing jobs  Matrix multiplication

13  Starts and ends in the same thread  Useful for UI updating  Continuations for:  Complete  Exception  Cancellation

14  let! for async method calls  The thread is suspended until the result in available  The rest of the code runs as a continuation  use! resource disposing equivalent of let!

15  Leverage parallel hardware capabilities  Data parallel programming with PLinq  Easy to implement  Abstracts away complexity  Transparent partition and merge operations  Works on seq and IEnumerable  Task parallel programming using the new Task Parallel Library in.NET 4.0

16  Erlang message passing style  “An actor is a computational entity that, in response to a message it receives, can concurrently: ▪ send a finite number of messages to other actors; ▪ create a finite number of new actors; ▪ designate the behavior to be used for the next message it receives.”

17  Asynchronous message passing  Can have even 1000 agents  Agents are lightweight  Based on async programming  State isolation between agents  No concurrency and data races

18

19  NUnit  xUnit.net

20  FsUnit based on NUnit  FsCheck inspired from Haskell’s QuickCheck  FsTest based on xUnit.net  NaturalSpec based on NUnit  FsSpec readable DSL

21  Expert F# by Don Syme  Programming F# by Chris Smith  CTO Corner - http://ctocorner.com/fsharp/book/http://ctocorner.com/fsharp/book/  HubFS http://cs.hubfs.net/  Matthew Podwysocki http://weblogs.asp.net/podwysocki/  Don Syme http://blogs.msdn.com/dsyme  Chris Smith http://blogs.msdn.com/chrsmith/


Download ppt "An introduction to F# (part 2) Bogdan Brinzarea-Iamandi Banca Romaneasca 25 February 2010."

Similar presentations


Ads by Google