F# and Clojure agents

109 views
Skip to first unread message

Leaf Garland

unread,
Nov 30, 2012, 7:51:20 AM11/30/12
to pragmatic-functional...@googlegroups.com
Hi,

I've noticed that F# and Clojure agents are quite often referred to as similar things (e.g. this intro to F# agents) but this article from Rich Hickey suggests that Clojure agents are purposefully different to the message passing agents of F# and Erlang's actors.

I wondered if anyone else had any thoughts on this difference and the reasons for it (mainly that the message passing model is great for distributed processing but has overhead within a single process) or had implemented anything similar to Clojure's agents in F#.

I guess that you could do something similar to Clojure agents using F# agents with a message type of 'a -> 'a. Is this why they are considered similar?

Cheers,
Leaf.

Jon Harrop

unread,
Nov 30, 2012, 10:34:06 AM11/30/12
to Leaf Garland, pragmatic-functional...@googlegroups.com

Interesting. I’ll read that article…

 

Note that message passing between agents in F# is pass-by-reference and does not do a deep copy or serialization. It relies upon .NET’s concurrent GC. In contrast, message passing in OCaml is serialization between processes. There are applications better suited to both but copying impedes multicore parallelism.

 

FWIW, I think it is unidiomatic to pass functions like that in MLs when you could pass a value of a union type instead. Debugging is easier with union types.

 

Cheers,

Jon.

 

--
 
 

Reply all
Reply to author
Forward
0 new messages