views:

522

answers:

10

I'm pretty well up to speed on general web programming languages, but one of the tools I'm working with right now is in CGI. All I can tell is that CGI scripts are quite slow.

Is CGI still commonly used today? If not, what has it been replaced by?
Are there any niche functions in which CGI is still alive and actively used?

A: 

ASP, PHP, ASP.Net, Ruby on Rails are the big hitters these days.

Spencer Ruport
+5  A: 

CGI has been replaced by a vast variety of web programming technologies, including PHP, various Apache extensions like mod_perl, Java of various flavors and frameworks including Java EE, Struts, Spring, etc, Python-based frameworks like Django, Ruby on Rails and many other Ruby frameworks, and various Microsoft technologies.

I'm sure CGI is still used for something, but I'd guess it's mostly just little bits of code that have been sitting around for years. Wikipedia does helpfully mention that FastCGI is similar to CGI but without the massive performance drawbacks.

aem
OK thanks, -- just making sure :)
Michael
A: 

Much like Cobol and Fortran there are some big money systems built on CGI that will of course be maintained well into the future.

Not that newer software isn't built with all those technologies from time to time.

Matthew Vines
+3  A: 

Many legacy websites are still built with cgi today, although people these days are moving away from it. One of the well renown application that is still using CGI that I know is MovableType blog.

jpartogi
+1  A: 

A project I left a few months ago still uses CGI. However, the site is for a very small user set (it only has about 40 users, and probably less than 5 use it frequently). While the hardware has been replaced 3 or 4 times, some of that code has been running for almost 10 years, with little or no modification. I'm sure other technologies would provide a performance improvement, but current performance is acceptable, and manpower to make a change is short, spread over too many areas, and not well versed in web technologies (especially since I left). This leads to an attitude of "If it ain't broke, don't fix it!"

As for replacements I've used/plan to investigate: In my new position, I've developed a web app with PHP. However, I'm more of a Python fan and plan to look into WSGI soon. I also plan to use AJAX to replace a CGI program on a site I voluntarily maintain for a non-profit.

PTBNL
How will AJAX *replace* a CGI program? AJAX isn't a server-side technology in itself, it's simply a technique for running server-side scripts without a full page load.
DisgruntledGoat
@DisgruntledGoat: Currently the page displays a table with data from a back end database and a form below the table. When a user submits data via the form a CGI program processes and updates one cell in the table. I've not really done any AJAX yet, so maybe I'm off base, but my plan is to make the table into a form, eliminating the separate form, and use AJAX to process the user's entries and directly update the database.
PTBNL
+2  A: 

I know of 2 projects that are being actively being developed that still use CGI scripts to good effect.

The first is Webmin a web-based system administration tool that I've been using for years.

The second is GitWeb which allows you to setup a web interface to your Git repositories.

As to the speed of CGI (or lack thereof) I can't really comment on that. From my experience with Webmin I can't say I've had any issues on that front.

Lou
A: 

I'm pretty sure PayPal still uses cgi...

Jason
+1  A: 

Many shared hosts serve server side languages like PHP, python and perl through CGI

blockhead
+6  A: 

CGI is protocol, it is most basic and most standard way to create dynamic pages.

There are many cases where it is useful:

  1. When you want to create, a basic application in a language without mod_XYZ, let's say C or Haskell, that may be computation intensive.
  2. In embedded systems, where memory is expensive and you prefer to spawn a CGI script rather then holding it in memory all the time.
  3. On some hosting services where you want to give flexibility to write server side software in any technology you want, but on the other hand do not hold president applications in memory using FastCGI (for example Sourceforge hosting).
  4. The loads on CGIs are low so you don't care about spawning applications per request. For example, in blogs like MoveableType, only updates are done via CGI, all the rest is served via static pages, which CGI script changes when needed. So the cost of spawning CGI script is very low.
  5. When most of your content is static pages and you want to serve it with server like thttpd, so very few operations that are done can be done via CGI that it supports.

So... CGI is simple but still very useful API, allowing to do stuff simply.

For example, the script that shows uptime of your server

#!/bin/bash
echo Content-Type: text/plain
echo
uptime

What can be simpler, easier and less web-server dependent?

Artyom
A: 

Real time operating systems where porting (for example, PHP) is not an option.

Tommy