Is PHP Hated?

By Deane Barker on May 16, 2009

Just asking: why do most programmers dislike PHP?: Interesting debate over at Reddit about why PHP is “disliked” among “most developers” (the veracity of that last sentence is up for debate).

Lots of good argument, including this fun rant:

PHP been hacked together in a half-assed way by a community of probably smart but unorganized or inexperienced people who have collectively catered to the absolute laziest crop of developers who think that using a shitty language every day for many years is a good tradeoff for the few days they’d have to spend learning to set up something better than the Fisher-Price crap that’s already on their web host. PHP has no known advantage other than being the path of least resistance, which is a strategic advantage but of course not an actual advantage.

I could get into specifics, but the best way to tell it is that from experience with many languages comes the conclusion that PHP is horrible from an intuitive sense that is more than the sum of the individual flaws with it. Not that some of those flaws aren’t big, but it’s important to note that these flaws add up to a culture of poor quality that feeds back on itself.

Your time with PHP is one compromise after another, and for some reason I’ve never understood there are apparently many people who learned PHP as their one language, cling to it, and defend all of its flaws instead of seeking out better languages, a category into which most of them fall.

You can replace the word PHP with MySQL and this post is still accurate. Half of the old “LAMP” is dead and Python and PostgreSQL are the future.

Gadgetopia

