Has anyone else found this?
Speed has always been argued in favor of PHP, but anything I've ever read or tested seems to show it as an insignificant difference. It's funny you raise this question, most coders argue the other way around. I came into PHP after learning perl and found PHP easy to learn, in fact, it was originally described to me as "perl, but in the page."
You will find many things different in perl, but many the same. What I like about perl is there are visual differences between scalars, associative arrays, and list arrays.
perl:
%hash = ('a'=>'Aye','b'=>'Bee');
@array = ('a','b');
$scalar = 'a';
PHP:
$hash = ('a'=>'Aye','b'=>'Bee');
$array = ('a','b');
$scalar = 'a';
The other is the management of global variables. Define a glob in one script:
$global = 'a';
require('script.pl');
require('script2.pl');
require('script3.pl');
It becomes available everywhere. For PHP, they have an entirely different outlook on globals; for example, to use it in a function, you have to define the global directly within the function to access it (there are exceptions; )
function some_func() {
global $global;
.....
}
Another is the complete absence of sub's in PHP. This one was hard for me to get past. :-)
I use them both, but then, I use Macs and Windows without prejudice either.
[edited by: phranque at 11:15 pm (utc) on Dec. 12, 2008]
[edit reason] fix smiley ;) [/edit]
Definately learning php has lead me to perl and I guess for most people its the other way round.
Global variables is an interesting point. Its one I really struggled with on php but with Perl it seemed to be a very easy thing.
But for code creation, PHP is certainly faster for most web applications by its very nature. You can cobble together a page containing a little PHP widget in an instant. Creating a webpage based on Perl often involves knowing which CPAN modules you'll need to load, parsing out any data being passed to it, and often dealing with issues arising from the fact that the Perl files are segregated into a /cgi-bin directory even if the server doesn't actually require it.
I personally prefer perl because it fits my style of thinking. I don't like the inconsisting function naming php, the missing closures and the fact that there are thousands of functions and many of them have confusing arguments etc pp. I don't recommend php to beginners because it takes the programmer another step away from what's actually happening (register globals is just the tip of it) so that (my observations only) many people do stuff but don't understand the underlying concept of http, client and server etc.
I do php though, I'm forced to because of all the boards and shops written in php and demanded by clients. Would love to see some open source perl-solutions with similar features...
Speed has always been argued in favor of PHP, but anything I've ever read or tested seems to show it as an insignificant difference.
PHP is faster (at least in every test I've done) but as you say, it's a tiny difference.
However, this is assuming you write your own code for the things you're doing in PERL. For instance if you use the CGI module your perl script is then, automatically, going to create significantly more load than a PHP script which does not need to call an external module for the same functions.
The PERL script itself will still probably run at nearly the same speed as a comparable PHP script but the server will overload (and thus slow down) sooner.
Still, as with almost any two programming langauges, the differences aren't huge, it comes down to personal preference.