News for hackers. Stuff that matters.
Re:Best Practices for Using Functional Programming in Python by wybiral on Wednesday December 05, 2018 @10:40AM (#18609192)
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".

Re:Best Practices for Using Functional Programming in Python by bunderbunder on Wednesday December 05, 2018 @11:23AM (#18609660)
Many 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.

Re:Best Practices for Using Functional Programming in Python by wybiral on Wednesday December 05, 2018 @12:31PM (#18610403)
Common 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.

Re:Best Practices for Using Functional Programming in Python by bunderbunder on Wednesday December 05, 2018 @12:55PM (#18610654)
That 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.

Re:Best Practices for Using Functional Programming in Python by karanlyons on Wednesday December 05, 2018 @03:49PM (#18612391)
You can hack that in with a decorator if you’d like, at some cost to performance.