I'd argue that it's unlikely and uncommon for that to happen without
thinking.  A language doesn't exist in isolation from its ecosystem, and
nobody learns a new language without working from examples, books, etc...
 Everything currently out there for Scala advocates using val as a
preference.

The mere fact of having val/var also forces you into making a choice, so
you have to actively think about what you need.  Given all the learning
resources currently available, this means that developers generally *will*
favour vals without good reason not too.

Contrast this approach to Java in which "final" is very much an optional
extra prefix, you're not forced into making an explicit final/non final
decision when declaring a value, and it's incredibly easy to just leave out
the keyword unless you're being remarkably self-disciplined or are
frequently leaning on static analysis tools to constantly (no pun intended)
remind you.

Worse still, "final" just seems to add extra verbosity and boilerplate
(especially on method params), developers are forced to make a trade-off
between making their code immutably safe, or making it cleaner and more
lightweight.  The language actively DIScourages immutability.

So by comparison, yes, Scala does encourage immutability.


2011/11/25 Cédric Beust ♔ <[email protected]>

>
> On Thu, Nov 24, 2011 at 5:05 PM, Ricky Clarkson <[email protected]>
>  wrote:
>
> That's encouraging, not enforcing.  Nothing stops you from importing
>> the mutable map type.
>>
>
> Nor using "var" instead of "val".
>
> --
> 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.
>



-- 
Kevin Wright
mail: [email protected]
gtalk / msn : [email protected]
quora: http://www.quora.com/Kevin-Wright
google+: http://gplus.to/thecoda
<[email protected]>
twitter: @thecoda
vibe / skype: kev.lee.wright
steam: kev_lee_wright

"My point today is that, if we wish to count lines of code, we should not
regard them as "lines produced" but as "lines spent": the current
conventional wisdom is so foolish as to book that count on the wrong side
of the ledger" ~ Dijkstra

-- 
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.

Reply via email to