I saw this post on Sitepoint quoting a statement by Rasmus Lerdorf which goes (according to Sitepoint) as follows:
How can you make PHP fast? Well, yo
Thanks to Artyom for the link to this informative link,
http://idleprocess.wordpress.com/2009/11/24/presentation-summary-high-performance-at-massive-scale-lessons-learned-at-facebook/
which says, among much else, "C++ Interoperability Challenging."
C++ requires much effort to write a website. Why not pick a language between C++ and PHP, say Python which is executed by bytecode JIT, and I understand is relatively easily extended by C++.
Don't even bother. PHP is slow... You may create a mixture of C++ and PHP but you'll need to do lots of profiling to understand what is slow. And this is mostly... PHP.
See following:
Just write in C++ in first place. It is as simple as writing in PHP with modern C++ web framework and good knowledge in C++.
Where to start:
For large calculation and processing C++ can be used with php. And for lighter process only PHP is enough.
While working on data processing or calculation based applications C++ can help. Please not you have to use one trick here.
One need to create server(daemon) process which keep listerning for the request. This daemon process is already compiled and it contains processing code.
So when there is any request to process the data it will do it much faster then PHP and reply back with result.
One can use exec
or similar function to execute daemon executable.
The bottleneck is usually I/O or database queries rather than what language you're using.
Slow is subjective term. Facebook (the biggest site online) is built on PHP and I never heard them complain. In the contrary in their pursuit of speed the developed and recently released HipHop If you are going for ultrafast PHP this is where you should focus. C++ for web is kind of impractical because it needs to be compiled and it will slowdown the development process.
Because: Why are so many web languages interpreted rather than compiled?
http://www.bitsandbuzz.com/article/compiled-web-vs-interpreted-web/
The first question that springs to mind is: do you develop for a website processing more than a million hits per hour? Because if not, then your costs are all in software development, and you'll get more bang for your buck by tuning your current PHP code and adding hardware than migrating even part of the codebase to C or C++.
See also http://shootout.alioth.debian.org/ note the comparisons of code size.
Yes, above this level (approximately), then your hardware costs start escalating to the point where it's worth the extra effort of developing in a compiled language.
The next thing to bear in mind is that while it's true that a very well written compiled code will almost always outperform a similarly well written interpreted code, when the code quality is even slightly less than perfect, the difference reduces - and the effect will vary depending on the language as well as the programmers ability. I currently look after a competently developed web application written in Java (which runs as native code) which requires twice the hardware resource to run slower than a comparable system I've managed, written in PHP by programmers with might be best described as quite a wide range of skill levels. Although this directly contradicts what most programmers would think of as common sense, I'm confident in saying that the interpreted/compiled argument is not the only one. There are lots of orgranisations/individuals out there still developing interpreted langaues, e.g. Groovy, Apex.
C.