▲ | monkeyelite 4 days ago | |||||||||||||||||||||||||||||||
A lot of standard libraries have tried to implement ropes for things like strings and it usually is reverted for a simpler structure. | ||||||||||||||||||||||||||||||||
▲ | josephg 4 days ago | parent [-] | |||||||||||||||||||||||||||||||
There's a good reason for that. Almost all strings ever created in programs are either very small, immutable or append-only. Eg, text labels in a user interface, body of a downloaded HTTP request or a templated HTML string, respectively. For these use cases, small string optimisations and resizable vecs are better choices. They're simpler and faster for the operations you actually care about. The only time I've ever wanted ropes is in text editing - either in an editor or in a CRDT library. They're a good choice for text editing because they let users type anywhere in a document. But that comes at a cost: Rope implementations are very complex (skip lists have similar complexity to a b-tree) and they can be quite memory inefficient too, depending on how they're implemented. They're a bad choice for small strings, immutable strings and append only strings - which as I said, are the most common string types. Ropes are amazing when you need them. But they don't improve the performance of the average string, or the average program. | ||||||||||||||||||||||||||||||||
|