tags:

views:

224

answers:

2

Mr Joe Armstrong says that with Erlang we might have sequential code running N times faster with N cores. Does this apply to F# also? Or is the Erlang VM designed in that way? Does F# manage processes in the OS or language?

+7  A: 

The MailboxProcessor type in F# (see MSDN docs) implements essentially the same agent-based concurrency model as Erlang. The only difference is that Erlang is more suitable for distributed computing (across multiple computers), while F# uses the programming model mainly on a single machine (but multiple threads/cores).

In general, I think that claims about Erlang would also apply to F#.

Regarding the quote: I'm not quite sure what the is the author exactly trying to say (maybe there is some context missing?). It certainly doesn't mean that you can take usual (sequential) program and run it magically N times faster.

However, if you use the programming model of Erlang or F# agnet-based concurrency then you can get a speedup with every additional core. This means that you'll write the program as a large number of agents (instances of MailboxProcessor in F#). Individual agents are written as sequential sub-programs, but you still need to think about programming differently.

Technical aspects: Erlang doesn't use physical OS threads and neither does F#, so the behavior should be very roughly similar. This means that you can create a large number of agents (which is the point of the programming model). Agents in F# are based on asynchronous workflows, that make this possible.

Tomas Petricek
See also http://blogs.msdn.com/b/dsyme/archive/2010/02/15/async-and-parallel-design-patterns-in-f-part-3-agents.aspx
Brian
+1  A: 

Adding cores will only improve the speed of your application if it is concurrent enough to use them, see Amdahl's Law. Using Erlang properly makes it easier to build apps in this way as concurrency is simple and cheap.

rvirding