New Technologies and What They Mean To You: Part 3
In part 2 of this series Jeremy talked about PHP, ASP and ColdFusion. In this article he explains what JSP and CGI are, providing advantages, disadvantages and examples for each.
New Technologies and What They Mean To You: Part 3 - CGI (Page 3 of 4 )
Definition
CGI stands for Common Gateway Interface and is a standard for running external programs from a Webserver. CGI specifies how to pass arguments to the executing program as part of the HTTP request. It also defines a set of environment variables. Normally each program is created in order to dynamically generate HTML which will be passed back to the browser, but it can also do a variety of server-side tasks such as redirects, reading/writing to text files, etc.
In order to improve performance, Netscape devised NSAPI and Microsoft developed the ISAPI standard, which allows CGI-like tasks to run as part of the main server process, thus avoiding the overhead of creating a new process to handle each CGI invocation.
What It Really Is
CGI is, more than anything, a framework. It isn’t a language at all. In fact, languages are written for use within CGI (save as CGI extensions, and are run by the CGI interpreter on the server). The most common language for use is Perl (others include C/C++, Fortran, TCL, Visual Basic, AppleScript), which we’ll cover later in this article.
CGI was developed for Unix systems in the 1980s and is still only on version 1.1. This, unlike other software, is in fact a good thing. It was designed with a specific goal in mind, and that goal hasn’t changed.
CGI is in fact extremely powerful in that it can be both compiled (when written using languages like C++) or interpreted (using languages like Perl and TCL).
More often than not, CGI scripts and applications are written in Perl. In fact, the use of Perl is so commonplace, as the language for writing CGI scripts, that most people think they are one and the same.
Advantages
Can be written in a multitude of languages
Fast and efficient
Powerful and robust
Compiled or interpreted, as appropriate
Cross platform
Disadvantages
Steeper learning curve than newer technologies
Less and less resources, the more “old school” it becomes
CGI has similar technologies on 2 fronts. There are other “container technologies”, and there are also other Unix-based cross-platform technologies.
PHP: Like CGI, PHP is cross-platform. PHP is a very strong language with an incredibly large and supportive community.
ASP: ASP is similar to CGI in that it is also a “container technology”. ASP pages can be written in several languages including VBScript and JScript (the server-side version of JavaScript).
Links
There are many sites out there dedicated to CGI, lots of great resources, and we’ve gathered some of the best ones here: