On 14 January 2011 21:54, Kevin Wright <[email protected]> wrote:
> > > 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. > > > Just in case anyone feels that Java + Parallel Arrays will be enough, here's one man's experience of just such an approach: http://www.infoq.com/presentations/Thinking-Parallel-Programming 49:10 - 49:50 Although Fortress is originally designed as an object-oriented framework in which to build an array-style scientific programming language, [...] as we've experimented with it and tried to get the parallelism going we found ourselves pushed more and more in the direction of using immutable data structures and a functional style of programming. [...] If I'd known seven years ago what I know now, I would have started with Haskell and pushed it a tenth of the way toward Fortran instead of starting with Fortran and pushing it nine tenths of the way toward Haskell. -- 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.
