4 ms·
Since it uses React internally, I wonder how large these documents can grow until the experience gets sluggish. I ask this because React basically requires all
by amelius 11y ago
Since it uses React internally, I wonder how large these documents can grow until the experience gets sluggish. I ask this because React basically requires all of the internal content to be "visited" upon a redraw. But regardless of React, it is still interesting to know the constraints in terms of performance.
Also, instead of just pointing to the code on github, I'd like to get at least a little insight into the architecture of the project, because that is the interesting part, in my opinion. There is a brief description in the readme on github, but it doesn't really paint a clear picture.
- brandonbloom 11y agoThe techniques for addressing this are essentially the same for any display technology: Avoid rendering stuff that is not on the screen. This works just fine in React.
- amelius 11y agoBut if at every update (every keystroke of the user), the algorithm needs to go through millions of lines of text to determine which ones to show, it is going to be slow, even if eventually only e.g. 50 lines are shown.
- brandonbloom 11y agoYou can say the same thing about any text editor built with any technology. This problem is fundamental and the tools to solve it are foundational. It's also no different than a game that doesn't render objects behind the player or obscured by walls. You need to choose data structures that enable efficient visibility queries. For a game, there's some sophisticated math involved. But for a text editor? You only need to perform basic arithmetic on the scroll position and window height to index in to a vector of lines. In React, you could render exactly 50 <Line> components and choose which 50 by exactly the same means vim chooses which 50 ncurses lines to show.