On 14 Mar 2011 17:28, "Cédric Beust ♔" <[email protected]> wrote: > > > > On Mon, Mar 14, 2011 at 6:04 AM, Kevin Wright <[email protected]> wrote: >> >> >> There's a few bits that Scala helps with. The deep support for immutability > > > Mmmh, I thought we went over this already: Scala "the language" doesn't off much more in terms of immutability than Java. Classes are mutable by default (you can even make case classes mutable if you want), variables are not "val" by default, methods can modify fields without any ceremony, etc... >
Variables must be either vals or vars, with var being seen as a potential code smell. You're forced to make a conscious choice about mutability. Contrast this to java, where marking something as final feels almost like an afterthought, and is easy to miss - especially in method parameters. Case classes go one step further, requiring neither keyword, but allowing you to explicitly specify a var member if that's what you really want. The whole idea of unifying constructor params with class fields also makes it far more natural to do the right thing when it comes to constructor injection, and named/default params avoid the temptation of mutable setter methods, or boilerplatey factories. Admittedly, no one feature is overwhelming, but they collectively give a very strong bias and helping hand towards getting immutability right :) > Mutable support in Scala comes much more from the libraries and developer discipline than the language itself (nothing wrong with that, by the way, it's one of the pragmatic aspects of Scala that I appreciate). > With the collection hierarchy in particular, absolutely! Though much of it wouldn't be practical without closures. > Other than that, I agree with the overall direction of your FileSystem abstraction. > Thanks, I know I'm not alone in thinking that scala has an unjustified stereotype for being obtuse and academic in normal use. So I try to give more down-to-earth examples where possible. > -- > Cédric > > -- 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.
