PHP

Not one of my favourite languages but very popular for rapid development of web applications, this interpreted language does a decent job on the front-end/ web facing/user-interface. However, it is interpreted which is extra work for the server. Caching can help but the answer is a compiler. Use PHP as it is to debug/develop rapidly your site but compile the code into machine readable stuff for faster execution. That is the obvious way to go and I did think to do such a project years ago, but it never amounted to anything. My concept was to rewrite important PHP scripts in Pascal so that they could compile properly.

The trolls here have pooh-poohed this idea, citing Facebook as an example of a high-powered/busy site running lots of PHP. Low, and behold, there is a story out that Facebook is working on a compiler for PHP.

Rumpus: So what will be the net effect of running the site on Hyper PHP?

Employee: We’re going to reduce our CPU usage on our servers by 80%, so practically, users will just see this as a faster site. Pages will load in one fifth of the time that they used to.

Facebook agrees. PHP is too slow as an interpreted language. QED.

Now, there are aspects of PHP that do not lend themselves to compiling like loose/flexible typing. The compiler has to make a choice at compile-time. This could be a fork of PHP or a new interface. We await the news.

Update: I tested the Roadsend PHP compiler against “Hello, World!”. My Pascal version executes in 0.001s according to time. The Roadsend version takes 0.1s. The difference? The statically linked version is 5.8MB! while my Pascal binary is 0.1MB. Maybe Hello, World! is not the best benchmark but it is an indication of problems with PHP compilers. Perhaps this is not an issue for FastCGI.

Update: Facebook has announced their project, HipHop,

HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features — such as eval() — in exchange for improved performance. HipHop includes a code transformer, a reimplementation of PHP’s runtime system, and a rewrite of many common PHP Extensions to take advantage of these performance optimizations.

They have tweaked the language a bit and the runtime and compile it in C++ instead of interpreting the code. They get a 50% reduction in server load doing that so it pays in a big way. They will release the code as FLOSS later today. 50% may be no motivation at all for a light-weight site but for Facebook, it probably will save them millions annually in operating costs. For me, it could cut response time which is a great thing in a web app.

- Robert Pogson

0 Responses to “PHP”


  1. No Comments

Leave a Reply




Archives by Month

My Mission

My observations and opinions about IT are based on 40 years of use in science and technology and lately, in education. I like IT that is fast, cost-effective and reliable. I do not care whether my solution is the same as yours. I like to think for myself.

My first use of GNU/Linux in 2001 was so remarkably better than what I had been using, I feel it is important work to share GNU/Linux with the world. I have been blessed by working in schools where students and school systems have benefited by good, modular software easily installed in most systems.

I have shown GNU/Linux to thousands of students and hundreds of teachers over the years and will continue in some way doing that until I die in spite of the opposition.

Posts

January 2010
S M T W T F S
« Dec   Feb »
 12
3456789
10111213141516
17181920212223
24252627282930
31