Introduction To Programming: Web Programming Languages — CGI

Common Gateway Interface, or CGI was the first method of server side scripting. It was developed by the NCSA to more easily allow for dynamic applications. Before CGI, the only way to create, say, a search engine, was to directly alter the code of the web server itself.

CGI is not a language unto itself. Rather, it takes the data in the CGI file and inputs it to an external program, which then sends it’s output back to the server. Any program than can handle the input/output streams used by CGI can be used by the CGI script.

When writing a CGI script you could put all the code you need for the task at hand in the CGI file, much like you would for PHP. The code would then be sent to an interpreter program to be executed. Alternatively, you could write the program separately and compile it, having only the inputs to activate it in the CGI.

A chief weakness of CGI is that it makes a separate running instance of the program it calls every time it is run. If there are many simultaneous connections this can add up quickly.

Being the first of it’s kind, CGI is widely used. However, newer sites are not commonly written using CGI, as it is highly inefficient compared to other methods for sever-side scripting.

Leave a Reply

Avatars are handled by the Gravatar service