PHP Classes

Not bashing, I use PHP

Recommend this page to a friend!

      PHP Classes blog  >  Top 10 Wrong Ideas Ab...  >  All threads  >  Not bashing, I use PHP  >  (Un) Subscribe thread alerts  
Subject:Not bashing, I use PHP
Summary:Some of the information here could be missleading
Author:Donald Duvall
Date:2011-08-19 15:38:09
Update:2011-08-20 08:55:11

  1. Not bashing, I use PHP   Reply   Report abuse  
Donald Duvall - 2011-08-19 18:40:56
I am not saying that any language overall is better or even implying that PHP is bad. I use PHP all the time and actually am finishing up a new Application framework for PHP based websites.

Point 1:
When you say that php is not in interpreted language, this is only partly true. While it is not interpreted at runtime from a Text source it is still interpreted from a Binary source (not exactly machine code). This does cause the language to be slower than others that are fully compiled and possibly even other "Script" languages. The speed of script languages often depends on how their engines "compile/interpret" high level features to a set of machine instructions.

Something like: $obj = new $className(&$variable);
is going to result in a lot of machine instructions. And, other script languages may have designed their underlying framework that supports this to work faster and have fewer machine statements.

So, just to sum that point up. PHP is still Interpreted however not from a text source, PHP is not Compiled to a machine code file and linked for stand alone execution. Making languages like C#, C++, D, Pascal, and any other that results in a Compiled and Linked machine code file much faster during execution.

Point 2:
C# is not the same level of compilation and interpretation as PHP, like you stated. C# is compiled to IL (similar to OpCode) and on the first execution or if you choose you can use the pre-compiler, the IL is compiled into machine code and linked. If you pushed the IL code exe, then the .Net framework will Compile and Link the IL for the specific hardware that you have on the machine. This makes any .Net language more optimized since it still does some similar conversion from Higher level code to a lower level code in the compilation to IL. And if you are thinking that it is similar to PHP because you need the Framework to run a .Net executable, don't be deceived. The framework after the compilation process is nothing more that already compiled DLL's that have low level functions that you higher level code compiled to a lower level code execute. This is part of the reason it is so fast.

So, please do not try to say that PHP is well suited for high performance web applications. We should all know that it is much slower that a real compiled executable. However that doesn't mean that you shouldn't use PHP. Choose your programming language and environment for each project. And pick the one that fits what you need. If you need high performance processing then pick a language that will deliver that (its not going to be PHP) but if you need a very capable Script language for a website that allows for quick development and high level code features with awesome array/map object all in one, then choose PHP.

I believe that there are so many different languages because there are so many different features that we look for in each project. So determine what you need from your language for your project and choose the language that best fits. PHP is not an all in one stop for all projects. I don't see any advanced NextGen Graphics rendering engines developed in PHP. I think its because its not the right language for the job.

Just my thoughts,

  2. Re: Not bashing, I use PHP   Reply   Report abuse  
Manuel Lemos - 2011-08-20 08:55:11 - In reply to message 1 from Donald Duvall
1. It does not make much sense comparing PHP with lower level languages like C++, because PHP does a lot of things behind the scenes that if you try to do in C++, you would have to write much more code to do the same, like for instance the implicit memory management and garbage collection.

That is why Facebook had an hard time to squeeze more performance from PHP code converted to C++.

Anyway, the point of the statement about PHP being a compiled language, is that in most cases PHP is not noticeable slower than those other compiled languages. People that thing PHP is much slower just do not understand the technical details that influence the speed of real world Web applications. That is what this article aimed to explain.

2. As for comparing PHP with C#, they basically play at the same league or compiling code into opcode or .NET assemblies. It just seems that you are not considering that PHP can also be compiled to native code, if you really insist, either using Facebook HipHop for PHP, or LLVM compiler, etc..

Other than that, if you really insist that C# is different, let me the Phalanger project that converts PHP to .NET assemblies. Phalenger developers were hire by Microsoft. So everything you can do with compiled C# code, you can do with PHP compiled with Phalenger.

As for claiming that PHP cannot be used for high performance sites, it seems pure prejudice. You may need to read again the explanations of how Facebook uses PHP in most of their production servers.