Monday, January 10, 2011

Is laziness good for software architecture?

F# will automatically insert laziness into certain recursive monadic constructions. Haskell is lazy by default. And I found myself wondering if this a good thing with regards to the overall architecture of an application.

I would tend to say that laziness is not a good thing with regards to your overall design. I have two arguments:
  • Laziness does not help the overall asynchronous model, especially as the future tends towards cloud computing with its network latency
  • Laziness can blur the clarity of what is really happening. And as a consequence the overall design suffers.
I like my systems to be very much in control of what is happening, therefore my recommendation is to have one asynchronous model for the whole system. Therefore do not include the "Delay" method in your F# monads and do fix warnings when the F# compiler says it will use a delayed reference.

No comments: