7

Author of Monix says in comparison of Monix with FS2

Where FS2 is better:

  • the model of communication between producers and consumers is pull-based, sometimes making it easier to implement new operators

Where Monix is better:

  • the model of communication between producers and consumers is push-based (with back-pressure) and this makes it inherently more efficient

Few questions arise:

  • Which operations are easier to implement in pull-based model?
  • Are there operations which are harder to implement this way?
  • Why pull-based approach is inherently slower?
Community
  • 1
  • 1
visa
  • 300
  • 2
  • 10
  • 1
    One operation that is easier to implement with a pull-based approach is `zip`. If there is two streams that you want to zip together, the pull-based approach just asks for the next element of the two streams and returns the tuple to the consumer. A push-based approach has to buffer elements if the streams are coming in at different rates, potentially causing memory issues or data loss. – Markus Appel Jun 11 '19 at 11:45
  • 1
    Usually though, the two approaches are used for different problems at hand. Pull-based approaches shine when it comes to lazy data transformation, while push-based approaches work well with listeners and event handlers, so for example when building front-end-applications. With pull-based approaches ontop of event-based systems what you will end up doing is polling the data source over and over for changes, which wastes computing energy on nothing. – Markus Appel Jun 11 '19 at 11:49
  • 1
    I don't think pull-based approaches are *slower*, they are just less *efficient*. Given the right circumstances they are as fast as push-based approaches, I think. – Markus Appel Jun 11 '19 at 11:51

0 Answers0