Which made me wonder if there are any OOP languages out there which has a strong emphasis on immutability. For e.g. syntax that lets user construct an object only on instantiation, syntax to easily clone an object, syntax to differentiate between a pure function and an impure one etc.
Note:
1. I do realise many people define OOP as stateful and what I am describing above is fundamentally against such OOP, and also this problem is solved by functional languages. But what I mean by object oriented is a paradigm that keeps classes/types/structs as fundamental building blocks to model problem domain, which has behaviour (methods) on state, and one which has essentially '.' (dot) syntax. For e.g. a language where I can do:
class Person (name, bday) { ...
func int age()
{
// calculated from bday state
}
}// And later var p = new Person (...) var age = p.age()
2. By mutability I mean mutating an object (changing its state), not reinitializing the variable. I'm OK with latter.
First time on HN, hopefully my question is within the rules. Thanks everyone!