python, a scripting language?

Terry Hancock hancock at anansispaceworks.com
Sun May 12 14:48:53 EDT 2002


Erlend J. Leiknes wrote:
> A friend of mine which is a java programmer insists on that python is
> scripting language...
> 
> I belive the term "script" is outdated because of "precompilation".
> The term for a script-language is that you write and run your program as
> text?
> 
> Anyway... I would be happy to hear some reasons why python is not a
> scripting language...

IMHO, "scripting language" vs "programming language" is a distinction
of usage. I have a piece of furniture I sometimes call a chair and
sometimes a stepstool.  If I'm climbing it to reach a high cabinet
it's a stepstool, if I'm sitting on it, it's a chair.

I would assert that your 2nd paragraph is off-base, BTW -- that's
the distinction between "interpreted" and "compiled" languages
(though the assertion that these are now extremely fuzzy
distinctions is surely true).  Java, Python, Perl, and others
do not fit cleanly in either category -- all have some partially
compiled/partially interpreted nature (and all are different
in the details).

Similarly, scripting languages are languages that are "good for"
scripting -- which means running commands in the OS shell for
system administration or installation tasks, while programming
languages are "good for" making programs in their own right.

The implication that the two are mutually exclusive is hogwash.

Tcsh, bash, and csh are certainly poor programming languages.
Tcsh/csh in particular has no concept of a function or
subroutine, let alone objects, so anything more than a couple
of hundred lines becomes a nightmare to maintain.  They are
also incredibly slow in execution, as various benchmark
tests have shown.

You *can* script with C,C++ or another compiled language, but
it's a major pain.  So they are poor scripting languages. I
have no idea where Java fits in this spectrum, though I
suspect it is also a poor scripting language.  I consider
this to be for two major reasons:

1) The syntax for invoking shell commands is relatively awkward
   (You have to call some function/subroutine/class to access
   the shell (like system()), and typically the mechanisms for
   getting info back and forth are not concise or easy to remember,
   and they get in the way of what you're actually trying to do).

2) They must be re-compiled and re-linked each time you make
   a change, which is just too much buy-in for a script which
   will be relatively rarely used or used in only one place.
   (this may also make them bulky, depending on how the linker
   works -- lots of unnecessary stuff may be stuck in your
   executable).  The decoupling between source and object code,
   also increases the chance that you will use the wrong version,
   or lose the original source (which may be the only
   documentation), etc.

Python is much faster than shell scripts, though a wee-bit slower
than native compiled languages like C (quite often though, the
difference is actually negligible, from what I've heard. I've
rarely had the need or opportunity to compare them).  It also
has powerful programming constructs:

 * Complex/high-level built-in aggregate data types (or objects,
   if you prefer).

 * An object-oriented syntax which IMHO is as simple as it could
   possibly be.

Because of this, it passes as a good "programming language". IMHO,
it is far better than programming in C for many, many tasks. The
main reason being the tremendous contraction of development time.
I've essentially abandoned C development for this reason (I still
occasionally use it for the exceptional cases).

Python fails the first test of a good "scripting language" --
you do have to wrap shell commands in some special syntax -- namely
various modules for OS access: os, commands, popen2, etc.  They
also aren't too integrated, BTW, which is sort of a pain (this is
probably because they don't all work on all platforms -- tcsh,
bash, and csh aren't burdened with this as no one expects them
to run on anything but Unix/Linux).  However, don't let this
scare you -- it isn't really that hard to script in Python, and
there are rewards to scripting in a general-purpose programming
language.

Also, Python passes the second test quite well -- I hardly ever
even have to think about the byte-compiling process.  It takes
care of itself, and the interpreter/compiler finds the updated
files and applies them right away.  Certainly I do not get bulky
executables to worry about.

The way you put the question suggests that you are really
asking for proof that Python is not a poor programming language,
which I hope is clear from the above comments. It is however,
*also* a reasonably good scripting language.  For larger scripts,
where program structure might be important, it's probably a big
win over tcsh/csh. Bash/sh may be more competitive (does have
functions), but I never learned them, so I'd rather just go
straight to Python.  For tiny scripts though, I usually just
use a few tcsh commands and I'm done with it.

Terry

-- 
------------------------------------------------------
Terry Hancock
hancock at anansispaceworks.com       
Anansi Spaceworks                 
http://www.anansispaceworks.com 
------------------------------------------------------





More information about the Python-list mailing list