News for hackers. Stuff that matters.
Re:Generics enabled by default in Go tip by SamReidHughes on Saturday August 21, 2021 @03:17AM (#28254956)
If you want a stack you'll just use a growable array (in Go, a slice). A linked list is suboptimal.

Linked lists serve a real purpose in some situations where you really do want O(1) behavior. One example is when you are performing the operation while holding a mutex. But it's never the sort of thing where the right tool is a linked list generic container.

Re:Generics enabled by default in Go tip by kroolik on Saturday August 21, 2021 @05:41AM (#28255593)
I agree linked lists might be suboptimal for a stack implementation, but for a different reason: data locality.

You can have O(1) stack with both implementations. Slice-based will be easier to follow, and will bust the cache less often (less pointer jumps).