3 ms·
> it's all about the heap! This. If you only use local (i.e., stack) variables, you should be able to directly transform your code into FP using a state monad.
by choeger 9y ago
> it's all about the heap!
This. If you only use local (i.e., stack) variables, you should be able to directly transform your code into FP using a state monad. Hence I do not think there is a large difference between the two paradigms here.
Plus: Functional Code is easier to reason about. At least for the person that does the formalization. You simply need fewer constructs (and less complicated ones). The same argument holds for parallel code, btw.
- fmap 9y agoYes! Functional or imperative programming makes no difference in his challenge problems. Tail recursive functions and loops are the same thing. Proving a loop correct using invariants and showing (partial) correctness for a tail recursive function by (functional) induction are the same thing.