Kotlin developers: immutable by default! `val` rat...
# compose
v
Kotlin developers: immutable by default!
val
rather than
var
! Compose developers: great, now let's wrap everything in
mutableStateOf
to make everything mutable again...
m
Val has never been immutable
c
val
never declared something immutable. The only thing it does is make the reference to the object not be changeable. You could always change the properties of the object. https://kotlinlang.org/docs/basic-syntax.html#variables
y
Most systems need to deal with state changes. Unless you can express it as a purely functional algorithm. It's just better to have an immutable state value that changes, rather than a bunch of vars with no obvious coordination.
c
mutableStateOf
doesn't make things mutable. It allows collecting all the mutation events, and apply them all at once in a "parallel world" with a different state which is also immutable (as long as what you store is immutable, of course)
c
I think Adam powell said that snapshot state is technically immutable with mutable convenience methods on it or something like that.