I’ve just developed my first real program using Core and Async. Overall I like it. Being single-threaded makes it easier to reason about. However, it will undoubtedly impede performance. Particularly the performance of serialization and deserialization to many client connections as this is an embarrassingly parallel hot path but currently done serially in OCaml. In the future I am hoping OCaml will ship with a multicore run-time but I am concerned that my code isn’t future proof because I have used global mutable state all over the place. This seems to be a consequence of the design of Async or at least the way in which I am using it. In F# I build communicating sequential processes from MailboxProcessors that encapsulate their internal mutable state. I cannot see how to do this in OCaml.
Can anyone give me guidelines on how to encapsulate the mutable state in my OCaml code? Should I be trying to do this?
--
Dr Jon Harrop, Flying Frog Consultancy Ltd.
Can anyone give me guidelines on how to encapsulate the mutable state in my OCaml code? Should I be trying to do this?
--