Comments

  1. Count me unimpressed by that tirade. I wish he had gotten into specifics instead of telling us about “intuition” and “gut feeling.”

    PHP has faults and it is certainly cobbled together. But it obviously caters to a pretty broad base of need, and is readable enough that people can get things done with it. And what are the alternatives in this space? Cold Fusion, ASP, JSP — and if you stretch, Perl and Ruby. Almost anything you say about PHP you can also say about four of those five, and Ruby suffers from performance issues. In that company PHP stands out as a pretty decent language all around.

  2. Agreeing with John. I would like to hear what languages these people are using in it’s stead. If someone is using the “perfect language” out there, it hasn’t been released to the general public.

    As for the guy that suggested postgreSQL over mySQL…really? That’s just laughable.

  3. Everyone’s entitled to their opinion but the “Language is the problem” stance has long been disproved. Ada, a perfect example of type casting H$ll, can be used to created utter crap. Having used CF back in the day, I found it to speed dev time greatly. When our budget got cut, the idea of setting up LAMP in a short period of time for zero dollars fit the bill.

    On a personal note, I’m not an OO expert by any means so Python is not something I have taken too. While PHP and it’s functional aspect bring me back to my days of Matlab and such.

    Use what works best for you.

  4. I’m paid to write PHP everyday. I absolutely despise the language, but it gets the job done. In a large project with tons of legacy code (i.e. code written before the project grew large), PHP quickly devolves into a unmaintainable mess of globals. A developer can unwittingly break code in other files by colliding with global variables, and tracing the origin of a given global value can be a nightmare.

    Python, Ruby, and Java don’t suffer from this problem. “Globals” don’t exist in these languages. Every variable, function, class, and constant is scoped to the current class or script. If you don’t explicitly declare or import something, you don’t need to worry about it.

    As for Chris and his laughing about PostgreSQL, he’s mistaken. PostgreSQL is superior to MySQL in every respect but market share. That includes performance, MySQL’s traditional strong point. PostgreSQL is a textbook example of successful scaling on multiple cores. MySQL collapses in a mess of bad multithreading under the same conditions.

  5. PHP is on most hosted websites – and if you code general websites that is why you’ll end up using it. The Web Hosting company isn’t going to install Cold Fusion or ASP.net just for your convenience (if you host yourself then it’s a different matter). And what does Postegre have over MySQL 5?

  6. Not really. As a person who has developed in 15 languages to date and has a good idea how to build a compiler, I wouldn’t rush to stomp PHP into mud. With its recent development in the way of OOP and projects that enforce high code standard, the PHP community is being enriched by good organized coders that come to replace the sloppy coders that didn’t wish to embrace the new paradigm. As any interpreted language it has some nice reflexive qualities that C will never really have. It’s expressive and relatively elegant (if used correctly). On the other hand there is a long history of highly disorganized code in the PHP world. Because it’s so easy to start, it’s easy to neglect the need to learn the better ways. Any easily accessible language has a wide following of mediocre coders, but that’s not exactly the fault of the language. Assembler is completely freehand, so there’s plenty of room for errors and poor structuring. Does it make it a bad and unneeded language? I think not.

  7. To Matthew:

    If your code is written using many globals, it’s not the PHP problem. This could happen in C as well. There’s simply good code and bad code and has nothing to do with the language.

    From the writability point of view I resent having to prefix every variable with $, but on the other hand, when you have to go through the existing code, it helps to better spot the variables. Don’t forget that initially it was intended as a hypertext preprocessing language, so a rich mixture of string literals and program code was expected and there had to be a way to tell one from another easily.

    I also resent not having a forced explicit declaration of variables. Even VBA has “Option Explicit”. That is the one feature that there is no excuse not to have.

  8. @Matthew

    I agree with Alex – if you are writing code into a mess (or someone before you did that), then to blame language that it allows you to do that makes no sense. If you are constantly hitting walls when driving do you really consider that it’s a car’s fault not a driver’s?

    I’ve went all way long from pure functional coding in php to Domain Driven Design, which enforces strict OOP and I can tell you judging by how my current and ex co-workers are coding that it’s a matter of how person understands coding.

  9. The “x people use PHP,” argument is a bandwagon appeal, and thus a logical fallacy, which proves nothing about PHP’s superiority as a language. Many people agree that Linux-based operating systems are by definition more capable than Windows-based operating systems, but the market share is quite low for end-users. You get what you pay for; find a better host if X host doesn’t support Y language. The argument regarding web hosts makes no sense; using PHP because it’s “more widely supported” is just going to discourage hosts from offering x language altogether, which is a terrible attitude to adopt. Python ships in every Linux distro by default, so I fail to see how wider support shouldn’t apply to Python more so than PHP.

    I don’t understand why everyone’s trying to sugarcoat PHP’s lack of namespaces by blaming the coders themselves; this is an issue with the language, not the coder. PHP just pollutes the global namespace like a savant, so unless I prefix all of my variables with a schizophrenic name scheme, then I cannot define $x in both x.php or y.php. And because it takes until 5.3 for PHP to implement namespaces (when it’s practically TOO LATE, because the developers won’t group the function soup they have into namespaces,) they are practically useless, adding to the fact that web hosts wait years just to upgrade their PHP version. I guess you’ll have to forget namespaces in PHP!

    Bad code can be written in any language, but there has to be some standards in place, and the language’s lack of cohesiveness and consistency is not helping at all. At least Python sets the bar by emphasizing good and bad coding practices in their documentation and PEPs. All PHP’s documentation does is vaguely slap a function and its arguments on a page with an ambiguous usage example. What’s worse is that there is a Comments section, which is riled with comments that are wrong 80% of the time. It’s a community of the blind leading the blind!

  10. I don’t have any problem with PHP maybe because I am prepending my code names with the class where I group them. It was not hard for me to find a php 5.3 hosting since I can always ask them to upgrade with justifications. I always either get move to a server that have 5.3 or the server software gets updated.

    On shared accounts that have so many lazy programmers using PHP, I have no choice but to use a virtual dedicated account. I was earning though using this approach by referrals.

    The problem I face most of the time are the first person/group who built a webpage that enforce everything to be read as global. Instead of rendering register_global to off, they intentionally turned it on. Instead of reading POST, GET, SESSION and others using streams they just directly use a php variable that have the same name in either POST, GET,SESSIOn and others.

    Editing this websites/code is a total nightmare specially that most of them just rename a file and build a complex file includes with file includes on each included file up to the nth time. I can’t blame the language here, it is the coders problem which wants faster completion and no quality checking. Some of the people I worked even was surprised to know that I do double checking, I guess this is not a norm for the generation of programmers that was coding for them before.

    I have seen equally bad or even terrible JSP and ASP.NET or ASP programs out there, some even give the whole world a full system admin access on the server. I guess that was funny if you are the one who discover this and not the company who paid people to build that software. 3 out of 10 ASP websites I visited allows me to login without even passing to the login page, that is insanse.

    PostgreSQL may be good for others but it is not for me, there are tweaks that I can apply on the database that makes reading/writing and sorting faster specially when ‘views’ are used. The only shortcoming I have with this database is its notorious error reporting with regards to transactional databases when using INNODB. It won’t tell me that part of the database insertion never happened.

    If anyone can give a potential scripting language that is more useful than PHP then please let me know. If there are any database software that is easier to use than MySQL and can be configured by SHELL access then please let me know.

  11. @Faltzer

    Regarding market share for end user that have Linux/Unix. This is not the operating systems problem but the fact that Microsoft is forcing all manufacturers that they should put Microsoft OS on their machines or their contact with Microsoft be voided. If you have a user base/client base that are using Microsoft OS.. will you just dump them? For a company that care for the market, they will install Microsoft on new computers they built and leave an option for the users to dish out that OS and install Linux. For a users point of view, why removed an OS you paid for?

  12. “While PHP and it’s functional aspect bring me back to my days of Matlab and such. “

    PHP is a procedural language(like C) that has rudimentary OO support(like C++ and Java, all three miss the point about OOP), not a functional language(Haskell, Scala, etc).

    The main problem with PHP can be summed up as “PHP makes it very,very easy to do the wrong thing but constantly gets in your way when you try to do the right thing”.

    And if you think having 50+ characters for function and variable names is an acceptable workaround for the lack of namespaces, then there is no hope or help for you.

  13. PHP has been thrown together (half-hAc3erd), but it along with many other languages is C-based.

    Perl,Curl,Python,XSL-fo,XHTML/XML,AJAX,and JavaScript have all been molded, and Hacked to include libraries that function well. Along with being PieCed like HTML to NOT contain libraries that do not remain consistant with development.

    If you hate PHP, you should check out Zend Framework 1.11+ ZIDS+Doctrine+JQueryX

    You can pretty much see where I am going with this. Pretty much all Object Oriented languages, Markup,Meta,and Data Relationship technologies have been php Phuchk.phar.

    It all goes back to Automata, and ML ,Cobol,etc.they all had their hay day. But none as popular as PHP…. As far as usage.

    There are many people who can run an auto-install of WordPress,PHPBB,and other Web tirants; thinking they understand the true nature of php.

    PHP is very versitile along with Perl, and that is why they have made their way into the .NET framework. LINQ for PHP is awesome, along with the graciousness of MVC frameworks.

    This is just one dorks opion.

    Rob

Comments are closed. If you have something you really want to say, email editors@gadgetopia.com and we‘ll get it added for you.