<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dominique Stender &#187; accelerator</title>
	<atom:link href="http://www.st-webdevelopment.com/tag/accelerator/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.st-webdevelopment.com</link>
	<description>Good software is only the beginning</description>
	<lastBuildDate>Sun, 26 Feb 2012 16:24:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Thoughts on HipHop for PHP</title>
		<link>http://www.st-webdevelopment.com/php/2010/02/thoughts-hiphop-php/</link>
		<comments>http://www.st-webdevelopment.com/php/2010/02/thoughts-hiphop-php/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 17:26:39 +0000</pubDate>
		<dc:creator>Dominique</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[accelerator]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://www.st-webdevelopment.com/?p=321</guid>
		<description><![CDATA[An overview of the PHP-to-C++ transformer HipHop for PHP that was recently announced by Facebook. I give an analysis of it's potential along with the requirements and possible limitations.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-327" title="HipHop_logo_white" src="http://www.st-webdevelopment.com/wp-content/uploads/2010/02/HipHop_logo_white.png" alt="" width="213" height="278" />It has been almost two weeks now since Facebook announced <a title="Announcement for the HipHop for PHP code transformer" href="http://developers.facebook.com/news.php?blog=1&amp;story=358" target="_blank">HipHop for PHP</a>. The source code is still not available because apparently they've ran into some compilation issues, according to <a title="HipHop for PHP on GitHub" href="http://github.com/facebook/hiphop-php" target="_blank">their GitHub</a> status. So in essence, not much is known about HipHop for PHP but I want to try to give my thoughts based on the small amount of information we have and my experience with similar technologies.</p>
<blockquote><p>Please note that the bits and pieces of information come from various sources and things may or may not be exactly as we think they are.</p></blockquote>
<p>In order to understand what HipHop for PHP does it is important to understand how PHP itself gets executed. In this article I will give a rough overview of the PHP execution process and make a few educated guesses in what aspect HipHop for PHP differs from there.</p>
<p>Based on the little information available online I'll discuss how HipHop for PHP is suitable for large businesses and what might turn out to be obstacles that are yet to remove.</p>
<h4><span id="more-321"></span>The PHP execution process</h4>
<p>PHP code can not be executed directly, a property it shares with all other scripting languages such as Python, Ruby and JavaScript. What makes PHP executable is the Zend Engine, and it does so in a two stage process.</p>
<ol>
<li>The scripts are parsed and analyzed, checked for syntactical and semantical errors and if all goes well the application is transformed into byte code.</li>
<li>Since the byte code is still not executable on a CPU, it is interpreted further into machine code (that is CPU dependent) and then executed.</li>
</ol>
<p>For most PHP applications the first parsing stage takes most of the total time. The second execution stage is comparatively fast. So in order to speed up a PHP application, most code optimizers hook into the Zend Engine after the first stage has been completed and save the generated byte code into a cache. In a consecutive call to the webserver the cache will be fed back into the Zend Engine, thus skipping the entire first stage of the execution process.</p>
<p>There are quite a few products on the market that behave in such a way. Zend itself offers the <a title="Zend Optimizer" href="http://www.zend.com/en/products/guard/zend-optimizer" target="_blank">Zend Optimizer</a> (now part of Zend Guard), there is <a title="eAccelerator PHP optimizer" href="http://eaccelerator.net/" target="_blank" class="broken_link">eaccelerator</a> and <a title="APC, the Alternative PHP Cache" href="http://pecl.php.net/package/APC" target="_blank">APC</a>, which comes as a PECL package.</p>
<h4>The execution process with HipHop for PHP</h4>
<p>What sets HipHop for PHP apart from these three (and no doubt other) accelerators is that it does not act as a cache. Instead, HipHop for PHP will transform your PHP application into C++ code and compile that directly into a binary which is executable.</p>
<p>In that sense, HipHop for PHP is probably very similar to <a title="Roadsend PHP" href="http://www.roadsend.com/home/index.php?pageID=compiler" target="_blank" class="broken_link">Roadsend PHP</a> which also generates executable code from PHP, albeit not by transforming it into C++ first.</p>
<p>In essence, HipHop for PHP will get rid not only of the first stage of the usual execution stage, but also of a big part of the second stage, namely the interpretation of byte code into machine code. Generally I believe it is safe to assume that HipHop for PHP has the potential to run an application much faster than any of the previously mentioned accelerators, simply because there is less for to be done at runtime. Time will tell.</p>
<p>For detailed information on the internals of HipHop for PHP make sure you watch the <a title="Video of the HipHop for PHP announcement" href="http://www.ustream.tv/recorded/4409735" target="_blank">Facebook Technology Tasting</a> video on ustream.</p>
<h4>Possible limitations</h4>
<p><strong>The requirements</strong><br />
The <a title="HipHop for PHP requirements" href="http://wiki.github.com/facebook/hiphop-php/building-and-installing" target="_blank">requirements to run HipHop for PHP</a> are available online. Nothing out of the ordinary at first sight. The page claims that HipHop for PHP is tested on <a title="The CentOS Linux distribution" href="http://centos.org" target="_blank">CentOS </a>and <a title="the Fedora Linux distribution" href="http://fedoraproject.org/" target="_blank">Fedora</a>. Both are venerable distributions, no doubt. But both also come without vendor support which may or may not be a problem for your organization.</p>
<p>Granted, companies who's codebase can actually benefit from HipHop for PHP will no doubt have a team of excellent system administrators which maintain Linux in their sleep. But those companies might also be in the situation that their customers demand a Linux distribution with commercial support, such as SLES, RedHat etc.</p>
<p>So this is more an organizational issue rather than a technical. That being said it is not clear yet whether or not packages will be released by other Linux distribution vendors once HipHop for PHP is out. If at all, it probably won't happen soon.</p>
<p>Coming back to the requirements for HipHop for PHP, it requires customized packages of libcurl and libevent, which again may or may not be an issue for your environment. Here I see the same organizational issue, but also a possible technical issue - you might be in the situation that you need the original libcurl or libevent for some other software on the server. Only a practical test will tell.</p>
<p><strong>Unsupported language constructs</strong><br />
As with most PHP caches and compilers, a few PHP language constructs are not supported. Most commonly known is the eval() construct which is simply not available in C++. Personally I believe that eval() is a bad thing to begin with and you can get around it in almost every cases. Sadly many PHP frameworks such as <a title="TYPO3 content management system" href="http://www.typo3.org" target="_blank">TYPO3</a>, many <a title="PEAR - the PHP extension and application repository" href="http://pear.php.net" target="_blank">PEAR</a> packages, <a title="Drupal content management system" href="http://drupal.org/" target="_blank">Drupal</a> and <a title="The Joomla content management system" href="http://www.joomla.org/" target="_blank">Joomla</a> make use of eval().</p>
<p>If you're intending to run one of these through HipHop for PHP you might need to wait for an update from the community, patch it yourself, or remove the code from the system if you don't need it. In any case this is a time consuming task.</p>
<p>Aside from eval() a few more language constructs may not be supported or may not benefit from the compilation in terms of performance, such as call_user_func_array() and other 'dynamic' constructs like dynamic variables, dynamic includes or built-in functions like function_exists(), class_exists(), get_declared_classes() etc.</p>
<p>HipHop for PHP is no different from other caches and compilers in these regards, so please don't make that affect your choice. Just be aware that things might not be as easy as you'd like them to be.</p>
<p><strong>No Apache?</strong><br />
This is speculative at this point but the <a title="Running HipHop [for PHP]" href="http://wiki.github.com/facebook/hiphop-php/running-hiphop" target="_blank">Running HipHop</a> page on GitHub seems to indicate that HipHop for PHP will not make use of the Apache webserver but instead come with its own webserver. My assumption is that this means we'll have to handle HipHop for PHP through Apache, much in the same way that we frequently do with Tomcat. This is not necessarily an issue.</p>
<h4>The potential of HipHop for PHP</h4>
<p>Despite the limitations I mentioned above, I believe HipHop for PHP has the potential to take PHP much further into the enterprise environment than many of the existing solutions. If it can deliver what it promises it is definitely something we will take a very close look at to give our eCommerce framework a serious performance boost.</p>
<p>Very high on my wishlist is to run the transformation process from PHP to C++ but skip the compilation. If that's possible I see the chance to make debugging compile errors much easier.</p>

<!-- using Like-Button-Plugin-For-Wordpress [v4.5.2] | by Stefan Natter (http://www.gb-world.net) -->
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.st-webdevelopment.com/php/2010/02/thoughts-hiphop-php/&amp;layout=standard&amp;show_faces=false&amp;width=550&amp;action=like&amp;colorscheme=light&amp;height=30&amp;locale=en_US" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:550px; height:30px"></iframe>
<!-- using Like-Button-Plugin-For-Wordpress [v4.5.2] | by Stefan Natter (http://www.gb-world.net) -->
]]></content:encoded>
			<wfw:commentRss>http://www.st-webdevelopment.com/php/2010/02/thoughts-hiphop-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

