HN user

willemst

23 karma
Posts0
Comments6
View on HN
No posts found.

We did not measure this separately. With Hiphop, you compile a bunch of PHP files to a binary executable file. Once you have this file, you cannot load any new PHP files like you can with vanilla PHP. So including the Smarty templates is kind of mandatory.

We did not really consider it, as we have few experienced Java developers and had no need to make Java and PHP code work together.

The Hiphop project started of because one engineer thought it was "really cool" and when he was able to produce impressive benchmarks, we put some more company effort into it.

Namespaces don't work very well, all functions that create dynamic code (code that is not known at compile time) don't work (eval(), create_function(), preg_replace() with 'e' modifier).

Don't define constants where the name of the constant is a variable, as in "define($key, $value)"

Don't use "current($a)" to get the first element of an array $a, but use "reset($a)". current returns whatever element the internal array pointer points to, and PHP changes that pointer in crazy/undefined ways. Hiphop has a saner way to handle that pointer, but it's not the same as in PHP so your code might break if it's dependent on the specificities of PHP. In general use current only in case you are explicitly handling the internal pointer (that is, you are also calling reset/next).

Under the compiled version of hiphop, class_exists returns true for (almost) all the classes even if you haven't already included the file where they are defined, since they are all statically compiled.

Don't rely on destructors being called at the end of the requests: under hiphop they aren't. So either the object happens to be destructed during request execution (due to its reference count going to 0), in which case the destructor is called, or the object is garbage collected at the end of the request and its destructor is just ignored.

There are some differences in the handling of SOAP errors in Hiphop.

This will give a fatal error in Hiphop but not PHP: $z = null, $z[0] = "foo";

You can consult these Hiphop docs: https://github.com/facebook/hiphop-php/raw/master/doc/incons... and https://github.com/facebook/hiphop-php/raw/master/doc/incons... for a list of other inconsistencies between PHP and Hiphop.

I would like to elaborate a bit on this. Currently, Hiphop supports 99% of the PHP 5.3 features. When we started working on Hiphop, less was supported.

Stuff like closures, eval(), create_function(), constants with dynamic names (e.g. defining constants from an array) and class destructors were all not supported. Some more subtle stuff: you cannot use current() to get the first element of an array in Hiphop, class_exists() always returns true.

We also had to port our custom PHP extensions.

Finally, we spend a lot of time on related stuff such as precompiling all Smarty templates (so that the generated PHP gets translated to C++ too), using Hiphop's daemon system and setting up compile, build and deploy systems.