PHP Sucks, But It Doesn't Matter

PHP is so popular for a few reasons:

  1. It sucks but it’s a modern-day kind of suck. Not a 10 years ago kind of suck which is altogether a different kettle of fish.

  2. The WWW is still young enough that you can get a lot of eyeballs with applications that are of the “low hanging fruit” variety. Put another way, the apps aren’t doing terribly complicated things but what little they do can be popular because we haven’t gotten to the more complex things yet.

  3. A lot of the complexity lives on the client via javascript or HTML. So PHP is mainly a glue for generating the right HTML/javascript.

  4. A lot of the complexity lives on the server (I’m thinking RDBMSs, back-end processing, etc…).

I expect most of those popular websites to move to a more structured framework by the time AJAX 2.0 is passe. They’ll crumble under their own weight if they don’t.

PERL apps followed a similar trajectory. PERL was so easy to use that you could get a working product out the door in much less time. By the time you’re on your 6th version, feature creep + a too-freewheeling language have prompted a rewrite in either java or C++…

The 180 comments in this page shows only one thing:


It doesn’t suck Jeff, you are just a shitty programmer LOL xD

God… I don’t think I’ve ever seen so many elitists on one web page.
The hammer is only as good as the carpenter, plus, how many hammer do you get (which are free to the public) which don’t break?

Some of you assholes need to get over yourselves.

