Search code examples
phphiphop

Possible to maintain php HipHop code?


I've been reading a lot about Facebook's PHP HipHop project, but one thing I can't seem to figure out (I don't have a 64 bit machine to test HipHop on) is whether or not one could use HipHop as simply a project conversion tool, rather than just to compile a binary.

Essentially if one were so inclined to try to convert a PHP CLI application to C++ using HipHop, would it therefore be possible to just maintain it in C++ in the future, rather than having to use HipHop every time?


Solution

  • I expect that automatically translated code will be harder to maintain than handwritten code. It will be generated by a computer so you can get rid of things like loops in many places. A lot of things might be sub optimal (direct translation cannot always accommodate for idioms) and after hand tweaking this for a while, it will be a mix of styles (auto generated and hand written) which will be a maintenance nightmare.

    Essentially, you should treat this C++ code just like a binary after a regular compilation. Would you bit tweak that to add new functionality? No, you'd edit the source and then recompile it. That's what you should do here as well. The C++ is generated and an intermediate representation. The fact that it's in a human readable language shouldn't tempt you to modify it.