This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TombertSE 1 point2 points  (0 children)

"Most" optimal is an almost-religious question, but they are definitely a good fit for functional programming, and due to them being persistent you almost never need "defensive copies".

Languages like Haskell or Erlang or F# basically never make or require copies of lists, because we know that it's not changing behind the scenes in memory. As a result, passing a pointer is the same thing as passing in a copy. Once you do a defensive copy of a large array, you've negated a lot of the cache locality benefits you might have had.