Reading these comments further, if you take nothing else away from this lesson (beating?!), Thomas Borzecki has written one of the concisest, yet most useful comments I have ever seen, particularly the last sentence. Heed and learn, then maybe TRY using PHP (or or any other language/environment properly before slating it!

I would have to say, coming from Java, PHP was really easy to pick up and start using almost right away.

I am still not used to the (VB) and have been using it for almost a year at work. I understand it’s a framework but some of it is so hard to use. HttpContext.Current.User.Identity.Name to get a username instead of $_SESSION[‘username’]. Just seems easier. Less stuff to deal with. $_GET, $_POST, $_SESSION, $_FILES is all I really need to know about PHP. Asp.Net there’s just so much more to pick up.

But i guess theres a give and take in any situation.

I love Visual Studio, the best IDE i have used however, the new Zend Studio is pretty good too and does have support for Refactoring. OOP and exception handling in PHP 5 are fine with me.

I don’t know if you’re being entirely fair. Having so many functions is evidence of:

  • How far PHP takes you before you have to do any of your own library writing, and
  • The historical lack of namespaces (coming, I believe, in PHP6).

Re: function name conventions: functionnamelikethis() and FunctionNameLikeThis() are identical. PHP function names are not case sensitive… Admittedly having this_convention() and thisConvention() is kind of a kludge, but it’s like that for historical reasons.

And browsing the function library will get you 99% of the info you ever need.

@steven rodgers, I suppose you write your websites in C++? Everything else is bytecode or interpreted. Don’t be such an elitist. Did you know PHP compiles to bytecode if you use an optimizer? There are many options, many of which are free.

PHP does some wonderful things and the key is that, like C++, it supports many programming approaches and it’s up to the developer to follow best practices. (Heck, it even has anonymous/lambda functions, besides objects, literals, and the usual.)

Note, though, that Facebook is partially PHP and partially C++ and Erlang and other languages.

I read PHP’s rand function. I read what their developers said about it. They are fools, they know nothing about seeding they know nothing about their silly rand function. rand is broken on win32 because the developers made stupid assumptions and then got blown away by casting floats to longs and assuming their bits were random.

PHP sucks, PHP devs are pretty awful, developers who use PHP - grow up.

Hey Jeff,

I think you failed to mention that Yahoo! is one of the largest PHP shops around. At MIX during the interview of Steve Ballmer by Guy Kawasaki, Steve mentioned how Microsoft was the biggest ASP.NET shop around. Then Guy mentioned that Yahoo! was the biggest PHP show around. Steve followed that up that if the Microsoft merger with Yahoo went through, Microsoft would be the biggest ASP.NET shop AND the biggest PHP shop.
Although PHP has more warts than a hundred toads, that doesn’t mean you can’t write clean, well-designed code with it. As already mentioned in previous posts, there are various MVC frameworks written in PHP, and there are developers who write object-oriented, n-tier code with unit tests, etc. By the way, most of the crappy PHP out there is written in PHP 4, PHP 5 is a completely different ball game.

Is it not possible to introduce concepts like N-Tier, Unit testing, frameworks to PHP?

I don’t think the problem is with the language, but with the communitiy. I like the ASP.NET community more that PHP’s. Because PHP’'s community seems to be dominated by many “scriptkids” hobbying in in their basements. As a result, there are a lot of bad code examples on the net on PHP. Whereas ASP.NET enjoys much more professional community.


Have you been living under a rock the last 5 years?
This stuff is all available in PHP5.

Just to name a few main stream frameworks:
Zend Framework

The unit testing suit for PHP is created by Sebastian Bergmann.

N-Tier is a way of building applications. It should not be build in a language. It’s something you should be able to create with any language available.

As far as the function naming goes. i agree. It’s a mess. And even the parameter order for the functions are mixed. Like reversing the needle and haystack. But that doesn’t cause bad code to be written. I’ve been a web developer for the past 10 years. And have seen my fare share of bad coding. Not only in PHP. This has nothing to do with the language. It’s because PHP is a trend. So everybody jumps on the bandwagon.

This phrase made me smile though :slight_smile:

PHP isn’t so much a language as a random collection of arbitrary stuff, a virtual explosion at the keyword and function factory.

Listen to what inventor of php Rasmus Lerdorf thinks…

I think the problem with PHP is the same as with Javascript: too many people have access to it. We all hate Javascript because of the astounding amount of bad Javascript that is out there. And there’s a lot of it because everybody with a browser has a compiler. PHP is on most every Apache server out there, so non-programmers who just have a website can use it. It’s a step away from Javascript’s ubiquity, but close enough.

I write in PHP, but I come from a COBOL background, where I had to structure everything just write and keep under the 4kb memory limit. My stuff is clean, so I will defend PHP as a tool.

As far as apps available written in it: I totally agree that most are worthless.

What is wrong with wanting beauty for beauty’s sake? It is good to have languages and tools that do not make you queasy all the time! For the reasons you mentioned, I am glad that I do not have to use PHP on a regular basis.

That being said, I do find that I can accomplish a lot in PHP with just a few lines of code. It just always feels like an ugly solution.

Facebook’s written in PHP too, I think.

PHP’s lack of namespacing from the beginning is probably a major downfall, but you can go too far the other way if you’re not careful (just look at the sheer size of Java and .NET’s respective runtimes). Namespacing has a tendancy to encourage growth, especially if it’s nice and extensible.

Hopefully PHP 5.3/6 will strike a balance here, though.

Personally, I know that nice, structured, designed code can be written in PHP (it’s what I do for a living, and I know I’m not alone in that), but I don’t tend to go posting code snippets in forums asking for help. None of this is because I’m an experienced PHP programmer, of course, but because I’m an experienced programmer in general—PHP’s biggest failing was giving novices who didn’t know better enough rope to hang themselves.

it all depends who’s coding…

Facebook’s written in PHP too, I think.

Paul – thanks. I knew I forgot a big one in there somewhere. Added.

I always thought Youtube was built with Python not PHP.

“PHP’s biggest failing was giving novices who didn’t know better enough rope to hang themselves.”

While I agree that it is a problem giving novices the rope to hang themselves, I believe that this is actually a symptom of an even bigger failing: PHP presents developers an inconsistent environment, because things can be toggled on and off by INI settings.

Magic quotes is a good example here. It’s on by default in php.ini-dist and off by default in php.ini-recommended. This means that people who learned on one are going to get it wrong on the other, leading to SQL Injection attacks.

Of course, the correct way for experts to handle it is the use of the magic_quotes_gpc() to see what the current setting is and handling it appropriately.

Another symptom of the same problem is that you cannot rely on anything but the most basic of functions to be present, as most can be turned off at the edit of an ini; either by module by commenting out the module’s name or by function using the disable_functions setting.

One huge advantage php has over .NET is the transparency and editability of the source code to front end developers.

Working on a PHP site I can dive in knowing little more than to comment out " and ', and can make changes to id’s, divs etc without having to know the language.

However, working on the front end of a .NET site you either have to constantly bother the back-end developers to alter the source for you, or learn a fair bit about the relationships between the controls and the html they output.

If you care about back-end and front-end developers being able to work seamlessly together then php definitely helps.