3 ms·
Python doesn't even have tail call recursion optimization (you'll hit a RecursionError exception if you go too deep). Using first-class functions is great but
by wybiral 8y ago
Python doesn't even have tail call recursion optimization (you'll hit a RecursionError exception if you go too deep).
Using first-class functions is great but I hesitate to call any serious use of Python "functional programming".
- bunderbunder 8y agoMany Common Lisp implementations also lack TCO. That said, I do agree that you probably shouldn't go crazy with FP in Python. At its core, it's a procedural language. It has some useful things from OO and FP, but you'll be more comfortable if you keep procedural techniques in the top tray of your toolbox. Which isn't all that bad a thing. IMO, well-done modern procedural programming looks a lot like functional programming with more loops and less recursion.
- wybiral 8y agoCommon Lisp is one of the least "functional" of the major lisp dialects too. Without TCO you generally need state for iteration. That being said, I agree, there's nothing wrong with taking aspects that you like (first-class functions mainly) without having to be a purist. In fact, imo purely functional languages are tedious compared to procedural languages like Python.
- bunderbunder 8y agoThat said, the ML/Haskell-like functional languages do have one thing that most procedural languages do not, which is that they help you keep side effects under control. I'd like to find a procedural language that allows for side effects (it is still procedural programming, after all), but encourages keeping them under control. I've been toying with Nim lately, and it's been a good experience. I think that it's possible to do even better, but it's already way ahead of anything else I've tried.
- karanlyons 8y agoYou can hack that in with a decorator if you’d like, at some cost to performance.