PHP: Bad design: Good result
Few weeks ago, I was just checking blogs from IT greats, as I usually do. I went through an interesting post PHP a fractal of bad design. It had a nice start-up
Nice blog. This started a new trend of criticizing PHP. What more disappointing is, he said any argument in favor of PHP is not valid. If you started a topic, give others chance to support/oppose you. If you are not open for that, just keep your mouth shut. You don’t like PHP, simply don’t use it. You decide what tool you want to use. Now to this very example, let’s come to cost. The toolbox mentioned above cost $1 and the perfect toolbox that author want cost $100. Well sir, I’m poor and perfectly fine with $1 toolbox. Any new carpenter will choose $1 toolbox and you have no right to blame him for that.
However for the matter of fact, although it do not matter much, below are some PHP statistics. Obviously I collected them from different source and that can be easily validated.
- Around 80% websites use PHP.
- More than 15% of websites in the world are powered by wordpress, which is written in PHP. (By the way I also do not like wordpress much because of globals but does it matter. I don’t like it so I don’t use it except for my this blogs website LOL)
- Three most popular CMS namely wordpress, joomla and drupal are written in PHP.
- One of the worlds’ most used website ‘Facebook’ is written in PHP.
The list may go infinite long but it doesn’t make sense to extend this list.
Now let’s come to the business point of view. Business guides the technology; Technology never guides the business. Can anyone argue on this fact? At the end, it is the business which is going to pay for bread and butter of a programmer and his family. From business point of view, PHP provide most affordable web solutions. Lot of CMS/framework/open source projects written in PHP fulfills most business requirements with minimum investment. Who want to argue on that?
OK I’m a technical person so let’s come to technical point. Most of the points covered in above mentioned article suggest author is speaking mostly about PHP 4 era. Before commenting on that, we must understand starting goals of PHP. Initially PHP was supposed to be easy to learn scripting language for non programmers. A lot has changed since then but since lot of websites were powered by PHP, PHP is forced to keep backward compatibility.
Still PHP 5 came in 2004, and had object oriented model. OK it might look little too late as compare to few other OOP languages like Java, C++ etc but important point is PHP had different goals as compare to C++, Java, SmallTalk etc. This point might be presented as negative point of PHP still PHP always did what it supposed to do (dynamic webs applications) and still it is one of the most easiest languages to learn. The proof is open source solution and website available in PHP.
On some of the technical points raised in articles:
No debugger: Aah what can I say? Just put ‘xdebug’ in Google and see the result.
Globals: Well even I too don’t support using globals and even it is depreciated in latest PHP versions. Still I’d say what is wrong with it. Global variable is simply a variable which exist in a request lifecycle. Same ‘scope=request’ concept is available in most other language by different name. So why complain about it in PHP?
Lack of threading: Yes PHP do not support threads. Do we really need that? Remember PHP is not available for desktop applications but only for web applications. Threads are useful to do multiple tasks simultaneously and they happen asynchronously. When a request comes on a web server, it ends with the response. What could we do here in different threads? I don’t think PHP needs threads just for the sake of providing it.
Inconsistent: I must fully agree there. PHP have weird naming convention which make it difficult to predict matching function. I too don’t like that but what is the other option as valuable as PHP? There is no other option and as per my experience, no new solution will appear in near future. At the same time, this problem of PHP is neutralized with good documentation/manual. You need something which you can’t remember, just type in Google and you have it without even looking at second result. So even though this is biggest negative point of PHP, it is acceptable price for the benefits and power that PHP provide.
There is a long list of such small issues. It doesn’t make sense to invest time to write on all of them.
At the end, I must say, technically I agree on most topics like PHP is inconsistent, it have weird behavior, code might look ugly and awkward etc. But does it really matter for business? If it does, what about wordpress, drupal, Hudson etc. Who can say they have perfect source code but they all are popular and dominating the market; just because they do what they are supposed to do and do it very well. This is the key. If you are good looking but do not do what you are supposed to do, sorry you do not fit in business.
At the same time, from business point of view, PHP is incredibly powerful. It is very easy to learn. Most important, it provides the perfect solution to business requirements with minimum investment and time. As a technical person, I’m supposed to provide technical solutions to my company/clients and PHP is one of my easiest, cheapest and biggest tools. I do not shy to say, even after all the valid technical issues, I love PHP & definitely going to recommend it to my clients without any hesitation.
This site uses Akismet to reduce spam. Learn how your comment data is processed.