|
|
|
|
|
by raydiatian
1339 days ago
|
|
> Patterns won’t do that I’m pretty sure Clean Code by Uncle Bob has a section on why you should use const to achieve immutable variables. In any case, good style guides inevitably are preaching this as well, as are good senior engineers. All in one’s first language (human), without needing to understand lambda calculus, or monads to run a hello world. |
|
Doesn't go far enough.
Firstly, it's just advice. I might like it, but it doesn't mean I can get my teammates to do it.
Secondly, if I want to do it, I have to get it right, any mistakes I make are on me.
Thirdly, const is not enough. You'll probably end up with immutable pointers to mutable data, rather than any kind of referential transparency.
A language which helps you get immutability right is a world of difference. It's like the difference between a memory-safe language vs just using C (and a C textbook which recommends that you write memory-safe code)