I read an discussion in a forum in which a guy swore that PHP is now compiled. From what I've read PHP is interpreted and compiled at runtime. The Zend optimizer helps, but I haven't read anywhere that it makes PHP a compilable language. Will any expert clear my mind on this subject?

    PHP is compiled to Zend bytecode and then run by the runtime engine; usually at load time from source code, but you can get optimisers that will save the bytecode itself and run that. This is the same mechanism used by Java and .NET, except that they make the compilation to bytecode a separate build step while PHP bytecode compilers generally operate on the principle of doing it if and when the source code is both available and newer than the stored bytecode.

    You can also compile to native executables; but due to the nature of PHP it's generally more a matter of saving a copy of the runtime and stashing the source or bytecode inside it as a resource. Priadoblender does that as I recall. There are other bytecode compilers for PHP: Phalanger, for example, compiles to CLR bytecode. I wouldn't be surprised if someone's done it for Java bytecode and Parrot, too.

    Interpreted, compiled, bytecode, machine code; it's all a bit blurry anyway, at least without the context of which stage in the build process we're talking about and what we're supposed to be compiling to (are we talking about the JIT compiler that turns machine code into microcode?). Would you call JavaScript a "compilable language"? Check out V8 and Rhino.

      Write a Reply...