In an application framework when performance impact can be ignored (10-20 events per second at max),
what is more maintainable and flexible to use as a preferred medium for communication between modules - Events or Futures/Promises/Monads?

It's often being said, that Events (pub/sub, mediator) allow loose-coupling and thus - more maintainable app... My experience deny this: once you have more that 20+ events - debugging becomes hard, and so is refactoring - because it is very hard to see: who, when and why uses what.

Promises (I'm coding in Javascript) are much uglier and dumber, than Events. But: you can clearly see connections between function calls, so application logic becomes more straight-forward. What I'm afraid. though, is that Promises will bring more hard-coupling with them...

p.s: the answer does not have to be based on JS, experience from other functional languages is much welcome.

  • 2
    It's often being said, that Events (pub/sub, mediator) allow loose-coupling who the hell says that? stop listening to them! You can't subscribe to an event without knowing the parent --> tight coupling. Look into weak events (=Mediator?). Sep 25, 2012 at 8:58
  • @Baboon I generally agree that events do not automatically produce loose-coupling, but if you introduce an event bus you can subscribe to events without knowing the "parent". Who says it? Ray Ryan on Google IO 2009, see google.com/events/io/2009/sessions/… at 13:50.
    – scarfridge
    Sep 25, 2012 at 10:12
  • @scarfridge yes, if you implement some kind of eventaggregator, it's lose coupling, as I said in my comment. Sep 25, 2012 at 11:07
  • .net rx Is an event aggregator, I'm on mobile , will post more details later Sep 25, 2012 at 14:00

1 Answer 1


Monads and events play quite nicely together, for example have a look at .NET Rx. I think there should be even an JavaScript implementation. http://msdn.microsoft.com/en-us/data/gg577609.aspx

  • sorry for delayed accept. "some dumb thing from microsoft" is indeed awesome. And now, after Reactive Extensions have been open-sourced, they are even more viable. Thanx for the answer (though you might want to expand it a little bit ;) ).
    – c69
    Nov 26, 2012 at 21:12
  • It depends what you are looking for: some introduction or specific examples. In any case I can recommend you to explore channel9 videos and talks by Erik Meijer and Brian Beckmann on the topic. Nov 28, 2012 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.