Rado's Radical Reflections

Why TypeScript?

Maybe you wondering why did I use TypeScript for this post. As it happens I have been working in the frond-end community in the last 8 years. My interest in incremental computation started by observing the similarities between some of the work I have done inside Angular’s “change detection” algorithms, and work I have done around integrating TypeScript’s compiler in Google’s build system.

UI programming

Why is incremental computation naturally appearing in UIs? As the user is interacting with an UI they are providing new inputs. Usually, these inputs are small compared with the initial input to the UI. On the other side the producing the DOM is the quintessential “expensive” computation. If it redone on each user input the UI will be unusable. So all UI frameworks attempt to solve the incremental computation problem, struggling with the fact that JS has no support for incremental computation. To make matters worse as we have seen incrementality is easier in a functional language, but JS is not well suited to that paradigm (which doesn’t stop people from trying).

The following is a quick list of the popular JS frameworks and how much incremental computation they support or not:

As this very quick survey shows in the modern JS framework space, there is general attempt to find the most ergonomic and practical way to expose some sort of incremental computation on top of an imperative language - JavaScript. And to be absolutely clear this is not a comparison of better vs worst of JS framework. The more incremental solutions can turn out to be unergonomic or add too high of an overhead (similar to parallel computation). This was merely an attempt to put them on equal grounding against a common model of ideal (and likely impractical) incrementity, so that we can understand the tradeoffs and the landscape better.

If one moves further from native JS, an into transpiled-to-JS land, supporting full incremental computation becomes much more manageable as this blog by Yaron Minsky and talk show.

Pragmatics

Given what you have seen so far, maybe you are excited to start using incremental computation in your project. I have to absolutely honest, if it wasn’t very clear, there are too many unknowns around the pragmatics of incremental computation to recommend it (at least in the JS space). This is an non-exhaustive list of pragmatic questions around incremental computation:

In any case, these can lead to some great conversations, so if you think you have an answer reach out.

Conclusion

So what was this all about? To borrow a lovely analogy from Edward Kmett’s talk Stop threading water - Learning to learn - research and development (or academia and industry) are stuck in maze trying to reach each other. Research has some lovely solutions, but doesn’t understand well the real-world problems, while development has excellent grasp on the real-world problems, but lacks the principled thought-through solutions. Left on their own devices each tries to traverse the maze of ideas to get through the other end.

But if they collaborate they can meet in the middle and shorten the search. The picture that Kmett uses in his talk is something like this.

The maze

Looking around the space of UI programming for the web, I think we are getting close to the meeting point of the research of incremental computation and the industry need for efficiently updating UIs.

My hope for this blog post is to shine some light on both loose ends so that folks on both sides can be more efficient in connecting the problems and the solutions.

References

  1. Mokhov, Mitchell, Jones, Build Systems à la Carte, Proc. ACM Program, 2018.
  2. Magnus Carlsson. Monads for Incremental Computing. ICFP ‘02 Proceedings of the seventh ACM SIGPLAN international conference on Functional programming
  3. U. Acar, G. Blelloch, and R. Harper. Adaptive functional programming. In Principles of Programming Languages (POPL02), Portland, Oregon, January 2002. ACM
  4. Rust Salsa framework
  5. SSA is Functional Programming
  6. https://www.jantar.org/papers/chakravarty03perspective.pdf
  7. Introducing Incremental
  8. Incremental computation in Swift
  9. Analysis and Caching of Dependencies
  10. A Theory of Changes for Higher-Order Languages - Incrementalizing λ-Calculi by Static Differentiation
  11. Incremental Computation with Names
  12. Edward Kmett - “Stop Threading Water: Learning to Learn”
  13. Incremental Computation via Function Caching
  14. Typed incremental computation with names

#Incremental Computation