3 ms·
This is truly the PHP solution to the problem. Design a virtual machine that uses runtime information to generate highly-optimized native code? Nahh.... just
by jrockway 17y ago
This is truly the PHP solution to the problem. Design a virtual machine that uses runtime information to generate highly-optimized native code? Nahh.... just regex the source into C++, compile with g++, and enjoy!
(To be fair, some language implementations have achieved good results with this method; notably Chicken scheme. But I was expecting something better and potentially more useful to the language implementation community at large.)
- Raphael 17y agoC++ is known to be fast, so what advantage could a more complex solution provide?
- jrockway 17y agoNot having to wait fifteen minutes for your app to compile and link, for one thing. But seriously, the C++ implementation comes at the cost of many of PHP's features; a "more complex solution" would allow those features to be kept. And while C++ is fast, a script translated into C++ is not going to be as fast as if you had written the application directly in C++, unless the compiler is very, very smart. (I have not seen any implementation that does this; GHC's native code generator produces faster code than it's "via-C" code generator, for example.) Also, static compilation precludes runtime-based optimization techniques, which has made a lot of code run "faster than C" (including C, ironically; see LLVM). So anyway, all this is is a way to compile a limited subset of PHP to C++. In doing so, you have to write a special dialect of PHP, without PHP's easy deployability and code/test/debug cycle. In that case, why are you using PHP to begin with, when a language like GHC or SBCL would run faster and without any compromises?
- rufugee 17y agoUmm...note in the post the mention of HPHPi, which gives you the code/test/debug cycle of regular PHP but using (apparently) HipHop.
- spudlyo 17y agoNot even the Linux kernel takes 15 minutes to compile and link anymore. My desktop machine does it in under 10 minutes, but I realize you weren't being entirely serious. http://xkcd.com/303/ http://xkcd.com/303/