| This is the biggest hurdle for a lot of people, at least for me.
The immutability. IF you have grown up doing objects, or C#, and thinking with variables. Then 'a=1' means a memory for variable a has a 1, and you should be able to change that. But it is really a like a function where the function returns a 1. 'let a = 1' is not assigning the value 1 to variable a. 'a' is a function that returns a 1. I think this is biggest reason why people trying to learn functional programming in languages that don't enforce immutability, have a harder time than with languages that do enforce it. Like moving to another country, and the people around you purposely don't speak English so you have to learn the language.
If the did speak English to help you, then you wouldn't learn the language. Enforcing immutability is like this. |
Mutable variables are better explained as slots or cells, I think. Both OCaml and Rust have a concept of ref cells, for example (and they entirely replace mutable local variables in OCaml).
1: https://en.m.wikipedia.org/wiki/Variable_(mathematics) 2: https://en.m.wikipedia.org/wiki/Variable_(computer_science)