In principle all kinds of languages are suitable to write cgi-scripts. In the following we will briefly discuss C, C++, Perl, and php.
My preferred choice is C, since it is fast and consumes only little resources. An interface between cgi and C is provided by cgihtml. Images can be created with gd. An interface between C and the MySQL database is part of the MySQL distribution.
Experiments are often not so terribly complex as to be able to take much advantage of C++. However, if you prefer C++ you may want to have a look at CGI++ which integrates HTML and cgi into a C++ program.
Many cgi-scripts in the past have been written in perl. An interface between perl and cgi is offered by cgi-lib.pl. Perl being not a compiled but an interpreted language makes it a bit slower and more resource consuming. Hence, I never dared to used it in an experiment. Perl is supported by the Apache server as a module mod-perl.
php is a programming language that offers both a interface to html as well as to several databases. Using the gd library to create images is also possible. However, php derives its functionality from perl, hence it is as resource hungry and slow. Still, if you have a relatively fast server or a slow experiment, php may be your best choice. Php is supported by the Apache server as a module.
Oliver Kirchkamp 2013-04-15