Forum Moderators: coopster & phranque

Message Too Old, No Replies

CGI, PHP, PERL or C?

What should I use to do CGI?

         

junbin

1:08 pm on Mar 8, 2003 (gmt 0)

10+ Year Member



I've tried to make sites using Perl and C and so far, the results are very differentiated.

With a Perl based site, the pages come out significantly slower (ie: Databse intensive pages can take up to 10s) while a C based site usually displays the pages instantly.

Is it simply coz my Perl sucks or is there really such a big difference in speed between Perl and C?

Also, since I was testing the pages on my own personal computer which is more or less clutter free, wouldn't the results when tested on a shared webhost be very very much worse? I'm not very experienced with webhosts and stuff since the most I've had were free ones which didn't support CGI.. but now that I'm committed to making a CGI site, I'd like to check out whether webhosts in general (or westhost specifically) object to CGI programs that hog up CPU resources... and if they do, how do they define hogging?

gsx

3:01 pm on Mar 8, 2003 (gmt 0)

10+ Year Member



Perl is interpreted, which inherently makes it slower. C is compiled into machine code before it is run, which makes it faster. But if your hosts changes servers, let's say from Windows to Apache, your Perl code should still run perfectly (there are a few commands that differ, but not too many). But the change from Windows to Unix/Linux may kill any C code until you recompile it to be suitable for the new type of machine.

seindal

1:48 pm on Mar 9, 2003 (gmt 0)

10+ Year Member



If you run perl programs as cgi scripts, they will be substantially slower than C programs, but if you run you perl code under Apache/mod_perl, they will be fast. Not quite as fast as C, but a lot faster then without mod_perl. The loss of execution speed is far outweighed by the increase in coding/debugging speed.

René.

jatar_k

4:09 pm on Mar 9, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The same holds true for php, it can be can be compiled as an apache module and the speed increases exponentially.

GeorgeGG

5:41 pm on Mar 9, 2003 (gmt 0)

10+ Year Member



free ones which didn't support CGI

I have a C based site (RedHat) and a few years ago I checked
on hosts that would allow you to run a binary, 'very few'.
The few that did wanted to view each change to code, and/or
they would have to compile it for you, etc...

Also my host box is about 4 (on box stuff) to 60 (sockets/external stuff)
times faster than my test box, 133mhz/64meg/cable, at home.

GeorgeGG

edit:
I compile at home then upload to server.

andreasfriedrich

10:36 pm on Mar 9, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>C is compiled into machine code before it is run...

...and so is Perl code. Perl is not interpreted but compiled each time before a script is run. That is why mod_perl will make such a difference because a given module will be compiled only once and then sit around as machine code waiting to do its job.

Andreas

seindal

12:47 am on Mar 10, 2003 (gmt 0)

10+ Year Member



then sit around as machine code waiting to do its job.

This is not 100% true. Perl code is compiled, but to a type of byte-code, in principle like java byte-code, which is then interpreted by the the perl interpreter. The byte-code is designed to be easy and fast to interpret, hence the speedup if you can skip the compilation phase.

René.