I'm not sure if it's quite as flexible as C++'s const-correctness, but if you're creating your own class hierarchy from scratch, you can (and are encouraged to) code in a style that basically ensures that every parameter is practically passed as a const (immutable) reference. So you can easily do things like make strongly-typed functional data structures that will compiler-complain if you try to modify them after creation, without needing to remember to type "const" all the time. And that's realistically what most people need at the end of the day.
I'm excited to experiment with this - it seems definitely designed by pragmatists who want to lower the barrier to entry and make it fun for non-functional programmers to code in (I'm looking at you, Haskell), but also encouraging and enforcing best practices wherever possible.
So I was mainly hoping it is like F#, that forces you to decorate non-immutable variables with the `mutable` keyword, inside a method/function.
However, thinking about it more deeply, this is not so important. Because local variables (in a method) are never shared between threads. So immutability doesn't suffer from them being mutable. Right?
http://smallcultfollowing.com/babysteps/blog/2014/05/13/focu...
"Put another way, it’s become clear to me over time that the problems with data races and memory safety arise when you have both aliasing and mutability. The functional approach to solving this problem is to remove mutability. Rust’s approach would be to remove aliasing."
Local variables themselves are naturally non-aliased, although the objects they point to might be.
PS apologies to anyone who's seen it before for trotting that link out yet again!
The reason for that is that a local variable could be captured by an anonymous function or nested function, and escape from the local scope, so it's exactly the same situation with a local variable as for an instance variable of a class: both kinds of variable break referential transparency.
LOL, what?
Time is a real property just like IO, effects, values and types. If people stop hand-waving, we would have fewer bugs.
I agree it's not right for everything, but there are a lot of operations that can be modelled with immutable data, such as most server-side web code - reads definitely, and a lot of the write operations don't actually need to mutate objects though most ORMs and other DB APIs do require this.
This depends on your definition of "the world". If time and memory are taken into account, you could easily make the case that the world is very much immutable. For example, if your friend changes his email address, its not as if his old address no longer exists. Even if it only exists in memory, it still exists somewhere, and you're still able to reference it.
If you're interested in this topic, I highly recommend Rich Hickey's talk "The Value of Values"[1].