homepage Welcome to WebmasterWorld Guest from 54.226.43.155
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Perl vs PHP Speed!
Live4now




msg:3805770
 3:46 am on Dec 12, 2008 (gmt 0)

For a long time I saw perl as a thing beyond me but as I learned abit of php I also started to understand perl and found more an more scripting in perl was worth the effort as it was faster than php.

Has anyone else found this?

 

rocknbil




msg:3806134
 2:39 pm on Dec 12, 2008 (gmt 0)

Welcome aboard, Live4now!

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]

Live4now




msg:3806517
 12:34 am on Dec 13, 2008 (gmt 0)

I do still struggle with Perl but do love beeing able to confine in the cgi-bin and although definately php is easier to write the scripts do seem to me to work faster in perl. Of course this maybe just badly written php on my part :)

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.

rainborick




msg:3806634
 4:37 am on Dec 13, 2008 (gmt 0)

I've rarely written anything complex enough for execution speed to be an issue I cared about. It usually seems to me that the differences between PHP and Perl are pretty much of a wash these days. Response times are more often affected by other issues.

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.

janharders




msg:3807212
 4:41 pm on Dec 14, 2008 (gmt 0)

the speed-discussion is usually broken because people compare mod_php and cgi-scripts written in perl. the extra process generation time for cgi will always result in a slower result.
I think, they're pretty much at the same level if you just compare execution time. php has those accelerators which give it an edge, perl has mod_perl which is not only very fast but also pretty much the mightiest thing around for apache-scriptlanguage-development.

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...

IanKelley




msg:3810627
 7:41 pm on Dec 18, 2008 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved