3 ms·
The reason why functional languages like linked lists so much is because they are very easy to make immutable without a lot of pain all around. If you implement
by int_19h 1y ago
The reason why functional languages like linked lists so much is because they are very easy to make immutable without a lot of pain all around. If you implement an immutable vector in a straightforward way, though, you basically need to do a lot of copying for any operation that needs to construct one (the rigmarole with immutable strings, and existence of hacks such as StringBuilder, is a good illustration of the problem).
But you can have a data structure that is more like vector under the hood while still supporting efficient copy-with-modifications. Clojure vectors, for example.
- gigatexal 1y agoThat makes sense. But LinkedIn lists are horrible for cache efficient things no? I think there was an article on HN from a Golang perspective padding structs or something such that they are efficient wrt to cache hits.
- rkomorn 1y ago> But LinkedIn lists are horrible for cache efficient things no? LinkedIn Lists you say? (Sorry. (But not that sorry.)) Edit meta sidenote: in this modern meme world, it's virtually impossible to know if a typo is a typo or just a meme you haven't heard of yet.
- gigatexal 1y agolol my phone autocorrected ugh. But you know what I mean. Some grace would be nice.
- stirfish 1y agoLinkedIn lists will tell you they contain one new element, but you have to click on a link and scroll through their suggested new elements to see what it is
- rkomorn 1y agoDo they also always end with an element that tells you what the LinkedIn list taught it about B2B sales?
- mrkeen 1y agoThey are, but you don't tend to keep them around in memory long enough. Start consuming the front before you produce the back.
- dontlaugh 1y agoWhich is a pity, you can fit entire small arrays in a cache line to end up with no pointer chasing at all.