Chris’s Wiki :: blog/programming/ScriptVersusProgram

A while back on the Fediverse April King ran a poll on ‘script’
versus ‘program’
.
In a reply, I fumbled around with my vaguely formed views:

I voted complex/simple but I think it’s more complicated for me in
practice. Something in a compiled language is always a ‘program’; a
large or complex thing is always a ‘program’, even for interpreted
languages in a single file. Maybe a script mostly needs to depend
on/use outside Unix programs, not internal things.

(‘A script’ for me is separate from the Unix question of ‘does it use
a #! line and an interpreter to run’, which is a technical issue that
only sometimes matters.)

I’m not sure I fully believe what I posted any more, or even that
I can clearly draw a distinction between ‘script’ and ‘program’
that feels right and is useful in practice. Personally, I think
that all compiled things are programs, not scripts, and I probably
call all of my Python code, even small ones, a ‘program’. Is Linux’s
DKMS, famously written as several thousand lines of Bourne shell, a ‘program’ or a ‘script’? I don’t know.
I’ve probably called it both at various times, but then some of the
times I’ve called it a script I’ve probably meant that as short for
‘a Bourne shell script’, ie I was talking about the implementation
language.

(On Unix, if you say ‘script’ people will generally assume it’s a
Bourne shell script instead of a ‘script’ in some other language,
even in another shell. If you mean ‘zsh script’ or ‘csh script’,
people expect you to say so explicitly. Although on Plan 9, ‘script’
probably means ‘rc script’, since Plan 9 didn’t really have a Bourne
shell.)

Some powerful Unix utilities provide a great opportunity to debate
things. I think of most awk things as ‘a program’, but I’m not sure what
a complex block of sed is; both ‘script’ and ‘program’ seem not really
right.

At the same time there are definitely things I think of as ‘scripts’
and not ‘programs’, even if they contain some relatively complex
logic. One example of this is my Bourne shell script for reporting
Linux cgroup memory usage
, which did a
relatively sophisticated (and slow) job
of reformatting information from a bunch of files. I never thought
of that as a program, although my Python rewrite definitely is a program and not
a script (to me). Possibly this is my Unix bias showing, where I’m
inclined to think of things written in shell (Bourne or otherwise)
as ‘scripts’ and things in most other languages ‘programs’.

PS: Another great area of debate is code written to extend other
programs. Are Emacs Lisp things ‘scripts’, ‘programs’, or something
else entirely (I suspect that Emacs people have their own term for
this and would reject both ‘script’ and ‘program)? Vim has a
‘script’ language
for
writing plugins and other things, but I don’t know if people call
things written in it ‘scripts’. In general it feels like what you
could call ‘extension scripts’ are a different thing than ‘scripts’,
even if they both use the same word.

(In summary, computing terminology is fun. For a certain sort of
fun.)


Source link