I know PHP 5 has some object oriented similarities but it's not a true OOP environment still right? Also does it have a true compiler? I see compiling of scripts which still means procedural. I assume it's not a real compiler in that any PHP compilers out there do not create assemblies?
Similar questions discussed a lot of times. There is no "true" or "false" OOP. Due to php supports encapsulation, polymorphism, inheritance - it is Object Oriented Programming Language. And there are no still "true" compilers. But you can look at Facebook's Hip-Hop
PHP is now a completely object oriented language, even if most of the API isn't.
- It supports class and objects.
- It follows the principles of OOP (Inheritance, Encapsulation, Abstraction, Polymorphism)
It is therefore a completely object oriented language.
PHP actually does compile (by default on every run unless using "an accelerator") its scripts into intermediary byte-code which is then run by the Zend Engine.
It's actually pretty close to other languages:
VB.NET / C# / F# / other .NET Languages
Those languages when compiled does not output binaries in assembly code, but rather binaries in Common Intermediate Language (CIL). CIL bytecode is then interpreted at runtime by the .NET Virtual Machine.Java
Java compiles.class
and.jar
files which are not in assembly code, but rather in Java Bytecode. Java Bytecode is then interpreted at runtime by the Java Virtual MachinePHP
PHP compiles into Zend Bytecode, which is then interpreted at runtime by the Zend Engine.
I think you should read up a bit on the definition of the words you're using!
"Assemblies" are a word that .NET uses for something that's loosely translated as "a DLL plus some support stuff that you can deploy." Perhaps you were thinking about "assembly code"?
Compilers compile to all kinds of representations. JVM bytecodes, CLR bytecodes, x86 bytecode, Python bytecode, MIPS bytecode, ARM bytecode, ... Those are all valid targets for a compiler. Note that, for both JVM and x86 bytecode, there exists both hardware (CPU) and software (interpreter) execution environments, so whether the target code is "hardware" or not doesn't really play into it.
Compiling of code versus interpreting of code doesn't mean anything when it comes to OO vs procedural vs functional. OO has to do with supporting polymorphism, data hiding, data-goes-with-interface-implementations and composability.
PHP supports all those things, so you can use it to implement an OO design in a straightforward way, so I would say that PHP supports OO.
Finally: you should look at the Facebook PHP compiler, which compiles PHP to C and then C to x86, which apparently gives it a 50% speed-up compared to the traditional PHP execution environment.