Does Python really follow its philosophy of "Readability counts"?
Thu Jan 15 06:19:58 CET 2009
"Russ P." <Russ.Paielli at gmail.com> writes:
> I think we need to distinguish here between purely functional
> languages and a languages that support functional programming. I would
> be even more averse to a purely functional language than I am to a
> purely OO language such as Java.
I guess I'm not sure what you're considering "purely functional
language" to mean, in this context. Haskell has a print function that
prints on the terminal. It's "purely functional" in the sense that it
conceptualizes an expression like 'print "hello"' as a "state
transformer function" that takes as input a state of the world in
which your screen is blank, and returns as output a state in which
your screen has "hello" on it. Your program constructs this state
transformer, and then the runtime system applies the transformer to
the external world and presto, "hello" appears on your screen. But
that is just the metaphysics of it. Normally in practical usage,
you'd think of the print function as something you use more or less
the way you'd use it in Python, except that you can only use it in
functions with IO in their type.
> One feature of Ada that I always thought was a good idea is the
> distinction between functions and procedures, where functions are
> guaranteed to not have side effects. But I don't think Ada allows
> advanced functional programming such as passing functions as arguments
> to other functions.
Well, Haskell uses its type system to encapsulate functions with side
effects. If you want to open a file or print something, you can only
do it from a function with IO in its type. Similarly, if you want to
do the equivalent of assigning a new value to a variable, you have to
use a special type for that purpose, and the type isolates any code
that can affect that variable, etc. I think that generalizes what
you're describing about Ada. It's actually very beautiful but takes
some getting used to.
> If Scala only had default arguments and argument passing by keyword
> (and maybe "continue" and "break"), I think it would be *very* hard to
> beat for a very wide range of applications.
I guess I don't understand the issue about continue and break, since
if Scala is anything like Haskell, the issue doesn't really arise.
Haskell doesn't have keyword args per se, but there are various ways
of simulating them, at least for the usual sorts of applications.
Anyway, Haskell is quite a bit more formal than Python, and it doesn't
yet have as much library support for everyday tasks, and generally
suffers from the not-always-practical priorities of being a "research"
language, but some people have switched to it from Python. I
personally find Haskell very interesting but too difficult in some
aspects, and lacking in "creature comforts" compared with Python.
I liked Tim Sweeney's talk about where he thinks PL design should go:
More information about the Python-list