Push or Pull the Data?
This week I was talking at AppBuilders conference (https://www.appbuilders.ch) in Switzerland. I was talking about binary serialisation formats, which is my latest obsession, but this is not what I want to discuss in this blog post.
At the conference I attended a talk by Krusnoslav Zaher, the creator of RxSwift. The talk is already online so you can also check it out, I think it is totally worth it
What I came to realise during the talk is a clear distinction between Entitas (ECS) and Rx. In Rx I define behaviour (mostly defined in closures) and the data will be pushed through my behaviour by the framework. In Entitas I define behaviour (systems) which can pull data. In Entitas there is a way to define behaviour which will get data pushed to it by the framework, we call them reactive systems. However reactive systems can also pull data.
This distinction between push and pull is crucial to the concepts and is rooted in the information hiding principal. Entitas and other idiomatic ECS implementations separate state from behaviour and expose data for everyone to query. When I work with ECS I feel like working with an efficient in memory NoSQL data base. Rx in contrary let you push data into the framework and define behaviours which will consume this data. The data itself is hidden while it is in the framework. In order to merge or split the data I need to use a provided operator or define my own.
I guess it is safe to say that Rx is a flow based architecture, where Entitas is a data based architecture. At this point I would like to quote Fred Brooks:
Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious.