3 ms·
Not exactly random access, but things like finding the last character, trimming trailing whitespace, etc. are all less efficient with linked lists because you h
by fiddlerwoaroof 6y ago
Not exactly random access, but things like finding the last character, trimming trailing whitespace, etc. are all less efficient with linked lists because you have to copy the head of the list to change the tail.
As far as UTF-8 goes, it does add a whole layer of complexity that I had overlooked: although, I suspect intelligent data structure choices could mitigate the random access cost (something like an array of bytes plus an array of grapheme cluster offsets, or similar).
I personally have never found the memory locality concerns relevant to the vast majority of programs I write: when using a language like Python or Ruby or Haskell, you already have a lot of pointer chasing going on because of your non-string data structures such that the memory locality of strings is nearly irrelevant.
- jjnoakes 6y agoI think if your program is string heavy you would definitely notice. It is quite a difference between chasing one pointer per structure and one per character.