Shell Scripts v. Command Options (was: Re: small bug in who(1) of SVR3)

Henry Spencer henry at zoo.toronto.edu
Thu Jan 17 04:59:08 AEST 1991


In article <18946 at rpp386.cactus.org> jfh at rpp386.cactus.org (John F Haugh II) writes:
>Studies have shown that the cost of maintaining code is largely independent
>of the language and depends primarily on the amount of code.  A three line
>change to a C file should be just as easy to maintain as a three line shell
>script.

(a) These are not three-line changes.

(b) Three lines of C *in the context of a much larger program* are a great
	deal harder to maintain than a three-line shell script which
	interacts with nothing but itself.

>As for performance, benchmarks will indicate the fork() is an extremely
>expensive system call...

The question is not whether it costs a lot, but whether it is worth the cost.

>If you have more than 68 users on your system and it only forks 68 times
>per second, you are likely to find that shell scripts run pretty damned
>slow...

Only if your users can type at least one command a second, which is rare.
I have no idea what the fork rate on our system is -- although being a Sun,
it's probably damnably slow -- but it's enough for our not-notably-patient
user community.  A user who's sitting in a text editor or waiting for a
sort to finish doesn't care about the fork rate.  A user who's running
"who" or a variant thereon usually doesn't either.

I don't advocate callous disregard for efficiency -- that way lies GNU
Emacs and other excesses -- but a sense of perspective is needed.  Hacking
C code to avoid writing a one-line shell script is a gross waste of time
and money unless that program is truly critical to system performance.
-- 
If the Space Shuttle was the answer,   | Henry Spencer at U of Toronto Zoology
what was the question?                 |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.bugs.sys5 mailing list