15 ms·
> - Immutability. You have to minimize state whatever the program you write, be it language-enforced or not. > - Purity: same story. I agree you can write dec
by the_af 12y ago
> - Immutability. You have to minimize state whatever the program you write, be it language-enforced or not.
> - Purity: same story.
I agree you can write decent code in any language, but the point is which guarantees your language gives you about the code other people wrote. Which is most of the code, usually. Your average imperative language gives you far fewer guarantees than Haskell. Even with your own code, you can achieve purity and immutability in Java or C++ if you want to, but you are mostly fighting against the language.
> - Laziness: never needed it, I think SPJ said the next Haskell would be strict.
On the other hand, Wadler himself in "Why Functional Programming Matters" argues that laziness is essential to achieve modularity and composability.
- p0nce 12y ago> On the other hand, Wadler himself in "Why Functional Programming Matters" argues that laziness is essential to achieve modularity and composability. I just read the part about it, I agree that lazy computation is a powerful tool for modularity and composability. But it's nothing specific to FP languages. Python and Nimrod do that through generators (yield keyword), D through "ranges" (no language support). Also not all algorithms you would want to write only once are easily expressible in a lazy way (eg. push parsers).
- Shorel 12y ago> Even with your own code, you can achieve purity and immutability in Java or C++ if you want to, but you are mostly fighting against the language. I think purity works very nice in D, using D definition of purity.