PHP vs. X programming language

soruce: zend.com by: kschroeder

Being a new Zender I’ve spent some time in the recent past looking at people’s opinions about PHP now that it directly affects the work I do. In my research I have found a lot of interesting “opinions” about PHP vs. this that and the other thing, usually in the form of lists. “4 reasons why Java will outlast PHP”, for example.

So, I figured I’d come up with a list of responses to the naysayers concerning PHP.

1) PHP lacks several important features
PHP is specifically web-centric. This means that many of the features that programmers from general purpose programming languages complain about PHP not having are simply not that important in a web based environment. Asynchronous execution using threads, for example, has very little use when a browser makes one request at a time.

2) PHP doesn’t have “real” object oriented programming support.
Knocking PHP because of a lack of OOP support is so “2003”. While the initial implementation of OOP in PHP 4 was not so great, PHP 5 implemented OOP in a manner that brings it very much in line with the other OOP programming languages out there. But the difference is that with PHP you don’t HAVE to use objects. The true definition of flexibility is when you are free to build as the situation warrants.

3) There are no tools for easing debugging/development problems.
Simply not true. For example, Zend developed Zend Studio which has all of the features of a modern IDE; profiling, debugging, etc. There are also several open source applications that aide in this arena. With the Eclipse PHP plugin coming along, this argument loses even more steam.

4) PHP is slow
Can be true, doesn’t have to be. If you take PHP out of the box, throw it on a web server and leave it there you will see lower performance. But if you build an application that understands caching, loads only what it needs and uses a code cache such as Zend Platform or APC you can get extremely fast performance. For example, using a caching mechanism in Zend Platform I recently demonstrated reducing execution time on a certain program from 600ms to 7ms.

5) There are no serious applications written in PHP.
While this is not true (many companies are using PHP in mission critical enterprise applications and there are several large scale applications available for use) the problem is that this statement diverts attention away from what the real question ought to be. The real question is “What is keeping serious applications from being developed in PHP?” The former statement is often used in a context of ridicule, guile or wholesale discrimination and seldom backed by fact.

There are very few reasons that should keep an enterprise level application from being developed in PHP from a functional perspective. In terms of back office integration today’s dependence on XML makes that concern irrelevant. If your concern is that your enterprise runs on Java then Zend’s Java Bridge built into Zend Platform gives you the option of using PHP to build your web based front end to your Java-based enterprise. Even in Microsoft environments PHP has COM and .NET integration points with Microsoft compatible platforms.

When I look at the php.net’s function reference I see 182 individual modules that are supported natively by PHP. There is support for several databases (not just MySQL), LDAP, IMAP, PDF, XML, shared memory, SSL, bindings to several multi-media engines, SOAP, COM, .NET, multiple compression/encryption schemes, JSON, non-blocking IO for both streams and sockets, XSLT, NIS, Shockwave and on and on and on. These are not the hallmarks of an insignificant programming language.

And this is only the beginning. PHP, with the help of Zend, has been given enterprise credibility via partnerships with IBM, Oracle and Microsoft. These are not industry lightweights. And they are companies who recognize that PHP is more than a simple hackers’ language. They see that PHP has the potential for great things in the enterprise space.

I would argue that once most of these points have been fully considered there are few significant barriers to building serious applications in PHP.

If, after reading this, still think that PHP has no place in the enterprise, please email me at kevin@zend.com. Your thoughts and responses are both anticipated and welcome.