
don't like CGI programming because it is unstructuredthough programming in general has been structured for many, many years. Web developers have powerful IDEs, formidable application frameworks like Enterprise Java Beans, and various code-generation tools, but still much Web development is based on CGI, or something very much like it, and CGI remains unstructured.
But what if you tried to apply all the structuring techniques that have been developed since the 1950s to CGI development? Not to denigrate the tried-and-true CGI development paradigm, but rather to imagine what kinds of powerful Web programs you could create if you had the timeand to create more time by making Web development faster, easier, and less error-prone.
An Example
Suppose you're developing a shopping cart for an e-commerce Web site, and you've already implemented credit-card payments. Now, you want to add payment by some other methodPayPal, for example.
You add another form:
<form action="completeOrder.cgi" method="POST">
<input type="hidden" name="method" value="PayPal">
...
</form>
Of course, you've already written
completeOrder.cgi, which looks like this (in a random Hypothetical Web Language):
if ($method == "CreditCard") {
...
} else if ($method == "Offline") {
...
} else ...
}
To this conditional you must add a case for PayPal. Or, rather, you
should add this case, because otherwise the form won't work right. But the language doesn't check this for you, and you could very easily leave this out, or misspell "PayPal", or misspell "method." Any number of things could go wrong.
Most programming languages check this sort of thing for youthey can tell you when you've misspelled a variable, and many even check the types for you. These "sanity checks" have been developed over the course of decades to take some of the guesswork out of programming, and to relieve the burden of memory that falls on the programmer's shoulders.
These details may easy for a good programmer to handle, but not very conveniently. CGI is just plain inconvenient. It doesn't check types or variable declarations and it doesn't even have function calls.
These flaws crop up, in one form or another, in almost any application framework. Some of the more sophisticated (re: complicated and expensive) frameworks have workarounds, but they're varied, inconsistent, and clumsy.