3 ms·
> The author mentions how he thinks representing all strings as linked lists is the 'right thing to do' No. He wasn't talking about strings-as-linked-list ther
by masklinn 14y ago
> The author mentions how he thinks representing all strings as linked lists is the 'right thing to do'
No. He wasn't talking about strings-as-linked-list there: list concatenation is O(N) of the first list, not O(1).
OP was talking about Erlang's iolists which are arbitrarily nested lists of binaries (~bytestrings) and strings (list of integers) which the IO port will iterate and serialize when it needs to: http://prog21.dadgum.com/70.html http://prog21.dadgum.com/70.html. Concatenating two lists (or two binaries, or a list and a binary) by creating an iolist merely requires allocating 2 cons cells, regardless of the size of the items being concatenated.
And because you misunderstood this, your whole comment falls down.
> and later complains about the language's runtime performance. These two things should immediately seem connected
They aren't and have nothing to do with one another. His complaint is about the erlang interpreter/VM being fairly slow. Because it is. Not strings being slow, the interpreter itself.
- lurker14 14y agoPoint of information for this thread: Erlang's iolist are similar (in data structure and complexity) to Haskell's bizarrely named Difference List, which is explained a bit more here: http://hackage.haskell.org/packages/archive/dlist/0.4.1/doc/html/Data-DList.html http://hackage.haskell.org/packages/archive/dlist/0.4.1/doc/... It's basically a tree, which is efficient (amortized O(1) per element) for many list appends followed by one iteration.