[OT] Python like lanugages

John Nagle nagle at animats.com
Mon Jan 17 15:40:26 EST 2011


On 1/17/2011 1:34 AM, Tim Harig wrote:
> On 2011-01-17, Paul Rubin<no.email at nospam.invalid>  wrote:
>> geremy condra<debatem1 at gmail.com>  writes:

>
> Which is rather interesting because the OOP community had
> traditionally though of functional programming as a 1960's thing that
> didn't work out.

     Right.

     The big problem with functional programming is that each function
has only one output.

     It's interesting that this is purely a syntactical problem.
Functional programs look like trees.  They have "fan in", gathering
many inputs into one, but no "fan out", spreading outputs out to
multiple destinations.   Conceptually, you could have a
programming language which allows you to write programs where functions
had multiple outputs which could be directed to different places,
but which weren't stored as state.  Such programs would be directed
acyclic graphs, rather than trees.

     That's been done once or twice.  There's what are called "single
assignment languages".  Each variable can only be assigned once.
The result looks like an imperative language but works like a functional
language.  Look up "SISAL" for an example.  This approach is good
for concurrency and optimization, but it never caught on.

     Note that from a concurrency standpoint, immutability is very
useful.  It's a lot like single assignment.  You can pass around
immutable objects to concurrent threads without race conditions,
provided that memory management can handle concurrency.  This works
in Python, although, because of the GIL problem, it doesn't help
performance.

     A form of Python for highly concurrent work is possible.
More things would have to be immutable, at least once the
program went multi-thread.  If modules, classes, and functions
were immutable in multi-thread code, global locking wouldn't
be necessary, and you could put tens or hundreds of CPUs
to work on one program.

     But Guido would never allow that, so concurrency in Python
is doomed to suck.

					John Nagle



More information about the Python-list mailing list