[Python Edinburgh] Functional Programming in Python

Mark Smith mark.smith at practicalpoetry.co.uk
Fri Dec 24 11:32:40 CET 2010


We spent some time talking about haircuts too. You're not missing that much
;)

I was raving in favour of functional programming, not really functional
programming in Python. There are certain types of problem that just 'suit' a
functional style of programming, and it's nice that Python provides tools
for that, but there's not that much productivity advantage from pushing code
into a functional style if it isn't one of these problems.

I was referring mainly to Russel Winder's theme from the last two years at
EuroPython, that processor cores will actually be getting slower, we'll just
have many more of them. To fully utilise these processors, then, we need a
new approach to coding that can distribute the processing load (the other
approach, I suppose, is /much/ cleverer compilers that can analyse code and
do some if this for you). I think the pure functional languages are ahead of
Python and similar languages in this game.

My proposal was that it would be nice if we could program mainly in an
imperative style (I think it suits the way people think better - I could be
wrong, I'm not greatly experienced in FP), but when operating on every item
in a list (for example), we could annotate the operation to say 'this can
happen out of sequence | this operation does not rely on any outside state',
and have it automatically distributed for you.

There are many libraries for distributed/multi processing in Python; I've
played with Kamaelia[1], which is let down horribly by its documentation
(and a very green website); and Parallel Python[2] which requires you to
plan how you handle your process distribution, which is fine if it's a major
feature of your app, but sometimes you just want python to 'just do'
something for you... and this is overkill.

Actually, this email is getting too long - I'm going to stop now :) I'll be
available in the pub next Tuesday if anyone actually finds this interesting,
or drop me an email...

--Mark

[1]: http://www.kamaelia.org/Home.html
[2]: http://www.parallelpython.com/

Other Refs:

http://www.doughellmann.com/articles/pythonmagazine/completely-different/2007-10-multiprocessing/index.html
http://jessenoller.com/2008/10/29/actors-concurrency-and-kamaelia/
http://code.google.com/p/python-csp/ <- I think this one is pretty
interesting.

On 23 December 2010 23:09, Dougal Matthews <dougal85 at gmail.com> wrote:

>  On Wednesday, 22 December 2010 at 20:43, Mark Smith wrote:
>
> Yeah, sorry if I raved or ranted about FP. Thanks for the link :)
>
> Sounds like I am missing out of some good discussions.
>
> Did you rave and rant in favour of or against? I don't think I'm fully sold
> on the whole concept yet - at least, not in Python. The mangling of the
> coding style into a project seems wrong too and I can't really imagine
> starting a Python project and deciding to do it app functional.
>
> Dougal
>
>
> _______________________________________________
> Edinburgh mailing list
> Edinburgh at python.org
> http://mail.python.org/mailman/listinfo/edinburgh
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edinburgh/attachments/20101224/10876ba3/attachment.html>


More information about the Edinburgh mailing list