3. What’s F#
• Languages by Don Syme, MS Research
• Strongly Statically Typed Language
• Functional Language with OO Ability
• General Purpose Language
6. Four Big Concurrency
Challenges
• Shared State
• Code Locality
• I/O Parallelism
• Scaling Up
7. Shared State
• Difficult to maintain and test
• Very difficult to parallelize
• Locking is fundamentally error prone
‣ Must guess where parallelism is needed
‣ All consumers need to participate
9. Immutability in F#
• Immutable Union • Immutable Tuple
• Immutable Record • Immutable List
• Immutable Set • Immutable Map
• Immutable Objects • Immutable ...
10. Code Locality
• Used to expressing algorithms linearly
• Async requires logical division of algorithms
• Very difficult to
‣ Combine multiple asynchronous operations
‣ Deal with exceptions and cancellation
12. React
async
{
let!
res
=
<async
work>
...
}
an HTTP Response
an UI Event
a Timer Callback
a Query Response
a Web Servcie Response
a Disk I/O Completion
an Agent Message
15. I/O Parallelism
• Software is often I/O-bound
‣ Leveraging web services
‣ Working with data on disk
• Network and disk speeds increasing slower
• I/O resources are inherently parallel
‣ Huge opportunity for performance
17. Scaling to Multi-Machine
• To scale up, must to go beyond a single machine
• Multi-machine resources becoming common
‣ Roll-you-own clusters with cheap hardware
‣ On-demand cloud compute with Azure
• But
‣ Shared memory doesn’t scale
18. ... the principle we go by is, don't expect to see
a particular concurrency model put into C#
because there're many different concurrency
model ... it's more about finding things are
common to to all kinds of concurrency ...
- Anders Hejlsberg
21. F#
• Modern, simple, powerful and productive
• Ready for production use with VS 2010
• Simplified parallel and async programming
for today and tomorrow
• Support .NET 4.0 / 3.5 and mono
• Open Source *
22. F# Resources
http://fsharp.net
Programming F# Expert F# 2.0 Real World FP