← Back to context

Comment by 4ad

2 years ago

That only works if your language is value-oriented, but most existing languages use references and mutation extensively.

I think that's too broad and somewhat outdated. C++ has const, for example, and you're expected to use it. Java and C# give you final/readonly, and not only that, but immutability is becoming more idiomatic, with the language increasingly encouraging it. For example, in modern C#,

   record Point(double X, double Y);

is immutable, whereas the mutable equivalent is the much more verbose:

   record Point {
      public required double X { get; set; }
      public required double Y { get; set; }
   }

Java goes even further by not even having syntax for mutable records - if you want something like that, you have to write it out as a regular class.

  • To reason about programs one can't consider only the good features and forget about the bad ones.

    But yes, it's good that languages are moving in this direction.