News for hackers. Stuff that matters.
Re:Text Showdown: Gap Buffers vs. Ropes by IshKebab on Monday October 09, 2023 @02:21PM (#37823454)
I don't think he's quick to dismiss it. He talks about it several times. Those latencies are when editing files in the hundreds of MB, and only in the worst case non-local edit. How often do you edit I file that big?

Also I expect if that was a real problem you could probably implement a system where you have more than one gap. Does that exist?

Re:Text Showdown: Gap Buffers vs. Ropes by celeritascelery on Monday October 09, 2023 @03:40PM (#37824491)
> Also I expect if that was a real problem you could probably implement a system where you have more than one gap. Does that exist?

That is a really cool idea! I actually tried implementing that. However I gave up because the code became quite a bit more complex, but it would totally be possible! That being said, multiple gaps would only help the "move gap" latency, they wouldn't help with the resizing latency. The later is both less predictable and much higher then moving the gap. Also when you need to coalesce the text for searching you would loose all your gaps.

Re:Text Showdown: Gap Buffers vs. Ropes by IshKebab on Tuesday October 10, 2023 @02:18AM (#37829044)
You can possible use an array of (heap allocated) ring buffers. I heard about that data structure a while ago and it is clever but I have never seen anyone use it.

It means an insertion anywhere just involves M character moves where M is the number of ring buffers.

The data layout won't quite be as nice as a gap buffer (2 chunks), instead you get 2*M chunks. But if you make your ring buffers like 10MB it's probably fine.

Re:Text Showdown: Gap Buffers vs. Ropes by funcDropShadow on Wednesday October 11, 2023 @07:34AM (#37843204)
> they wouldn't help with the resizing latency

Could'nt you avoid resizing by massively over allocating in the first place? A decent OS, hint Linux, would only map pages to the allocated memory pages once they are touched.

Re:Text Showdown: Gap Buffers vs. Ropes by gpderetta on Monday October 09, 2023 @06:59PM (#37826512)
> How often do you edit I file that big?

On the other hand, does speed really matter for small files?

Handling uncommon scenarios gracefully is important.

Re:Text Showdown: Gap Buffers vs. Ropes by Avshalom on Monday October 09, 2023 @07:05PM (#37826575)
you can also cut the worst case non local edit case in half by implementing a circular gap buffer as in climacs https://flexichain.common-lisp.dev/download/StrandhVilleneuv...
Re:Text Showdown: Gap Buffers vs. Ropes by XorNot on Tuesday October 10, 2023 @12:25AM (#37828497)
Hundred+ meg JSON files are pretty common these days. A lot data analysis is just "make some JSON and worry about it later" and that I do like to start by pulling into a text editor.
Re:Text Showdown: Gap Buffers vs. Ropes by masklinn on Tuesday October 10, 2023 @12:59AM (#37828651)
Pulling data in a text editor to look at it has nothing to do with editing it tho. And actuallly wilfully editing hundred+ megs json by hand seems like a near nonexistent use case indeed.
Re:Text Showdown: Gap Buffers vs. Ropes by funcDropShadow on Wednesday October 11, 2023 @07:36AM (#37843221)
The text editor needs to be able to load large without needing x times more memory than the size of the file.