awto/effectfuljs

Adaptive (Incremental) programming effects library

awto opened this issue · 0 comments

awto commented

One of many possible effects EffectfulJS may support is an Adaptive (Incremental) programming. Namely re-executing only parts of the code when some dependency changes. Like Mobx @computed property but not re-executing the whole function, only a part (delimited continuation) to reflect the changes in variables. These may be loops, other functions calls etc - some heavy computations.

For example, if there is a huge data grid and we want to render only a visible part of it (with possibly applied filtering, sorting etc). We can write simple for-of loop rendering the grid between starting and finishing position, and if the variables change (on scrolling), or new data arrive from a server only the changed parts rerender, without even using special component, they typically lack some required feature. Or, imagine, it is a game scene rendering where some object changes but the code doesn't bother on handling the changes, it just renders the whole scene once, the rest is handled by the underlying framework.

I believe it is fairly easy to utilize Mobx or derivablejs for this. From EffectfulJS it will receive proper continuations (which may be fired more than once). And they are used called the same way @computed properties are called on dependency change. There is already delimited continuations effects library to be utilizied, only dataflow dependency tracking engines must be integrated.

A couple of links about Adaptive Programming (though they are about functional programming)

Adaptive Functional Programming
Monads for Incremental Computing
Traceable Data Types for Self-Adjusting Computation - mobx supports only adaptive references, this describes how to extend to more advanced types, like sorted maps.
This is based on rather complex functional programming concepts but end-user won't need to know them to use. They will just write plain JS programs.

This is based on rather complex functional programming concepts but end-user won't need to know them to use. They will just write plain JS programs.