If hack code is compiled into c++, is the time efficiency of a hack program in the same league as c++, in bash processing algorithm? For example : big loops with float add and mult )
1 Answers
This is a basic misunderstanding. The original HipHopForPHP compiled PHP code to C++, but the new HHVM, and by extension Hacklang does not compile to C++.
In the new HHVM, code is compiled to HHVM-specific assembly language (bytecode), which is then interpreted by HHVM itself. For more details see this blogpost: http://hhvm.com/blog/6323/the-journey-of-a-thousand-bytecodes
There was an attempt to use LLVM for code generation, but it was deemed too risky: http://hhvm.com/blog/10205/llvm-code-generation-in-hhvm
This means that your code will never directly hit the CPU, it will always be run in a virtual machine, much like Java. While Hack is fast, it's nowhere near as fast as C++, which has a lot of zero-cost optimizations and is run directly on the CPU after compilation.

- 1,265
- 8
- 16
-
1Early version of Facebook extended PHP stuff was c++ compilation, however. https://en.wikipedia.org/wiki/HipHop_for_PHP – Xmanoux Dec 23 '16 at 11:38
-
Yes, but that has not been the case for quite some time, and Hacklang was AFAIK never compiled to C++. I'll fix my answer to reflect HHVM history better. – Janos Pasztor Dec 23 '16 at 12:15