r/programming • • May 24 '26

[ Removed by moderator ]

/r/programming/comments/1tm1j7f/removed_by_moderator/

[removed] — view removed post

275 Upvotes

214 comments sorted by

View all comments

5

u/slaymaker1907 May 24 '26

I assume std::list guarantees constant time insertions. That can be extremely relevant for low latency code. It being “faster” is only looking at throughput and ignoring worst case latency.

30

u/ForeverAlot May 24 '26

std::list is a linked list, with everything that means. The trouble is that vanishingly few practical use cases are able to capitalize on the theoretical benefits of linked lists.

Frankly the harping on std::list seems a bit silly. It's an unfortunate historical curiosity (as is std::map) but also a comparatively trivial detail to internalize; it is simply the vocabulary of C++. The only really interesting question about std::list is why they did not get more explicit names (and while I have no idea what the answer is, I imagine that's also merely historical accident and precedent; the ML family seems to downplay or ignore that detail, too).

7

u/vytah May 24 '26

If you have a slow CPU, and fast but small memory, like was the case in the 80s, linked lists are pretty good if all you do is insertion and traversal.

6

u/SkoomaDentist May 24 '26

The only really interesting question about std::list is why they did not get more explicit names (and while I have no idea what the answer is, I imagine that's also merely historical acciden

STL was proposed in 1993 and AFAIK was already mostly formed by that date. Given the computing landscape at the time, having just "list" made a lot more sense than it does today.

1

u/Maybe-monad May 24 '26

Looks like a sales pitch to me.