News -- Why Learn CGI?
by Scott Guelich
07/01/2000
CGI was the first, widely used system for creating dynamic content on the
web. Prior to CGI (Common Gateway Interface), the only way to create
dynamic content was to write a customized web server. That's not easy, of
course, so few people bothered. CGI, however, allowed developers to connect
separate programs to the web and thus transformed it from a repository of
static documents and images into a network of online applications.
Today, there are numerous technologies available for creating dynamic
content. Alternatives to CGI include the following:
- Java Servlets
- Allaire ColdFusion
- Active Server Pages (ASP)
- PHP
- mod_perl
With the increased use of these newer technologies, it is not uncommon for
someone to ask whether CGI is still relevant today. Indeed, some of the
companies marketing these newer technologies have a habit of referring to
CGI applications as legacy applications, inspiring images of dusty
mainframes.
Will CGI development soon be as obsolete as COBOL? Well, don't believe
everything you read, especially if it was written by a marketing
department. One of the virtues of CGI is that it is an open standard that
does not have a company or even a group of volunteers to promote it. Thus,
it is an easy target, and its dominating market share makes it a popular
target as well.
So for the person who asks, "Why should I learn CGI?" I offer the
following reasons:
- CGI remains the most popular way to develop dynamic content.
More dynamic pages are created on the web today with CGI than with any
other technology, and companies continue to develop new applications
with CGI.
- CGI is universal.
CGI is supported by all the major web
servers as part of the default installation. Some Java web servers even
support CGI via a compatibility mode.
- CGI is language independent
. Although Perl is certainly the
most popular language for developing CGI scripts, CGI allows you to
develop in any language. The more popular alternatives to Perl include
C, Python, and Unix shell scripts; but you can also write CGI scripts
in Visual Basic, AppleScript, and
even Java.
- CGI was intentionally designed as a lightweight interface over
HTTP.
Thus, learning CGI helps you better understand HTTP, which
is the foundation for all web transactions, regardless of language
or interface. Time spent learning CGI is an investment, not a loss.
- Numerous ISPs and homepage services allow CGI scripts.
Some,
like Hypermart,
offer this service for free. Thus, developers can learn CGI authoring
without paying a penny. And a site with CGI scripts can be hosted
without resorting to more expensive options like a leased line or
colocation.
- The basics of CGI are intuitive and easy for programmers to
understand.
CGI typically uses standard input and output
streams and environment variables. This interface is the same as that
used by Unix shells and the DOS command prompt. Perl, incidentally,
was originally written for the Unix shell environment, which is one
reason why Perl works so well for CGI scripting.
- There is a great wealth of CGI resources online.
Because CGI
has been around for a while, there are a great deal of online resources
available for CGI authors, including sample CGI scripts and
libraries/modules. Most of this code is available for Perl because
of Perl's popularity as a language for CGI and because Perl developers
have a tradition of sharing code with each other. The best source for
Perl code is
CPAN.
In closing, there is no reason why you should learn only one web
development technology. If you want to become an effective and successful
web developer, it is valuable to learn a few. And, for the reasons I've
outlined above, if you are going to learn more than one technology, the
first should be CGI--especially given its popularity.
Scott Guelich graduated from Oberlin College
in 1993 with a philosophy degree and decided to "only take a few years off"
before continuing with graduate school. Unable to find any listing for
"Philosopher Wanted" in the classifieds, and having done some programming
while growing up, he quickly found himself working with computers. He
discovered the Internet the following year and Perl the year after that.
He has been doing web development for four years and currently works as a
consultant in the San Francisco Bay Area. Nonetheless, he insists that he may
still make it back to graduate school...some day.