Learning from PHP and MySQL, then dismissing them

Aristotle on 2007-07-31T21:24:00

Perrin Harkins:

There’s a tendency to just write off entire popular projects with some kind of sweeping generalization. […] Even if they aren’t your chosen tools, keeping enough of an open mind to learn from what they do right is worth it.

That’s easy enough: PHP is the best proof for Elaine’s Law that there is. It’s pretty awful, but the barrier to entry for new users is far lower than with any competitor, and the new web frameworks in other languages have not changed this fact either. Most of them are now competitive with PHP for developers already proficient (to some extent) at programming in general and with the underlying language in particular. But they’re still far harder for non-developers who just want to install an app to use it.

To some extent, the success of MySQL goes back to the same reason; certainly it is how MySQL gathered so much seminal momentum – nothing at the time was even close to its degree of simplicity of installation and maintenance. I posit that if SQLite was available at the time, MySQL would never have happened (as far as the world is concerned) and the arena today would be shared between SQLite and PostgreSQL. That is, assuming anyone had invested as much work into clustering Pg as has gone into MySQL – because while solutions for that exist for Pg, you have to pick from one of several and they’re all harder to get going than MySQL. (There’s Elaine’s Law again.)

And I agree that we should learn from that. The clearest implication is that fixing the CPAN toolchain (which was fine enough in the era of its conception, but times have changed and we need to follow) is of the essence if we want to regain impact. Adam Kennedy, Schwern, Ken Williams, Ovid, Andreas König and a host of others deserve high praise for their ongoing work in that area.

But I don’t see how being openminded enough to learn from the strengths of others implies not criticising them. I don’t shy from criticising Perl; why wouldn’t anyone else be fair game?

Of course, criticism should have basis in fact; statements like “if everyone used Pg, we wouldn’t need database partitioning” are a fool’s utterance. And I have written PHP code in the past, and currently administrate several PHP applications for other users. I also use MySQL fairly heavily both as an admin and as an SQL developer. On those grounds, I would qualify my involvement with both as unfortunate; it did nothing but give me more grounds on which to criticise them. However, I think exposure to the sometimes disturbing facts alone is enough for some criticisms levelled against these platforms, even without any experience using them.


civility, not silence

perrin on 2007-08-01T19:38:29

Saying PHP is "pretty awful" without actually talking about any specific issues with it is just the kind of thing I mean. It adds nothing useful to the discussion and creates an environment of insults and flame wars. If you want to talk about things that bother you in PHP, go ahead, but you'll get better results if you do it in a way that's less insulting and more constructive.

Maybe my attitude about this comes partly from going to conferences and meeting the developers who work on these things. There are people behind these projects. They're not a faceless mob. Rasmus is a smart guy, and fun to talk to. Ditto for the MySQL guys. Insulting these people is not in anyone's best interest. It certainly isn't going to convince them to see things your way.

P.S. It's "Harkins"

Re:civility, not silence

Aristotle on 2007-08-04T21:41:26

I sat on this comment for a couple of days because I didn’t know quite where to start with the response.

  1. Would you object if I called bash a pretty awful programming language? Do I really have to list all the specific problems that make it unfit for a very large domain of problems, every time I want to say it’s unfit for them? Assuming you wouldn’t: why is bash fair game but PHP sancrosanct?

  2. My motivation is not to fix PHP. It is plenty successful despite all the naysayers anyway, but even assuming the PHP developers ever found any credible reason to listen to me (I don’t see any, nor did I ever claim they should do so), and started making the language more like how I think it should be, the result would inevitably have very little in common with PHP as we know it.

I know there are people behind these projects. I generally don’t attack developers; I hope they are mature enough to be able to tell critcism of their work apart from criticism of their person.

But in the case of PHP specifically, I have multiple anecdotes that lead me to doubt the competence of the team at hand.

  • For one thing, there’s the hair-raisingly bizarre “fix” to a security problem.

  • There’s also the whole sordid story surrounding Stefan Esser in general.

  • There’s the fact that they changed the pass-by-reference semantics in a pointrelease (replacing one flawed semantic with another, no less).

  • There’s the fact that they introduced the === operator to address the lack of an object identity comparison, except that the semantics of === are completely worthless for the purpose. (The problem it does address should, in my opinion, have been addressed the way Perl does it: have multiple comparison operators each imposing a particular type on its operands; specific example of how PHP would look nothing like PHP if anyone had reason to listen to me.)

That’s just off the top of my head.

We haven’t really gotten into criticisms of the language proper yet. What annoys me most about that are the APIs:

  • I tried to do some image processing, and couldn’t find a way to write my code tidily because the API is so misshapen.

  • I tried to process zip archives and couldn’t find a way to do it efficiently and with tidy code because the API is stupidly limited.

  • I tried to bolt a minor feature onto PHP Markdown but gave up because I couldn’t find a way to do it concisely and efficiently: there is no way to capture part of a match when you do a substitution.

  • Every PEAR package I’ve seen promptly follows the terrible example of the builtin library.

That’s just off the top of my head.

Are you really suggesting that I have to rattle off this entire list every time I want to say “PHP is awful”?

Re:civility, not silence

perrin on 2007-08-05T15:03:27


I know there are people behind these projects. I generally don’t attack developers; I hope they are mature enough to be able to tell critcism of their work apart from criticism of their person.

I've never met a developer who wouldn't be upset by someone calling their code awful.

But in the case of PHP specifically, I have multiple anecdotes

Good. Those sound much more reasonable than a blanket statement.

Saying something really general like "PHP is pretty awful" looks like denial of the things that are great about PHP. For example: it's open source, it's a high-level dynamic language, it has good OO support, it's fast, and it helped thousands of people take the web into their own hands instead of leaving it to the AOLs and CNNs of the world.

Are you really suggesting that I have to rattle off this entire list every time I want to say “PHP is awful”?

That depends on the context. If you're trying to express some kind of serious statement about PHP (as opposed to just ribbing some PHP-coding friend), then staying away from pejorative generalizations will almost certainly lead to a better conversation.

Also, regarding bash programming: bash is a product of its time. When it was introduced, it was pretty cool, and an impressive piece of work. Better options exist now. That doesn't make bash awful. I would never code in Perl4 now, but I don't call Perl4 awful just because Perl5 has improved on it so much.

Re:civility, not silence

Aristotle on 2007-08-05T20:41:28

I guess this comes to down to a difference in points of view.

I assume, on principle, that my code is generally awful… :-) Sometimes I know it’s not, in which case someone else’s calling it awful just makes me shrug; unless I know it’s a sharp programmer in which case I ask. (Even then I’d be hard pressed to ever use an epithet like “beautiful” – the best thing I have to say about any particularly good piece of code I wrote is that it’s “simple”.)

Likewise, I don’t deny that there are worthwhile things about PHP – how else would it ever have gotten to be so successful? I use several PHP apps myself! OTOH I would never write anything non-marginal in PHP, just like I’d never write anything complex in shell.

And yeah, bash was indeed impressive at its time, and so was Perl 4. But I'm not sure that line of reasoning is useful; where do you draw the line? I mean, if you take this to its logical conclusion, you'd have to say that compared to assembler, anything looks good -- and even assembler was a milestone compared to punchcards. But that was then; today, no one in their right mind would write complex apps in bash or Perl 4, much less in assembler. In the context of the here and now, PHP is an awful choice.