2011/1/14 Cédric Beust ♔ <[email protected]> > > > On Fri, Jan 14, 2011 at 12:56 PM, Kevin Wright > <[email protected]>wrote: > >> Currently, the language just goes a long way towards encouraging >> immutability and freedom from side effects > > > How? I really don't see it this way. > > You can use var or val. You can modify fields inside methods. Only case > classes are final. > > I don't see much in the overall philosophy behind the language that's very > different from Java's in terms of immutability, and most defaults are toward > mutability. > > If Scala programs tend to have more immutable structures than Java > programs, it's much more because of the discipline of its developers than > because the language encourages it. > > I see this as a good thing, by the way, but I think your claim is just > plain incorrect. > > -- > Cédric > > You can even make case classes mutable if you mark params as vars. :)
mutability is certainly accepted, and can't really be avoided for the kind of *deep* Java interop that's a design goal of java. I'll also agree that `var` isn't inherently harder to write than `val`, though anyone learning from current blogs, books, etc. will find themselves rapidly coming to see var as the lesser used of the two. More specifically though, I was thinking about the collections. If you create a new Map, or List, or Seq, etc, etc. then you'll get an immutable collection by default, mutable versions exist, but have to be explicitly imported. Given how much an "average" program will use a collection of some sort or another, that's a *lot* of encouragement. > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<javaposse%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > -- Kevin Wright gtalk / msn : [email protected] <[email protected]>mail: [email protected] vibe / skype: kev.lee.wright twitter: @thecoda -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
