Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I heard many people around still saying Perl is great language for CGI. But i think it is not as much as popular as now growing languages such as Python, Ruby.

Is there any solid reason for Perl still being the appropriate language for CGI.

share|improve this question

closed as primarily opinion-based by gnat, Bart van Ingen Schenau, Kilian Foth, World Engineer Feb 6 '14 at 13:55

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 10 down vote accepted

Perl is not a great language for CGI. Or rather, CGI isn't great.

The Perl language was designed by Larry Wall to make his sysadmin tasks easier. It is interpreted, highly portable, has deep Unix integration, and unparalleled text handling facilities (especially when compared with C). When the Web came around, Perl was at the right place at the right time, and became popular as an easy to learn language which was available on virtually any server. This allowed people to easily cobble together simple forms or other kinds of dynamic content. Originally, many people used to abstract over the CGI protocol, later was used.

Today, Perl isn't used very much in this area, as other languages like PHP have taken over this specific niche. While Perl is a general-purpose programming language that was used for the Web, PHP was specifically built for creating websites via CGI.

While Perl still is a great language, CGI has become unpopular: This protocol requires a new interpreter to be started for each request, which is too slow for anything but low-traffic websites. The FastCGI protocol is better in this regard as one interpreter instance handles multiple requests. Certain servers like Apache have tried to reduce overhead by integrating the languages deeper into the server, via plugins like mod_perl or mod_php. They have a ton of issues themselves.

Today, most programming languages define a specific server interface, e.g. Perl has PSGI, Python has WSGI. This interface defines how a server can pass on requests to a web application and allows a variety of efficient or backwards-compatible middlewares.

Web programming today has been irreversibly shaped (no, improved) by the innovative Ruby web frameworks Ruby on Rails and Sinatra. Since then many projects have scrambled to bring this ease of creating webapps to other languages. In Perl, these projects are

  • Dancer (basically just a simple way to map routes to templates)
  • Mojolicious (a very complete, low-dependency web framework)
  • There's also the older Catalyst framework, but it's far more complex.

As these frameworks are built on PSGI, they can be deployed via CGI or via any other interface where appropriate middleware exists (there are also a few specialized PSGI servers).

Perl isn't the only language that has such awesome stuff: Ruby was already mentioned, and Python has a few nice frameworks of it's own, the most well-known being Django. While PHP is very much invested in being usable via mod_php without much further ceremony, it too has a number of modern frameworks. Actually, any language that has been used in the past twenty years has some kind of web framework, and Wikipedia has a nice list of them.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.