4 ms·
The main problem with functional programming in python is the bizarre neutered version of its lambdas. It really limits the expressiveness of using anonymous fu
by thinkpad20 12y ago
The main problem with functional programming in python is the bizarre neutered version of its lambdas. It really limits the expressiveness of using anonymous functions in python, as compared to, say, JavaScript. It's by far my biggest complaint with what is otherwise one of my favorite languages.
- dorfsmay 12y agoSince you can define a function inside a function, why does it matter that it isn't anonymous?
- SoftwareMaven 12y agoHaving done a lot of python and JavaScript, all I can say is it does matter. It is an extra redirect as you try to find out what is happening as part of a callback (repeated over and over). It is also additional cognitive load as you now need to mentally parse the function's name (which you don't actually care about) and the function's purpose. Finally, it is more time consuming. I really like coding in python, but the weak-sauce lambdas are on of my least favorite things about it. I would like tail call optimization, but living without it doesn't bother me on a daily basis. Lame lambdas do bother me on a daily basis.
- dorfsmay 12y agoIs tail optimization a language or an implementation issue? Couldn't that be implemented in the compiler without changing the language?
- eevee 12y agoDon't try to fake anonymous functions in Python. Use its strengths: decorators, generators, etc. Anonymous functions work well (err, passably) in JavaScript and Perl. They don't really work in Python, and of course you'll just run into pain if you try to force them to. Perhaps also make some noise about this PEP: http://legacy.python.org/dev/peps/pep-0403/ http://legacy.python.org/dev/peps/pep-0403/