PHP vs. Perl

Started by ipt, Aug 09, 2022, 12:19 AM

Previous topic - Next topic

iptTopic starter

Hello there! I have some queries:

After writing in PHP for a considerable period of time, I have noticed that many prominent companies have a higher demand for Perl instead of PHP. Moreover, some reviews suggest that Perl is faster than PHP in terms of script execution, but I am not certain if this is true or not.

I have also read about certain drawbacks of Pearl, such as the 500th error and difficulty in processing data obtained from forms. Although some modules can fix these issues, it remains unclear if hosting them would be a problem.

Additionally, I am curious to know if it is advisable to keep all scripts in cgi-bin or if there are other more suitable options available. It is admittedly inconvenient that regular HTML pages cannot be placed in this directory after coming from PHP.

On the whole, it is essential to explore alternative options and weigh their pros and cons before making a decision.
  •  

RoyJones

Non-compilation modules can be simply placed alongside the script and accessed through the full path. If the hosting provider furnishes development tools, a module that necessitates compilation can be installed.

Regarding PHP vs Perl, PHP is already a significant language (though some of its features are endearing), but it possesses noticeable simplicity as well. Hence, novice web writers prefer to start their ventures in PHP. As a consequence, there are many more substandard and inadequate PHP scripts than there are in Perl. Basically, an active attempt to lower the bar for entry into PHP has resulted in a tarnished image.

However, one can also write serious code in PHP. Speaking as a Perl programmer with 9 years of experience, I can say that Perl is 50% a regular expression language that has been emulated by several programming languages (including PHP). Even Unix console utilities are gradually shifting from POSIX regexp to pearl ones. Therefore, it is worth familiarizing yourself with Perl, at least from this perspective.

In my opinion, if you have access to PCP, write code on it. If you have time and interest, learning Perl is not detrimental, but advantageous as it expands expertise. In terms of calling a perl, there is not much difference from PHP; both use the same principle for calling (e.g., from Apache via the handler), and it is the web server that makes the distinction.

Usually, PHP handler is assigned to the file extension, whereas perl and other CGI handlers must be called using the ScripAlias folder. Nevertheless, the web server has provided means to modify this principle, which is even available through .htaccess. For Apache, I recommend reading http://httpd.apache.org/docs/. If you manage the web server, there are two modules for Apache - embedded Perl solutions - one for mod_perl, the other for working with regular Perl.

Lastly, for errors, each server has an error_log. If your hosting provider does not allow access to this file, then it's time to switch providers, as the file is highly beneficial.
  •  

mdillinger

The fundamental difference between Perl and PHP lies in their very nature. Perl is a universal programming language that can solve a broad array of problems, whereas PHP was designed solely for web application development, striving to balance the power of a fully-fledged language with the benefits of a highly specialized tool. Consequently, PHP has garnered some contentious qualities in its quest for a compromise.

Perl, like any complete language, has a core - a set of functions and rules that do not depend on platform or operating system. By contrast, PHP lacks such a solid foundation and depends instead on the provider. Hence, it possesses several distinct features. Perl code is more portable and consistent, while PHP runs into compatibility issues when the hosting provider does not have the essential extensions.

PHP offers a potentially vast range of functions, with over 3000 to choose from. However, the actual number available on real hosting site only amounts to about a third. In contrast, Perl provides the programmer with a limited but effective set of standard tools, ensuring readability and smoother exchange of code and experience.

Moreover, PHP syntax has become unwieldy due to the unavoidable lengthening of function names. For example, what is called pop in Perl is array_pop in PHP. Although the two languages share some similarities, programs that look similar in one are often more cumbersome and verbose in the other when it comes to solving the same problem.

Lastly, Perl is a much more mature language than PHP, highly resistant to changes in versions and equipped with advanced development tools.
  •