Jaybill McCarthy Dispells 10 PHP Myths

January 3, 2008


“Jaybill McCarthy”:http://jaybill.com/ has written an excellent blog post to open the year with, “10 PHP Myths Dispelled”:http://jaybill.com/2008/01/02/10-php-myths-dispelled/. In it he spends a paragraph on each of 10 myths about PHP and show why they are just not true.

bq. Myth #1: PHP is not a truly Object-Oriented Language

I hear this one a lot from Java programmers. It’s completely false. PHP has excellent OO language facilities. There’s inheritance, abstract objects, interfaces, properties and methods. Okay, there’s no polymorphism. (Personally, I think polymorphism might be the worst idea ever, but that’s just my opinion.) I will say that there have been vast improvements in PHP’s OO mechanics with PHP 5, but I’ve written lots of PHP 4 apps that were totally OO. The mere fact that you can write purely procedural PHP code doesn’t mean that PHP isn’t OO capable. Furthermore, the fact that PHP allows you to mix OO and procedural code makes things like bootstrap scripts really simple.

He goes on to tackle topics like:

*(disc) PHP Encourages Sloppy Code
* PHP is slow because it’s interpreted
* PHP isn’t really for “serious” developers

Click on over to “10 PHP Myths Dispelled”:http://jaybill.com/2008/01/02/10-php-myths-dispelled/ and give it a read.

About Cal Evans

Many moons ago, at the tender age of 14, Cal touched his first computer. (We're using the term "computer" loosely here, it was a TRS-80 Model 1) Since then his life has never been the same. He graduated from TRS-80s to Commodores and eventually to IBM PC's. For the past 10 years Cal has worked with PHP and MySQL on Linux OSX, and when necessary, Windows. He has built on a variety of projects ranging in size from simple web pages to multi-million dollar web applications. When not banging his head on his monitor, attempting a blood sacrifice to get a particular piece of code working, he enjoys building and managing development teams using his widely imitated but never patented management style of "management by wandering around". Cal is happily married to wife 1.31, the lovely and talented Kathy. Together they have 2 kids who were both bright enough not to pursue a career in IT. Cal blogs at http://blog.calevans.com and is the founder and host of Nomad PHP

View all posts by Cal Evans

6 Responses to “Jaybill McCarthy Dispells 10 PHP Myths”

  1. sevenforty Says:

    System Administrators, clients/customers, etc are often novices when it comes to fully understanding development and programming languages. I agree that it is tough to convince those making decisions especially when they have pre-conceived and misinformed biases or limited knowledge.

    The problem is, is that many of these myths the original author comments on are real and run rampant in forums, blogs and what not and promote the stigma that PHP endures. The easy integration of PHP with web servers, while technologically fantastic, allows for novice/amateur developers to dabble in programming and push horrible production code out. I’ve personally taken over many PHP projects that are filled with junk, spaghetti code that was developed by "professional" programmers.

    It’s not the inherit fault of the language; however, it unfortunately takes the brunt. If Java were as easily as accessible, the same conceptions would be had with Java.

    I agree that PHP is an effective choice with the advent of PHP5 these days. Coming from a very strong Java background, I believe that a large percentage of Java applications out there could easily have been done more effectively in PHP.

    As for insecurity in PHP, security in web applications falls fundamentally first and foremost in the hands of the developer. Without a competent developer, security bugs will be in any language.

  2. gcornelisse Says:

    It’s not just novices that make these assumptions. It’s clients/customers, system administrators, and IT departments too. I admit it’s easier these days to sell a PHP product or service without the usual defense of PHP, but the unfortunate stigma PHP has garnered for many years still pops up more frequently than I’d prefer.

    Logic, such as stated in this top 10 list, is often not enough to overcome the ignorance. I believe there are an unfortunate number of companies that spend too much time and money going with another language when PHP really would be the most effective choice.

    I recently dealt with a department sys-admin of a state University that simply wouldn’t install/support PHP on their servers because "it’s not secure". All the while their peers in other departments have embraced PHP and are obviously the better for it. Frustrating…

  3. jbeall Says:

    Previous poster states:

    "e.g. Strings [are not] objects ([or you could] do e.g. "this".doSomething() in PHP )."

    The unstated assumption is that in order for a language to be considered "object-oriented", all data structures must be objects.

    This is academic nonsense. Not even Java or .NET have primitive types that are objects* — are they not object oriented either?

    According to Wikipedia (and any sensible programmer), "Object-oriented programming (OOP) is a programming paradigm that uses ‘objects’ and their interactions to design applications and computer programs."

    PHP is perfectly capable of this programming paradigm, and as such, can be considered "object-oriented".

    If it really upsets you so much that certain primitive types are not also objects, write a String wrapper class and use that instead.

    *Java and .NET both have autoboxing, which will transparently convert primitive types to their corresponding wrapper objects, allowing you to interact with them as if they were actually objects. But this has not always been the case. Before autoboxing, would you claim that Java was not object-oriented? Absurd!

  4. _____anonymous_____ Says:

    It seems that the above commenter doesn’t understand the relation of native data types to OO programming. Under her or his definition C++ wouldn’t be considered an object-oriented language.

    There exist many object-oriented languages that also have native data types. Another way to say it is: a language ‘supports’ object-oriented programming, which PHP 5 does just fine. Any and all object-oriented programming one wants to do, and any object-oriented design patterns one wants to implement, can all easily be accomplished with PHP 5.

    There are a few languages where every single piece of data or variable is an actual object internally to the language, like SmallTalk, but that doesn’t mean that other languages (that have native data types that aren’t actual objects) don’t allow programming in a fully object-oriented way, including Java, PHP 5, C++, and many others.

  5. _____anonymous_____ Says:

    While it is true that PHP has some features of an object oriented language, PHP is NOT truly object oriented. Are e.g. Strings objects (when could you do e.g. "this".doSomething() in PHP ). Hence: this is not a myth, but a fact — and don’t pretend otherwise.

  6. sevenforty Says:

    The author makes some good points and I’ve seen the MVC issue many times before (ironically often Rails developers) that simply do not understand what MVC is or even what a design pattern is.

    However, I believe that the article should be changed to "10 PHP Myths that Novice Programmers Make". No self respecting developer would really believe in any of these myths.