4 ms·
First, functional programming is an umbrella term. This paper talks about strict FP, which is basically "no mutation", so I'll talk about that. It's clear that
by norswap 10y ago
First, functional programming is an umbrella term. This paper talks about strict FP, which is basically "no mutation", so I'll talk about that.
It's clear that some other aspects of FP, such as first-order functions, closures, etc are very useful in practice.
Immutability does have its advantages in that it supplies strong guarantees about what your code does. It avoids spaghetti code where everything can and does mutate everything else.
Myself, I tend to use whenever its advantages outweigh its inconveniences. Immutability is especially handy at interface boundaries.
- DrJokepu 10y agoI agree that immutability is very useful, but you don't really need any kind of FP to use immutability, do you?
- 33degrees 10y agoI was going to say the same thing; it's certainly possible to write immutable object oriented code
- norswap 10y agoIndeed, it's more of a pattern.
- braythwayt 10y agoIf your data is immutable, in what sense is your code not 'Functional Programming?' "It's OO, and it can't be both OO and FP." Hmmm.
- deleted 10y ago[deleted]
- slikts 10y agoYou're confusing first-class and higher-order functions.