View Single Post
Old 06-11-2004, 12:23 PM  
Nathan
Confirmed User
 
Industry Role:
Join Date: Jul 2003
Posts: 3,108
I hate to TOTALLY disagree to all of this, but I sadly have to

C++ vs PHP/mySQL is first of all a bad comparision.

1) We need to compare C/C++ vs PHP.. the database type will be the same, makes no sense otherwise.

2) We need to make sure what EXACTLY we are talking about:
a) C/C++ CGI App vs PHP Script
b) C/C++ FastCGI App vs PHP Script
c) C/C++ Apache Module vs PHP Script

I would say, most of you here were thinking of a), so lets look at that one:

Overhead when executing a C/C++ CGI app is rather huge. Why? Well, Apache first has to run an exec call, which basically FORKS apache and then lets the CGI app take over the process. This prosess is rather time consuming and resource hungry.
A PHP Script is simply loaded by the php module, which gets called instead of the base module. So no time is lost here, then PHP has to compile the script, obviously, not the fastest thing, but in terms of resources, its a HUGE advantage to the exec involved in the C/C++ App.

Now, for Database connection, the C/C++ CGI app has to open a new connection to the Database, whereas PHP will have it already in most cases. Although also connects are fast, its still a time saver for PHP.

Last but not least, C/C++ apps will tend to be harder to write and a lot less flexible. Load on the server will very likely also be higher when using C/C++ apps because more apps are running.

And, like many posted here, PHP can be extremely speed up by taking out the rather slow parsing step and by caching the system. This caching does not mean caching the OUTPUT, it means caching the fully compiled and optimized script in various stages in memory to run it even faster.

So, unless the person writing the app in C/C++ really has a _VERY VERY VERY VERY_ good rep of knowing how to do CGI correctly, I would ALWAYS prefer PHP over anything else.
__________________
"Think about it a little more and you'll agree with me, because you're smart and I'm right."
- Charlie Munger
Nathan is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote