Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang's promise of concurrency in F#

Tags:

erlang

f#

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?

like image 430
Kalyan Ghosh Avatar asked Dec 22 '22 22:12

Kalyan Ghosh


1 Answers

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.

like image 74
Tomas Petricek Avatar answered Jan 02 '23 07:01

Tomas Petricek