-
Why PHP?
Posted on May 21st, 2008 5 commentsI just finished reading an article basically mirroring my own sentiments regarding PHP’s status amidst the hall of great programming languages. I thought I’d chime in in regards to why I think php is so widely used when there are so many more elegant programming languages out there for dynamic web applications. Using php seems akin to using C++ when you could be using Java. True you can probably develop more efficiently in Java but there is nothing you can do in one but not the other in regards to the end product. Ultimately you get to the same place, you just have to take different routes.
I mentioned alot of this in my previous article about why I choose not to develop with Ruby on Rails when Ruby is a much nicer language to work with than php. I’ve developed in quite a number of languages (C, C++, Basic, Visual Basic, C#, Ruby, Python, PHP, Java, Scala, to name a few), so I’ve had the opportunity to see what sets languages apart. Some of these languages I love and some I loathe all for different reasons. If I had my choice in a perfect world, I would not use php and ultimately nothing is forcing me to do so, but there are reasons why I and many many other developers do it.
You would think the deciding factor for the choice in language/platform would be functionality (ie features). Contrary to logic, this is not usually the case, the undeniably critical word is “Community”. Languages that have large communities always succeed no matter how horribly designed the language is. Just look at Java. I used to love java, but that was because I was coming from C/C++. Now that i’ve gained worldly knowledge, Java now appears to me to be a grossly verbose, overly-complex, non-ideal language. Don’t misunderstand that for the JVM which is an engineering miracle, I speak only of the Java language itself. I won’t go into the reasons why as that’s not the point, only that if I had to design a seriously hardcore enterprise application I would probably choose the JVM as my platform, even over PHP.
With community comes support. This means a developer can easily get questions answered either by doing a quick search through some documentation, forums, mailing lists, tutorials, etc, or just by asking other developers. Response time will be quick and its likely that someone else has already run into the same problem and had it resolved. Secondly, comes extensibility. Well known languages usually have vast repositories of third party or user-contributed add-on modules, extensions, plugins, etc. A developer who knows that they don’t have to reinvent the wheel when developing what should be a simple application while likely turn to a platform that has alot of reusable components.
It’s critical to reiterate the main point of the parent article as well as my own words which is that good programmers can make art with homely tools. Successful applications are a result of good practices, not good platforms. Perhaps the reason that Rails is not breaking ground in the enterprise market in addition to reasons I’ve mentioned before, is that developers that use rails probably tend to rely on the constructs of the framework/language to make things happen. That’s part of the magic of Rails is that you can make a lot of stuff happen with a minimal amount of code but that is a very dangerous double edged sword in that you also give up a lot of control.
PHP has a grab bag of issues at the fundamental level such as a half baked concept of object oriented programming from the start (Much improved in php5 but still lacking). It also lacks that functionality to gracefully and ’securely’ to emulate certain functional paradigms like closures (which would seriously cut down on the amount of required code as well as boost stability). This is not saying it can’t be done. I’ve written stuff that look like closures (In 2 lines instead of 1), but its not the same thing. Also because php looks alot like C, it doesn’t promoted elegant design the way that something like ruby or python does. This isn’t necessarily a fault but it doesn’t help either. Like one of the quotes in the parent articles states, its too easy to make spaghetti code in php by mixing php with sql with html with god knows what else. Being a dynamic language by nature (mostly untyped), its easy for web noobies to teach themselves php and inadvertently propagate very bad programming practices. It’s much easier to write crap code than it is to write really elegant MVC (Model-View-Controller) applications. It’s the aftermath that is the nightmare (maintenance, extending).
I don’t think php was designed by computer scientists by any stretch of the imagination and it is clear it was implemented with minimal planning. It took off in a time when the alternatives were asp and perl (Yeah there was lisp but what kind of geek do you have to be.. heh). The sad reality is that its still hard to integrate python or ruby into apache the same way you can with php, those things definitely need to improve. With huge repos like PEAR and PECL, and sites like phpclasses.org, noobie developers are more likely to be guided towards php when traversing google’s collective suggestions regarding web development.
Perhaps php might earn some respect if php6 is any good. Until then, it will probably continue to the scapegoat of the web that we all use but refuse to openly acknowledge.
5 responses to “Why PHP?”
-
[...] is NOT elegant? The Realm of Zod argues that it doesn’t matter, it’s the community that counts. Adrian Sutton argues that it’s not the elegance that matters, it’s the [...]
-
Hi, do you share any of your code on SVN or Google Code? A lot of it is interesting, the PHPTAL, your Modular Directory Structure, all of this integrated on SVN would be great.
-
I am planning on releasing a large amount of code into the wild pretty soon once I polish up my cms a little bit. I’m deploying a large website with it at the end of next month which will be a good benchmark for its performance. Either way, at the very least I’ll release a tarball with the current incarnation
-
My sentiments exactly. I had a customer recently who brought a consultant to a contract discussion. The consultant’s first words were “So, why aren’t you using Ruby or Django. PHP is so linear and hard to maintain.” I have looked at Ruby on Rails, Django/Python and others, but I keep coming back to the community around PHP. I usually find several possible solutions to any given problem and then review/test them to determine the best fit for my application. I also have found a much greater abundance of humility combined with real-world knowledge in the PHP community. In the Rails community, I have met with a lot of arrogance and immaturity (granted, my experience is limited). I especially dislike the attitude in the Applesque videos on YouTube advertising Rails. A tool is only a tool. It’s how the tool is used that makes the difference in the end. And I know PHP!
-
chrisw June 26th, 2008 at 03:08
Interesting article, and as an experienced programmer moving into PHP work, I’m inclined to agree with your view of PHP. FWIW, I’m finding the Zend Framework (1.5) a huge help in enforcing a solid MVC approach to developing my app, not to mention the many useful components in ZF generally. Just wish the documentation was a little better !
Leave a reply
-


