Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
While any programming language that includes the concept of standard in and standard out can be used to write a CGI, some languages are intrinsically more suited to the task than others. In this section, I review the most common CGI languages (sh, Perl, and C), point out their strengths and weaknesses for CGI use, and give some language-specific optimization tips. But first, here are a few performance tips general to all languages:
Keep loops small.
Use table lookups rather than calculation, where practical.
Use integer rather than floating-point math.
Avoid dynamic memory allocation.
Profile your code and optimize the most used parts.