Reputation: 2216
I understand that the functional style prefers var or val List of a mutable, and I understand why, but I am thinking about purely time/space trade offs.
I am currently interfacing with a java library and have to write tons of non idomatic code in scala anyways..
Upvotes: 0
Views: 136
Reputation: 3608
In my oppinon the greatest use of immutable List is, that there are no side-effects if you share them between objects. This is important if you start using concurency or even parrallelism.
By the way: Scala uses Builder to change existing Lists and 'recycles' the former List, so this is not as expensive as you might expect it to be.
Edit
As I got you now to get benchmarks I found this one verry good, because they show the code they used.
Upvotes: 2
Reputation: 24769
Maybe several pointers can help you to understand, why there is not a so big penalty when you use immutable structure:
Upvotes: 3