Python advocacy

Donn Cave donn at u.washington.edu
Wed Mar 8 01:34:44 CET 2000


Quoth Paul Prescod <paul at prescod.net>:
| Donn Cave wrote:
|> ...
|> 
|> The idea that Python can or should replace these scripting languages
|> is equally dubious in my opinion.  Replace the UNIX shell with Python?
...
|> I think Python stands a much better chance of growing the
|> muscles to compete with C++ and Java, than the flexibility to compete
|> with scripting languages.
|
| I've never heard anyone as knowledgable about Python as you claim that
| it is *not flexible enough* to compete with anything. In what way is
| "sh" more flexible than Python.

Lexically, I guess would be the word.  I have in mind two things.
The UNIX shell is what you get with a very domain specific language,
the simplest functions in the problem domain (UNIX commands) can be
written with no punctuation at all.  More complex operations can be
expressed with only a little punctuation, e.g., a pipeline.  This isn't
just a matter of how much work it is to type, it's really simpler and
more likely to be done right.  The language per se is quaint and very
limited, a terrible choice for complex programming tasks, but that's
not what scripting is about.  Is sh more flexible than Python?  No,
but to get where sh is, Python would have to be a lot more flexible
than it is, as generic scripting languages like Tcl or REXX already are.

For an example of Tcl's lexical flexibility, see the "expect" command
from Don Libes' Expect package.  I think the Lisp & Scheme dialects
can probably do the same kind of thing, and in this way they're more
flexible than Python.

| Okay, yes, in some cases a small program may be smaller in sh than in
| Python. I've never consider the benefit in reducing 10 line programs to
| 2 lines worth the extra cognitive load of learning another stunted
| language.

The survival value of those stunted languages has a lot to do with
that cognitive load.

| On the other hand, I would gladly learn something that is *more
| powerful* in some particular problem domain like constraint programming
| languages or matrix languages. There's a big difference between stepping
| up to something domain specific and stepping down to something
| brain-dead. I wasted too many brain waves trying to make DOS batch files
| useful to go that route again on Unix.

Yes, I think "expect" is more powerful than any Python idiom I can
think of to translate it to.  I think the shell is a more powerful
way to operate UNIX commands.  I think this is not just the power
to do something with less typing, it's also the power to do something 
with less investment in learning the ropes.

	Donn Cave, donn at u.washington.edu

PS, if you want to see something really horrid, David Korn kept on
developing the Bourne shell after the UNIX guys left with Bell Labs,
and I understand that by now this language (ksh96) can do simple
socket client/server operations, for example, and there are a couple
of independent object-oriented shell projects out there too.
I haven't used it, but it must be far worse than either of the two
common examples of languages extended too far.  There are some hard
core fans, though, who really do a lot of work in it and see it as
more powerful, period.



More information about the Python-list mailing list