3 ms·
i started learning functional programming with python, it falls apart at ~300 loc which is absurdly low, which makes python basically useless for production FP.
by dustingetz 14y ago
i started learning functional programming with python, it falls apart at ~300 loc which is absurdly low, which makes python basically useless for production FP.
python's data structures are mutable, and mutable data structures necessarily expose a different interface than immutable data structures. using mutable datastructures in immutable style necessarily has severe performance penalties; and to do meaningful stuff you need to use a statement, and you can't put a statement in a python lambda. And Guido thinks lambda's are un-pythonic and a misfeature which he seems to regret [1].
python is a great sandbox for imperative programmers interested in FP, and these are great slides. it's awesome to play with these concepts in a familiar language - thats how i started - but its important to note that FP is just not pythonic, and thus it's probably a mistake to put functional-style python into production.
[1] http://news.ycombinator.com/item?id=3962316 http://news.ycombinator.com/item?id=3962316
if you are interested in functional python, i wrote about it a bit this year in my blog, because despite all this, python is a nice language for evangelism aimed at imperative developers.
[2] implement generators without yield http://www.dustingetz.com/2012/10/03/implement-python-generators-without-yield.html http://www.dustingetz.com/2012/10/03/implement-python-genera...
[3] easy monads http://www.dustingetz.com/2012/10/07/monads-in-python-identity-maybe-error.html http://www.dustingetz.com/2012/10/07/monads-in-python-identi...
[4] hard monads http://www.dustingetz.com/2012/10/02/reader-writer-state-monad-in-python.html http://www.dustingetz.com/2012/10/02/reader-writer-state-mon...
[5] peter norvig's Lispy refactored using monads https://github.com/dustingetz/monadic-interpreter https://github.com/dustingetz/monadic-interpreter