Mathew
05-14-2004, 11:06 PM
well by real world I mean scripts for adult webmasters, for everyday use.
also I'm not including python and other languages like this because they're too rare in our community.
So, to the topic.
Why is C/C++ considered faster? Because it's compiled. And if you run it from command line, equal codes will execute faster in C/C++ than they'll do in PHP or PERL. (I guess I should not explain why, you all know that)
But here comes the smart part.
all C/C++ applications are executed via CGI interface. Common Gateway Interface. And at that time, webserver has to fork another process, this application (well .. if somebody don't know what does that means, webserver kinda "types" the command on the command line).
And that's where it's slowing down.
(To the people who will object. - Of course I'm aware of FastCGI and Apache modules but let's be honest - if you have an administrator/programmer capable of installing FastCGI and adapting scripts for it or writing an apache module, you're probably not reading this anyway :D )
PHP on the other hand, when installed correctly (as an apache module), have to load the script, execute it. that's it. and usually if this script is something like out.php, thumbs.php.. then it already resides in memory.
So in that case, PHP is faster. C/C++ can only be faster in case when multiple math operations for example are performed. And I do mean multiple. Tradescripts/thumbscripts perform few. A couple. (a shameless plug - tmanager perform NONE on out :D )
okay, so here we are. PHP is faster than C/C++.
So from where comes the myth about slow PHP scripts?
Because of the fast learning curve of PHP. Anyone without knowledge of application architecture can throw up a script and some even sell it.
I've seen sources of hundreds of adult scripts, free and paid, and MOST suffer from very poor architecture and database design. That's why they're slow. Ain't no PHP problem, is it?
On the other hand.. if you can program C/C++ then you probably have at least SOME knowledge on how to build database structure and application architecture. That's why sometimes, despite of the CGI thing, C is faster.
But now, our loved customers.. Try running your thumbs.php. And remember that it's zend encoded, performs no math and one filesystem operation. Is it slow? :)
Okay, hope this cleared some things out :)
also I'm not including python and other languages like this because they're too rare in our community.
So, to the topic.
Why is C/C++ considered faster? Because it's compiled. And if you run it from command line, equal codes will execute faster in C/C++ than they'll do in PHP or PERL. (I guess I should not explain why, you all know that)
But here comes the smart part.
all C/C++ applications are executed via CGI interface. Common Gateway Interface. And at that time, webserver has to fork another process, this application (well .. if somebody don't know what does that means, webserver kinda "types" the command on the command line).
And that's where it's slowing down.
(To the people who will object. - Of course I'm aware of FastCGI and Apache modules but let's be honest - if you have an administrator/programmer capable of installing FastCGI and adapting scripts for it or writing an apache module, you're probably not reading this anyway :D )
PHP on the other hand, when installed correctly (as an apache module), have to load the script, execute it. that's it. and usually if this script is something like out.php, thumbs.php.. then it already resides in memory.
So in that case, PHP is faster. C/C++ can only be faster in case when multiple math operations for example are performed. And I do mean multiple. Tradescripts/thumbscripts perform few. A couple. (a shameless plug - tmanager perform NONE on out :D )
okay, so here we are. PHP is faster than C/C++.
So from where comes the myth about slow PHP scripts?
Because of the fast learning curve of PHP. Anyone without knowledge of application architecture can throw up a script and some even sell it.
I've seen sources of hundreds of adult scripts, free and paid, and MOST suffer from very poor architecture and database design. That's why they're slow. Ain't no PHP problem, is it?
On the other hand.. if you can program C/C++ then you probably have at least SOME knowledge on how to build database structure and application architecture. That's why sometimes, despite of the CGI thing, C is faster.
But now, our loved customers.. Try running your thumbs.php. And remember that it's zend encoded, performs no math and one filesystem operation. Is it slow? :)
Okay, hope this cleared some things out :)