Hacker News new | ask | show | jobs
by thomasballinger 3246 days ago
One optimization that's not hard to do for terminal output is a line cache: if a row is the same, don't render it. The rendering logic is probably already operating on lines, so this doesn't require the fancy diffing; but diffing a flat grid seems easier anyway vs the dom tree. For context, (I suspect parent already understands this) this is analogous to the vdom optimizations (not shouldComponentUpdate optimizations) possible with React. Except the algorithm is more straightforward: for each character on the grid, is the content the same since the previous render?

This library looks real neat, a declarative TUI with an api already familiar to many developers. I've thought this would be a neat thing to exist since I started using React after having written a similar declarative, redraw-only-as-necessary terminal rendering library for bpython (http://ballingt.com/bpython-curtsies/).

In it (http://curtsies.readthedocs.io/en/latest/) the only rendering optimization was a line cache. For the specific use case of an interactive interpreter this worked pretty well: once a line is changing, it's probably changing a lot. But you could go further using the output of diffing of arrays of terminal text.

edit: whoa https://github.com/Yomguithereal/react-blessed looks awesome for this