tags:

views:

149

answers:

3

I am new To F# but have few years experience in Classic VB, C# and LINQ

I like F# and Understand that it will by default provide support for multiple cores. To use available multiple cores (4/5/6) on servers - is a quite advantage.

How does F# do this?
I also understand that LINQ provides Parallel processing - does it work same way as F#? Why doesn't C# have complete parallel core processing?

Thank you

+4  A: 

There's no magic support in F# to automatically parallelise your code. It's just that various features of F# make writing parallel code easier than in a more imperative or OO language.

That said, look at the Async module for an example of how to easily write parallel code in F#.

Massif
So F# provides simple syntax for parallel processor programming - is it?
swapneel
More that if you write code in the functional style; things like the fact all data is immutable make many of the problems of writing parallel code disappear.
Massif
+1  A: 

I know F# has async which you can use like this:

getIds()
|> List.map (
    fun id -> async {
        do! somethingAsync1 id
        do! somethingAsync2 id
    }
)
|> Async.Parallel
|> Async.RunSynchronously 

That is not to say you can't do this in C# with a bit of work. Certainly F# has some nice syntax with regards to concurrent programming.

ChaosPandion
+2  A: 

I think you would enjoy watching Luke's PDC video:

http://blogs.msdn.com/b/lukeh/archive/2010/02/01/f-for-parallel-and-asynchronous-programming-pdc-2009.aspx

It talks about why parallel/concurrent programming is hard, and what features of F# make it easier.

Brian
thanks for this post Brian - very useful
swapneel