4 ms·
This is just another example of how we're learning the lessons of FP about 20 years late. I'm no expert - I've only muddled with FP languages (mostly Haskell).
by chrismsnz 14y ago
This is just another example of how we're learning the lessons of FP about 20 years late.
I'm no expert - I've only muddled with FP languages (mostly Haskell). But what I learned there deeply affected my everyday imperative and OOP coding. Pure functions make for testable, clean code.
- dasil003 14y agoGood functional languages like Haskell also offer better abstractions so we don't have to suffer tired debates around Java methodologies.
- lmm 14y agoThese are orthogonal axes. Good nonfunctional languages like Python also offer better abstractions than Java, and bad functional languages don't.
- chii 14y agoi dont believe python offers any better abstraction over java. Less verbose, sure, but not "better" abstractions.
- dasil003 14y agoYes they're all just Turing machines. You can implement a Lisp interpreter in Java, etc, etc.
- mercurial 14y agoIt has generators, for instance, which makes it a lot easier to implement lazy data structures. Or context managers (though Java 7 has it too). And first-class functions, which beats defining one-method interfaces to get a callback any day of the week.
- dasil003 14y agoAgreed. However I don't need to waste my breath advocating for Ruby over Java. DHH apparently has plenty of time to devote and never seems to tire of it, even after nearly a decade.
- slurry 14y ago> nonfunctional languages like Python also offer better abstractions than Java, and bad functional languages don't. In some cases, but for what is being discussed here, not really. Python is as bad or worse than Java in leaking state everywhere.
- wildranter 14y agoJust because someone keeps hitting his fingers instead of nails, doesn't mean a hammer is not a good tool. In other words, it is the programmer who leaks state, not the language.
- slurry 14y agoCheap shot: that's what Perl hackers say about readability. Python's support for functional idioms is limited by design. Python doesn't have to be good at everything to be a good language.
- wildranter 14y agoI never directed my comment to Python. That because what I said serves to any language, from C to Python, and including ObjC, Pascal, JS, Ruby, etc. From WP: In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. FP is a paradigm as OO is too. One thing does not exclude the other. Nothing stands between you and using the best of both worlds, in any language. You just have to think outside of the box. ;)
- molf 14y agoPerhaps so, but the call to `update` makes this function impure even if `time` is an argument.
- chrismsnz 14y agoIndeed, I wasn't commenting directly on his example rather the general topic.
- praptak 14y agoI still agree with the general point about valuable insights from FP. Perhaps the one applicable here is: impure functions can still make for testable and clean code as long as they are explicitly so.