News for hackers. Stuff that matters.
Re:Text Showdown: Gap Buffers vs. Ropes by userbinator on Monday October 09, 2023 @09:33PM (#37827618)
The simplest approach is to just use a large string or array of lines. However these each suffer from poor performance as either the size or line length of text increases.

Every time this point comes up in the design of text editors, I feel compelled to mention that memory bandwidth is dozens of GB/s on modern hardware; even when it was only a few MB/s a few decades ago, text editors that used a single contiguous buffer (not even a gap) were very common and no one complained about their speed. Indeed, the benchmarks in this article confirm that.

As another popular article that's often submitted here says: computers are fast --- very fast for human timescales, and in particular manipulating text of humanly-encountered sizes.

There's a lot of dogma around advanced text editor structures and what is "optimal", and IMHO a lot of that is totally unneeded accidental complexity created by those more interested in theoretical daydreaming than real-world solutions. Thus, I think even a gap buffer is "overkill", and a single "gapless" buffer is really sufficient. Don't overthink things.

Re:Text Showdown: Gap Buffers vs. Ropes by hoseja on Tuesday October 10, 2023 @03:43AM (#37829494)
And yet, search-and-replace on big files takes seconds.
Re:Text Showdown: Gap Buffers vs. Ropes by kaba0 on Wednesday October 11, 2023 @09:55AM (#37844442)
I can grep through half my file system in seconds. What do you measure?
Re:Text Showdown: Gap Buffers vs. Ropes by PH95VuimJjqBqy on Tuesday October 10, 2023 @10:04AM (#37832258)
I don't know this authoritatively, but I believe vim uses a simple array internally. And it works well.