The Bourne shell is not a programming language

May 6, 2008

Before you rise in righteous indignation, let me say that that doesn't mean that you can't write programs in the Bourne shell; you can write programs in anything that's Turing-complete if you try hard enough. It's just that you shouldn't.

The problem with writing programs in the Bourne shell is the same as writing programs in any other highly constrained language: your programs come out all but unreadable because they are spending most of their time getting around the inherent limitations of their environment. What your program is really doing winds up being expressed only indirectly, because you have no good direct way of saying it, and in turn this makes it hard to do anything but run the program and hope it works.

This leads to an obvious question: what's the boundary between a script (which the Bourne shell is fine for) and a program? I'm not sure, but I sort of think that if you need more than a few lines of comments, it's a program.

(Or to put it another way: if it's not obvious what it does and how it works, it's a program.)

Unfortunately I don't think there's a really good Unix programming language to replace the Bourne shell, which is one of the reasons that writing programs in the Bourne shell remains so tempting.

Written on 06 May 2008.
« The costs of doing your own system administration automation
Today's Solaris 10 irritation: the fault manager daemon »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Tue May 6 23:00:10 2008
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.