I'm trying to decide whether to make my data model mutable or
immutable in my Dart project. I greatly prefer to design my APIs
around immutable objects, but I'm not clear on how much that affects
performance.
Is Dart designed to have an allocator that can smartly reuse short-
lived objects?
I'm more asking about the language philosophy, rather
than the implementation as it stands. Regardless of how it actually is
right now, I want to do the Dartier thing.
I think many of us like immutability. However, a key design decision for Dart is that there is no shared state concurrency. Two threads can never mutate the same object. You don't have to worry about locks, semaphores, etc. Given that, immutability is nice for reasoning about code, but it isn't as critical for maintainability as it might be in, say, Scala or Clojure where immutability is also helpful for safely sharing state across threads.
On Mar 8, 2012 10:49 AM, "Ladislav Thon" <lad...@gmail.com> wrote:
>>
>> I think many of us like immutability. However, a key design decision for Dart is that there is no shared state concurrency. Two threads can never mutate the same object. You don't have to worry about locks, semaphores, etc. Given that, immutability is nice for reasoning about code, but it isn't as critical for maintainability as it might be in, say, Scala or Clojure where immutability is also helpful for safely sharing state across threads.
>
>
> While I agree that immutability is an immense help when dealing with concurrency in shared-memory world, I think that it's biggest advantage lies in API design.
+1, to me that's at most as important.
I meant at least :)